pub fn intersections<'a>(
        &'a self,
        ray: &'a Ray,
    ) -> (Option<Intersection>, Vec<Intersection<'a>>) {
        let mut all_intersections = BTreeSet::new();
        let mut hit: Option<Intersection> = None;

        for object in self.objects.iter() {
            let object_intersections = object.intersections(ray);

            // Object intersections are not guaranteed to be ordered, so we need to go through each.
            //
            for intersection in object_intersections {
                if intersection.t >= 0.0 {
                    // Note that there is a case where we don't need to clone, but it's not worth bothering.
                    //
                    all_intersections.insert(intersection.clone());

                    match hit {
                        None => {
                            hit.replace(intersection);
                        }
                        Some(Intersection { t, .. }) => {
                            if intersection.t < t {
                                hit.replace(intersection);
                            }
                        }
                    }
                }
            }
        }

        let all_intersections = all_intersections.into_iter().collect::<Vec<_>>();

        (hit, all_intersections)
    }
// Returns the hit, and all the (sorted) intersections.
//
// Minor optimizations could be applied, but they're possibly not meaningful.
//
// See Shape#intersections() for an interesting optimization.
//
Returns the hit, and all the (sorted) intersections.
Minor optimizations could be applied, but they're possibly not meaningful.

See Shape#intersections() for an interesting optimization.
Returns the hit and all the ( sorted ) intersections . Minor optimizations could be applied but they ' re possibly not meaningful . See Shape#intersections () for an interesting optimization .
pub fn intersections<'a>(
        &'a self,
        ray: &'a Ray,
    ) -> (Option<Intersection>, Vec<Intersection<'a>>) {
        let mut all_intersections = BTreeSet::new();
        let mut hit: Option<Intersection> = None;
        for object in self.objects.iter() {
            let object_intersections = object.intersections(ray);
            // Object intersections are not guaranteed to be ordered, so we need to go through each.
            //
            for intersection in object_intersections {
                if intersection.t >= 0.0 {
                    // Note that there is a case where we don't need to clone, but it's not worth bothering.
                    //
                    all_intersections.insert(intersection.clone());
                    match hit {
                        None => {
                            hit.replace(intersection);
                        }
                        Some(Intersection { t, .. }) => {
                            if intersection.t < t {
                                hit.replace(intersection);
                            }
                        }
                    }
                }
            }
        }
        let all_intersections = all_intersections.into_iter().collect::<Vec<_>>();
        (hit, all_intersections)
    }
pub fn intersections < ' a > ( & ' a self , ray : & ' a Ray , ) -> ( Option < Intersection > , Vec < Intersection < ' a > > ) { let mut all_intersections = BTreeSet :: new ( ) ; let mut hit : Option < Intersection > = None ; for object in self . objects . iter ( ) { let object_intersections = object . intersections ( ray ) ; // Object intersections are not guaranteed to be ordered, so we need to go through each. // for intersection in object_intersections { if intersection . t >= 0.0 { // Note that there is a case where we don't need to clone, but it's not worth bothering. // all_intersections . insert ( intersection . clone ( ) ) ; match hit { None => { hit . replace ( intersection ) ; } Some ( Intersection { t , .. } ) => { if intersection . t < t { hit . replace ( intersection ) ; } } } } } } let all_intersections = all_intersections . into_iter ( ) . collect :: < Vec < _ > > ( ) ; ( hit , all_intersections ) }
Returns the hit, and all the (sorted) intersections.
Returns the hit and all the ( sorted ) intersections .
&'a self
ray
&'a Ray