diff options
Diffstat (limited to 'src/world/mod.rs')
-rw-r--r-- | src/world/mod.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/world/mod.rs b/src/world/mod.rs index cba6ddc..0779551 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -5,7 +5,7 @@ mod scene; pub mod container; mod hittable; pub use scene::*; -pub use hittable::{Intersection, Hittable}; +pub use hittable::{Intersection, Hittable, DynHittable}; pub use shapes::Shape; use std::sync::Arc; @@ -13,22 +13,22 @@ use crate::material::Material; use crate::core::{Bound3f, Ray}; pub struct Object { - pub shape: Shape, + pub inner: DynHittable, pub mat: Arc<dyn Material>, } impl Object { - pub fn new<T: Into<Shape>>(mat: Arc<dyn Material>, shape: T) -> Self { + pub fn new<T: Into<DynHittable>>(mat: Arc<dyn Material>, inner: T) -> Self { Object { mat, - shape: shape.into(), + inner: inner.into(), } } } impl Hittable for Object { fn intersect(&self, ray: &Ray) -> Option<Intersection> { - if let Some(mut inter) = self.shape.intersect(ray) { + if let Some(mut inter) = self.inner.intersect(ray) { inter.add_material_if_none(self.mat.as_ref()); Some(inter) } else { @@ -37,6 +37,6 @@ impl Hittable for Object { } fn bounding_box(&self) -> Bound3f { - self.shape.bounding_box() + self.inner.bounding_box() } } |