pub fn intersections_with_ray<'a>(
        &self,
        colliders: &'a ColliderSet,
        ray: &Ray,
        max_toi: Real,
        solid: bool,
        groups: InteractionGroups,
        mut callback: impl FnMut(ColliderHandle, &'a Collider, RayIntersection) -> bool,
    ) {
        let mut leaf_callback = &mut |handle: &ColliderHandle| {
            if let Some(coll) = colliders.get(*handle) {
                if coll.collision_groups.test(groups) {
                    if let Some(hit) =
                        coll.shape()
                            .cast_ray_and_get_normal(coll.position(), ray, max_toi, solid)
                    {
                        return callback(*handle, coll, hit);
                    }
                }
            }

            true
        };

        let mut visitor = RayIntersectionsVisitor::new(ray, max_toi, &mut leaf_callback);
        self.quadtree.traverse_depth_first(&mut visitor);
    }
/// Find the all intersections between a ray and a set of collider and passes them to a callback.
///
/// # Parameters
/// - `position`: the position of this shape.
/// - `ray`: the ray to cast.
/// - `max_toi`: the maximum time-of-impact that can be reported by this cast. This effectively
///   limits the length of the ray to `ray.dir.norm() * max_toi`. Use `Real::MAX` for an unbounded ray.
/// - `callback`: function executed on each collider for which a ray intersection has been found.
///   There is no guarantees on the order the results will be yielded. If this callback returns `false`,
///   this method will exit early, ignore any further raycast.
Find the all intersections between a ray and a set of collider and passes them to a callback.
Find the all intersections between a ray and a set of collider and passes them to a callback .
pub fn intersections_with_ray<'a>(
        &self,
        colliders: &'a ColliderSet,
        ray: &Ray,
        max_toi: Real,
        solid: bool,
        groups: InteractionGroups,
        mut callback: impl FnMut(ColliderHandle, &'a Collider, RayIntersection) -> bool,
    ) {
        let mut leaf_callback = &mut |handle: &ColliderHandle| {
            if let Some(coll) = colliders.get(*handle) {
                if coll.collision_groups.test(groups) {
                    if let Some(hit) =
                        coll.shape()
                            .cast_ray_and_get_normal(coll.position(), ray, max_toi, solid)
                    {
                        return callback(*handle, coll, hit);
                    }
                }
            }
            true
        };
        let mut visitor = RayIntersectionsVisitor::new(ray, max_toi, &mut leaf_callback);
        self.quadtree.traverse_depth_first(&mut visitor);
    }
pub fn intersections_with_ray < ' a > ( & self , colliders : & ' a ColliderSet , ray : & Ray , max_toi : Real , solid : bool , groups : InteractionGroups , mut callback : impl FnMut ( ColliderHandle , & ' a Collider , RayIntersection ) -> bool , ) { let mut leaf_callback = & mut | handle : & ColliderHandle | { if let Some ( coll ) = colliders . get ( * handle ) { if coll . collision_groups . test ( groups ) { if let Some ( hit ) = coll . shape ( ) . cast_ray_and_get_normal ( coll . position ( ) , ray , max_toi , solid ) { return callback ( * handle , coll , hit ) ; } } } true } ; let mut visitor = RayIntersectionsVisitor :: new ( ray , max_toi , & mut leaf_callback ) ; self . quadtree . traverse_depth_first ( & mut visitor ) ; }
Find the all intersections between a ray and a set of collider and passes them to a callback.
Find the all intersections between a ray and a set of collider and passes them to a callback .
&self
colliders
&'a ColliderSet
ray
&Ray
the ray to cast.
the ray to cast .
max_toi
Real
the maximum time-of-impact that can be reported by this cast. This effectively
limits the length of the ray to `ray.dir.norm() * max_toi`. Use `Real::MAX` for an unbounded ray.
the maximum time - of - impact that can be reported by this cast . This effectively limits the length of the ray to ` ray . dir . norm () * max_toi ` . Use ` Real :: MAX ` for an unbounded ray .
solid
bool
groups
InteractionGroups
callback
impl FnMut(ColliderHandle, &'a Collider, RayIntersection) -> bool
function executed on each collider for which a ray intersection has been found.
There is no guarantees on the order the results will be yielded. If this callback returns `false`,
this method will exit early, ignore any further raycast.
function executed on each collider for which a ray intersection has been found . There is no guarantees on the order the results will be yielded . If this callback returns ` false ` this method will exit early ignore any further raycast .
position
the position of this shape.
the position of this shape .