use crate::{ Shape, geometry::{Hit, Hittable, Ray}, }; #[derive(Debug, Clone)] pub struct Scene(Vec); impl Scene { pub fn new(objects: Vec) -> Self { Self(objects) } pub fn intersect(&self, r: Ray) -> Option { let mut hit: Option = None; for obj in &self.0 { let t_max = hit.as_ref().map(|h| h.t).unwrap_or(f32::INFINITY); if let Some(h) = obj.intersect(&r, t_max) { hit = Some(h) } } hit } }