library: shape: add Shape trait definition

This commit is contained in:
Bruno BELANYI 2020-03-16 15:25:21 +01:00
parent 6aaf927823
commit 924f6bcc3c

View file

@ -0,0 +1,13 @@
use super::{Point, Point2D, Vector};
use bvh::aabb::Bounded;
use bvh::ray::Ray;
/// Represent an abstract shape inside the scene.
pub trait Shape: Bounded + std::fmt::Debug {
/// Return the distance at which the object intersects with the ray, or None if it does not.
fn intersect(&self, ray: &Ray) -> Option<f64>;
/// Return the unit vector corresponding to the normal at this point of the shape.
fn normal(&self, point: &Point) -> Vector;
/// Project the point from the shape's surface to its texel coordinates.
fn project_texel(&self, point: &Point) -> Point2D;
}