/// Returns object, point, and normal of the closest intersection of ray with objects, or None
Returns object, point, and normal of the closest intersection of ray with objects, or None
Returns object point and normal of the closest intersection of ray with objects or None
fn intersect_objects<'a>(ray: &Ray, t_min: f32, t_max: f32, objects: &'a Vec<&'a dyn Intersectable>) -> Option<(&'a dyn Intersectable, Point, Vector, Vector)> {
    let mut closest = None;
    let mut closest_distance_squared = std::f32::MAX;
    for obj in objects {
        if let Some((point, normal, uvw)) = obj.intersect(ray, t_min, t_max) {
            let distance_squared = (point - ray.point).magnitude2();
            if distance_squared < closest_distance_squared {
                closest = Some((*obj, point, normal, uvw));
                closest_distance_squared = distance_squared;
            }
        }
    }
    closest
}
fn intersect_objects < ' a > ( ray : & Ray , t_min : f32 , t_max : f32 , objects : & ' a Vec < & ' a dyn Intersectable > ) -> Option < ( & ' a dyn Intersectable , Point , Vector , Vector ) > { let mut closest = None ; let mut closest_distance_squared = std :: f32 :: MAX ; for obj in objects { if let Some ( ( point , normal , uvw ) ) = obj . intersect ( ray , t_min , t_max ) { let distance_squared = ( point - ray . point ) . magnitude2 ( ) ; if distance_squared < closest_distance_squared { closest = Some ( ( * obj , point , normal , uvw ) ) ; closest_distance_squared = distance_squared ; } } } closest }
Returns object, point, and normal of the closest intersection of ray with objects, or None
Returns object point and normal of the closest intersection of ray with objects or None
ray
&Ray
t_min
f32
t_max
f32
objects
&'a Vec<&'a dyn Intersectable>