diff options
author | Julian T <julian@jtle.dk> | 2021-08-02 15:21:59 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-08-02 15:21:59 +0200 |
commit | 351d9132c0b2c54dfa9f50bfe328d25ccf059cea (patch) | |
tree | c2b9401c6484f1ba5354de4ea5dc6f58b2a214cd /src/world/scene.rs | |
parent | 13e018067631a7401df5b232f95f3d1f7a0cd75c (diff) |
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.
Diffstat (limited to 'src/world/scene.rs')
-rw-r--r-- | src/world/scene.rs | 9 |
1 files changed, 7 insertions, 2 deletions
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<Object>) { - for obj in objs { + pub fn add_objects<T>(&mut self, objs: T) + where + T: IntoIterator<Item = Object>, + { + for obj in objs.into_iter() { self.add_object(obj); } } |