[][src]Trait rpt::Shape

pub trait Shape: Send + Sync {
    pub fn intersect(
        &self,
        ray: &Ray,
        t_min: f64,
        record: &mut HitRecord
    ) -> bool;
pub fn sample(
        &self,
        target: &DVec3,
        rng: &mut StdRng
    ) -> (DVec3, DVec3, f64); }

Represents a physical shape, which can be hit by a ray to find intersections

Required methods

pub fn intersect(&self, ray: &Ray, t_min: f64, record: &mut HitRecord) -> bool[src]

Intersect the shape with a ray, for t >= t_min, returning true and mutating h if an intersection was found before the current closest one

pub fn sample(&self, target: &DVec3, rng: &mut StdRng) -> (DVec3, DVec3, f64)[src]

Sample the shape for a random point on its surface, also returning the normal and PDF

Loading content...

Implementations on Foreign Types

impl<T: Shape + ?Sized> Shape for Box<T>[src]

impl<T: Shape + ?Sized> Shape for Arc<T>[src]

Loading content...

Implementors

impl Shape for Cube[src]

impl Shape for MonomialSurface[src]

impl Shape for Plane[src]

pub fn intersect(&self, ray: &Ray, t_min: f64, record: &mut HitRecord) -> bool[src]

Ray-plane intersection

impl Shape for Sphere[src]

pub fn sample(&self, target: &DVec3, rng: &mut StdRng) -> (DVec3, DVec3, f64)[src]

Sample a spherical light source, somewhat respecting the solid angle from a target point

Currently, this implementation just generates a random point in the hemisphere facing the target point, weighted by the cosine. This isn't the most sophisticated technique, since you can sample the solid angle exactly, but it's pretty good.

impl Shape for Triangle[src]

impl<T: Bounded> Shape for KdTree<T>[src]

impl<T: Shape> Shape for Transformed<T>[src]

Loading content...