diff options
author | Julian T <julian@jtle.dk> | 2021-02-21 18:01:56 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-02-21 18:01:56 +0100 |
commit | da1c3949a449f3fafe579c62ff6b14ffd993a197 (patch) | |
tree | 754df5c9b5e9f0fa0a8bb7a8cd3dd4b12fe5ad89 /src/world/mod.rs | |
parent | c695da871a75bb6786c08c3546ef71ed032bd61d (diff) |
Add 3d bounding box and merged SceneIntersection and Intersection
Diffstat (limited to 'src/world/mod.rs')
-rw-r--r-- | src/world/mod.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/world/mod.rs b/src/world/mod.rs index f0ba8d2..43f7530 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -2,11 +2,15 @@ pub mod shapes; mod scene; +mod container; +mod hittable; pub use scene::*; +pub use hittable::{Intersection, Hittable}; +pub use container::HittableList; use std::sync::Arc; -use crate::core::Hittable; use crate::material::Material; +use crate::core::{Bound3f, Ray}; pub struct Object { pub shape: Box<dyn Hittable + Sync>, @@ -21,3 +25,13 @@ impl Object { } } } + +impl Hittable for Object { + fn intersect(&self, ray: &Ray) -> Option<Intersection> { + self.shape.intersect(ray).map(|mut i| {i.m = Some(self.mat.as_ref()); i}) + } + + fn bounding_box(&self) -> Option<Bound3f> { + self.shape.bounding_box() + } +} |