use super::{Intersection, Hittable}; use crate::core::Ray; type Shape = Box; pub struct Scene { shps: Vec, } impl Scene { pub fn new() -> Self { Self { shps: Vec::new(), } } pub fn add_shape(&mut self, shp: Shape) { self.shps.push(shp); } pub fn add_shapes(&mut self, shps: Vec) { for shp in shps { self.add_shape(shp); } } pub fn intersect(&self, ray: &Ray) -> Option { for shp in self.shps.iter() { if let Some(i) = shp.intersect(&ray) { return Some(i) } } None } }