diff options
author | Julian T <julian@jtle.dk> | 2021-08-05 15:44:40 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-08-05 15:44:40 +0200 |
commit | 3ef8f4d918406eec6bdc29e0ebd883fabfac9b2e (patch) | |
tree | aa4b1aac1e165821c16f222ebfb9212a9740e98b /src/world/hittable.rs | |
parent | 45119506c0293fdde6cef35f6e6f82d4055b46b6 (diff) |
Add picture for c5505ab84820248c6dba35fc06aef9e0ced183derendered
Diffstat (limited to 'src/world/hittable.rs')
-rw-r--r-- | src/world/hittable.rs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/world/hittable.rs b/src/world/hittable.rs deleted file mode 100644 index e11a3bc..0000000 --- a/src/world/hittable.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::core::{Vector3f, Bound3f, Ray}; -use crate::Float; -use crate::material::Material; - -/// Returns the context of a intersection -pub struct Intersection<'a> { - /// Normal vector at intersection - pub n: Vector3f, - pub p: Vector3f, - pub front: bool, - pub t: Float, - pub m: Option<&'a dyn Material>, -} - -impl<'a> Intersection<'a> { - pub fn new(out_normal: Vector3f, point: Vector3f, ray: &Ray, t: Float) -> Self { - let front = ray.direction.dot(&out_normal) < 0.0; - Intersection { - n: { if front { out_normal } else { -out_normal } }, - front, - p: point, - m: None, - t, - } - } - - pub fn add_material_if_none(&mut self, mat: &'a dyn Material) { - if let None = self.m { - self.m = Some(mat); - } - } -} - -/// Defines a common trait for objects in the scene -pub trait Hittable: Sync + Send { - /// Returns the intersection with ray - fn intersect(&self, ray: &Ray) -> Option<Intersection>; - - /// Returns the axis alligned bounding box containing self - fn bounding_box(&self) -> Bound3f; -} |