From ae460c3f34838e3baf0ffafe4ccbcf1fbfe03095 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 31 Jul 2021 18:27:56 +0200 Subject: Remove dynamic boxes from object and list implementation --- src/world/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/world/mod.rs') diff --git a/src/world/mod.rs b/src/world/mod.rs index 3a09522..cba6ddc 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -6,21 +6,22 @@ pub mod container; mod hittable; pub use scene::*; pub use hittable::{Intersection, Hittable}; +pub use shapes::Shape; use std::sync::Arc; use crate::material::Material; use crate::core::{Bound3f, Ray}; pub struct Object { - pub shape: Box, - pub mat: Arc, + pub shape: Shape, + pub mat: Arc, } impl Object { - pub fn new(mat: Arc, shape: Box) -> Self { + pub fn new>(mat: Arc, shape: T) -> Self { Object { mat, - shape, + shape: shape.into(), } } } @@ -29,7 +30,7 @@ impl Hittable for Object { fn intersect(&self, ray: &Ray) -> Option { if let Some(mut inter) = self.shape.intersect(ray) { inter.add_material_if_none(self.mat.as_ref()); - Some(inter) + Some(inter) } else { None } -- cgit v1.2.3