use super::raycasting::{IntersectionInfo, Ray}; use super::scene::Scene; use crate::Real; pub struct Sampler<'a, T: Real> { pub scene: &'a Scene, } impl<'a, T: Real> Sampler<'a, T> { pub fn sample(&self, ray: &Ray) -> Option> { self.scene .objects .iter() .flat_map(|object| object.intersect(&ray)) .min_by( |a, b| match PartialOrd::partial_cmp(&a.distance, &b.distance) { None => std::cmp::Ordering::Less, Some(ordering) => ordering, }, ) } }