pub fn cast_ray<S: QueryResultsStorage>(&self, opts: RayCastOptions, query_buffer: &mut S) {
        let time = instant::Instant::now();

        let mut query = self.query.borrow_mut();

        // TODO: Ideally this must be called once per frame, but it seems to be impossible because
        // a body can be deleted during the consecutive calls of this method which will most
        // likely end up in panic because of invalid handle stored in internal acceleration
        // structure. This could be fixed by delaying deleting of bodies/collider to the end
        // of the frame.
        query.update(&self.bodies, &self.colliders);

        query_buffer.clear();
        let ray = rapier3d::geometry::Ray::new(
            Point3::from(opts.ray.origin),
            opts.ray
                .dir
                .try_normalize(std::f32::EPSILON)
                .unwrap_or_default(),
        );
        query.intersections_with_ray(
            &self.colliders,
            &ray,
            opts.max_len,
            true,
            opts.groups,
            None, // TODO
            |handle, _, intersection| {
                query_buffer.push(Intersection {
                    collider: self.collider_handle_map.key_of(&handle).cloned().unwrap(),
                    normal: intersection.normal,
                    position: ray.point_at(intersection.toi),
                    feature: intersection.feature,
                    toi: intersection.toi,
                })
            },
        );
        if opts.sort_results {
            query_buffer.sort_intersections_by(|a, b| {
                if a.toi > b.toi {
                    Ordering::Greater
                } else if a.toi < b.toi {
                    Ordering::Less
                } else {
                    Ordering::Equal
                }
            })
        }

        self.performance_statistics.total_ray_cast_time.set(
            self.performance_statistics.total_ray_cast_time.get()
                + (instant::Instant::now() - time),
        );
    }
/// Casts a ray with given options.
Casts a ray with given options.
Casts a ray with given options .
pub fn cast_ray<S: QueryResultsStorage>(&self, opts: RayCastOptions, query_buffer: &mut S) {
        let time = instant::Instant::now();
        let mut query = self.query.borrow_mut();
        // TODO: Ideally this must be called once per frame, but it seems to be impossible because
        // a body can be deleted during the consecutive calls of this method which will most
        // likely end up in panic because of invalid handle stored in internal acceleration
        // structure. This could be fixed by delaying deleting of bodies/collider to the end
        // of the frame.
        query.update(&self.bodies, &self.colliders);
        query_buffer.clear();
        let ray = rapier3d::geometry::Ray::new(
            Point3::from(opts.ray.origin),
            opts.ray
                .dir
                .try_normalize(std::f32::EPSILON)
                .unwrap_or_default(),
        );
        query.intersections_with_ray(
            &self.colliders,
            &ray,
            opts.max_len,
            true,
            opts.groups,
            None, // TODO
            |handle, _, intersection| {
                query_buffer.push(Intersection {
                    collider: self.collider_handle_map.key_of(&handle).cloned().unwrap(),
                    normal: intersection.normal,
                    position: ray.point_at(intersection.toi),
                    feature: intersection.feature,
                    toi: intersection.toi,
                })
            },
        );
        if opts.sort_results {
            query_buffer.sort_intersections_by(|a, b| {
                if a.toi > b.toi {
                    Ordering::Greater
                } else if a.toi < b.toi {
                    Ordering::Less
                } else {
                    Ordering::Equal
                }
            })
        }
        self.performance_statistics.total_ray_cast_time.set(
            self.performance_statistics.total_ray_cast_time.get()
                + (instant::Instant::now() - time),
        );
    }
pub fn cast_ray < S : QueryResultsStorage > ( & self , opts : RayCastOptions , query_buffer : & mut S ) { let time = instant :: Instant :: now ( ) ; let mut query = self . query . borrow_mut ( ) ; // TODO: Ideally this must be called once per frame, but it seems to be impossible because // a body can be deleted during the consecutive calls of this method which will most // likely end up in panic because of invalid handle stored in internal acceleration // structure. This could be fixed by delaying deleting of bodies/collider to the end // of the frame. query . update ( & self . bodies , & self . colliders ) ; query_buffer . clear ( ) ; let ray = rapier3d :: geometry :: Ray :: new ( Point3 :: from ( opts . ray . origin ) , opts . ray . dir . try_normalize ( std :: f32 :: EPSILON ) . unwrap_or_default ( ) , ) ; query . intersections_with_ray ( & self . colliders , & ray , opts . max_len , true , opts . groups , None , // TODO | handle , _ , intersection | { query_buffer . push ( Intersection { collider : self . collider_handle_map . key_of ( & handle ) . cloned ( ) . unwrap ( ) , normal : intersection . normal , position : ray . point_at ( intersection . toi ) , feature : intersection . feature , toi : intersection . toi , } ) } , ) ; if opts . sort_results { query_buffer . sort_intersections_by ( | a , b | { if a . toi > b . toi { Ordering :: Greater } else if a . toi < b . toi { Ordering :: Less } else { Ordering :: Equal } } ) } self . performance_statistics . total_ray_cast_time . set ( self . performance_statistics . total_ray_cast_time . get ( ) + ( instant :: Instant :: now ( ) - time ) , ) ; }
Casts a ray with given options.
Casts a ray with given options .
&self
opts
RayCastOptions
query_buffer
&mut S