From 351d9132c0b2c54dfa9f50bfe328d25ccf059cea Mon Sep 17 00:00:00 2001 From: Julian T Date: Mon, 2 Aug 2021 15:21:59 +0200 Subject: Move back to dynamic dispatch for object.shape This will allow more general nesting, with the performance penalty of dynamic dispatching. This is implemented with the DynHittable for convenience. --- src/world/scene.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/world/scene.rs') diff --git a/src/world/scene.rs b/src/world/scene.rs index 87bec1f..8954050 100644 --- a/src/world/scene.rs +++ b/src/world/scene.rs @@ -1,5 +1,7 @@ use crate::core::{Bound3f, Ray}; +use std::iter::IntoIterator; + use super::{Object, container, Hittable, Intersection}; type Container = container::HittableList; @@ -17,8 +19,11 @@ impl Scene { self.content.add(obj); } - pub fn add_objects(&mut self, objs: Vec) { - for obj in objs { + pub fn add_objects(&mut self, objs: T) + where + T: IntoIterator, + { + for obj in objs.into_iter() { self.add_object(obj); } } -- cgit v1.2.3