pub struct QueryPipeline { /* private fields */ }
Expand description
A pipeline for performing queries on all the colliders of a scene.
Implementations§
Source§impl QueryPipeline
impl QueryPipeline
Sourcepub fn with_query_dispatcher<D>(d: D) -> Selfwhere
D: 'static + QueryDispatcher,
pub fn with_query_dispatcher<D>(d: D) -> Selfwhere
D: 'static + QueryDispatcher,
Initializes an empty query pipeline with a custom QueryDispatcher
.
Use this constructor in order to use a custom QueryDispatcher
that is
aware of your own user-defined shapes.
Sourcepub fn query_dispatcher(&self) -> &dyn QueryDispatcher
pub fn query_dispatcher(&self) -> &dyn QueryDispatcher
The query dispatcher used by this query pipeline for running scene queries.
Sourcepub fn update_incremental(
&mut self,
colliders: &ColliderSet,
modified_colliders: &[ColliderHandle],
removed_colliders: &[ColliderHandle],
refit_and_rebalance: bool,
)
pub fn update_incremental( &mut self, colliders: &ColliderSet, modified_colliders: &[ColliderHandle], removed_colliders: &[ColliderHandle], refit_and_rebalance: bool, )
Update the query pipeline incrementally, avoiding a complete rebuild of its internal data-structure.
Sourcepub fn update(&mut self, colliders: &ColliderSet)
pub fn update(&mut self, colliders: &ColliderSet)
Update the acceleration structure on the query pipeline.
Uses generators::CurrentAabb
to update.
Sourcepub fn update_with_generator(
&mut self,
mode: impl QbvhDataGenerator<ColliderHandle>,
)
pub fn update_with_generator( &mut self, mode: impl QbvhDataGenerator<ColliderHandle>, )
Update the acceleration structure on the query pipeline using a custom collider bounding volume generator.
See generators
for available generators.
Sourcepub fn cast_ray(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
ray: &Ray,
max_toi: f32,
solid: bool,
filter: QueryFilter<'_>,
) -> Option<(ColliderHandle, f32)>
pub fn cast_ray( &self, bodies: &RigidBodySet, colliders: &ColliderSet, ray: &Ray, max_toi: f32, solid: bool, filter: QueryFilter<'_>, ) -> Option<(ColliderHandle, f32)>
Find the closest intersection between a ray and a set of colliders.
§Parameters
colliders
- The set of colliders taking part in this pipeline.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 toray.dir.norm() * max_toi
. UseReal::MAX
for an unbounded ray.solid
: if this istrue
an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If thisfalse
then the ray will hit the shape’s boundary even if its starts inside of it.filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn cast_ray_and_get_normal(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
ray: &Ray,
max_toi: f32,
solid: bool,
filter: QueryFilter<'_>,
) -> Option<(ColliderHandle, RayIntersection)>
pub fn cast_ray_and_get_normal( &self, bodies: &RigidBodySet, colliders: &ColliderSet, ray: &Ray, max_toi: f32, solid: bool, filter: QueryFilter<'_>, ) -> Option<(ColliderHandle, RayIntersection)>
Find the closest intersection between a ray and a set of colliders.
§Parameters
colliders
- The set of colliders taking part in this pipeline.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 toray.dir.norm() * max_toi
. UseReal::MAX
for an unbounded ray.solid
: if this istrue
an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If thisfalse
then the ray will hit the shape’s boundary even if its starts inside of it.filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn intersections_with_ray<'a>(
&self,
bodies: &'a RigidBodySet,
colliders: &'a ColliderSet,
ray: &Ray,
max_toi: f32,
solid: bool,
filter: QueryFilter<'_>,
callback: impl FnMut(ColliderHandle, RayIntersection) -> bool,
)
pub fn intersections_with_ray<'a>( &self, bodies: &'a RigidBodySet, colliders: &'a ColliderSet, ray: &Ray, max_toi: f32, solid: bool, filter: QueryFilter<'_>, callback: impl FnMut(ColliderHandle, RayIntersection) -> bool, )
Find the all intersections between a ray and a set of colliders and passes them to a callback.
§Parameters
colliders
- The set of colliders taking part in this pipeline.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 toray.dir.norm() * max_toi
. UseReal::MAX
for an unbounded ray.solid
: if this istrue
an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If thisfalse
then the ray will hit the shape’s boundary even if its starts inside of it.filter
: set of rules used to determine which collider is taken into account by this scene query.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 returnsfalse
, this method will exit early, ignore any further raycast.
Sourcepub fn intersection_with_shape(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
shape_pos: &Isometry<f32>,
shape: &dyn Shape,
filter: QueryFilter<'_>,
) -> Option<ColliderHandle>
pub fn intersection_with_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_pos: &Isometry<f32>, shape: &dyn Shape, filter: QueryFilter<'_>, ) -> Option<ColliderHandle>
Gets the handle of up to one collider intersecting the given shape.
§Parameters
colliders
- The set of colliders taking part in this pipeline.shape_pos
- The position of the shape used for the intersection test.shape
- The shape used for the intersection test.filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn project_point(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
point: &Point<f32>,
solid: bool,
filter: QueryFilter<'_>,
) -> Option<(ColliderHandle, PointProjection)>
pub fn project_point( &self, bodies: &RigidBodySet, colliders: &ColliderSet, point: &Point<f32>, solid: bool, filter: QueryFilter<'_>, ) -> Option<(ColliderHandle, PointProjection)>
Find the projection of a point on the closest collider.
§Parameters
colliders
- The set of colliders taking part in this pipeline.point
- The point to project.solid
- If this is set totrue
then the collider shapes are considered to be plain (if the point is located inside of a plain shape, its projection is the point itself). If it is set tofalse
the collider shapes are considered to be hollow (if the point is located inside of an hollow shape, it is projected on the shape’s boundary).filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn intersections_with_point(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
point: &Point<f32>,
filter: QueryFilter<'_>,
callback: impl FnMut(ColliderHandle) -> bool,
)
pub fn intersections_with_point( &self, bodies: &RigidBodySet, colliders: &ColliderSet, point: &Point<f32>, filter: QueryFilter<'_>, callback: impl FnMut(ColliderHandle) -> bool, )
Find all the colliders containing the given point.
§Parameters
colliders
- The set of colliders taking part in this pipeline.point
- The point used for the containment test.filter
: set of rules used to determine which collider is taken into account by this scene query.callback
- A function called with each collider with a shape containing thepoint
.
Sourcepub fn project_point_and_get_feature(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
point: &Point<f32>,
filter: QueryFilter<'_>,
) -> Option<(ColliderHandle, PointProjection, FeatureId)>
pub fn project_point_and_get_feature( &self, bodies: &RigidBodySet, colliders: &ColliderSet, point: &Point<f32>, filter: QueryFilter<'_>, ) -> Option<(ColliderHandle, PointProjection, FeatureId)>
Find the projection of a point on the closest collider.
The results include the ID of the feature hit by the point.
§Parameters
colliders
- The set of colliders taking part in this pipeline.point
- The point to project.solid
- If this is set totrue
then the collider shapes are considered to be plain (if the point is located inside of a plain shape, its projection is the point itself). If it is set tofalse
the collider shapes are considered to be hollow (if the point is located inside of an hollow shape, it is projected on the shape’s boundary).filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn colliders_with_aabb_intersecting_aabb(
&self,
aabb: &Aabb,
callback: impl FnMut(&ColliderHandle) -> bool,
)
pub fn colliders_with_aabb_intersecting_aabb( &self, aabb: &Aabb, callback: impl FnMut(&ColliderHandle) -> bool, )
Sourcepub fn cast_shape(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
shape_pos: &Isometry<f32>,
shape_vel: &Vector<f32>,
shape: &dyn Shape,
options: ShapeCastOptions,
filter: QueryFilter<'_>,
) -> Option<(ColliderHandle, ShapeCastHit)>
pub fn cast_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_pos: &Isometry<f32>, shape_vel: &Vector<f32>, shape: &dyn Shape, options: ShapeCastOptions, filter: QueryFilter<'_>, ) -> Option<(ColliderHandle, ShapeCastHit)>
Casts a shape at a constant linear velocity and retrieve the first collider it hits.
This is similar to ray-casting except that we are casting a whole shape instead of just a
point (the ray origin). In the resulting TOI
, witness and normal 1 refer to the world
collider, and are in world space.
§Parameters
colliders
- The set of colliders taking part in this pipeline.shape_pos
- The initial position of the shape to cast.shape_vel
- The constant velocity of the shape to cast (i.e. the cast direction).shape
- The shape to cast.max_toi
- The maximum time-of-impact that can be reported by this cast. This effectively limits the distance traveled by the shape toshape_vel.norm() * maxToi
.stop_at_penetration
- If set tofalse
, the linear shape-cast won’t immediately stop if the shape is penetrating another shape at its starting point and its trajectory is such that it’s on a path to exit that penetration state.filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn nonlinear_cast_shape(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
shape_motion: &NonlinearRigidMotion,
shape: &dyn Shape,
start_time: f32,
end_time: f32,
stop_at_penetration: bool,
filter: QueryFilter<'_>,
) -> Option<(ColliderHandle, ShapeCastHit)>
pub fn nonlinear_cast_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_motion: &NonlinearRigidMotion, shape: &dyn Shape, start_time: f32, end_time: f32, stop_at_penetration: bool, filter: QueryFilter<'_>, ) -> Option<(ColliderHandle, ShapeCastHit)>
Casts a shape with an arbitrary continuous motion and retrieve the first collider it hits.
In the resulting TOI
, witness and normal 1 refer to the world collider, and are in world
space.
§Parameters
colliders
- The set of colliders taking part in this pipeline.shape_motion
- The motion of the shape.shape
- The shape to cast.start_time
- The starting time of the interval where the motion takes place.end_time
- The end time of the interval where the motion takes place.stop_at_penetration
- If the casted shape starts in a penetration state with any collider, two results are possible. Ifstop_at_penetration
istrue
then, the result will have atoi
equal tostart_time
. Ifstop_at_penetration
isfalse
then the nonlinear shape-casting will see if further motion with respect to the penetration normal would result in tunnelling. If it does not (i.e. we have a separating velocity along that normal) then the nonlinear shape-casting will attempt to find another impact, at a time> start_time
that could result in tunnelling.filter
: set of rules used to determine which collider is taken into account by this scene query.
Sourcepub fn intersections_with_shape(
&self,
bodies: &RigidBodySet,
colliders: &ColliderSet,
shape_pos: &Isometry<f32>,
shape: &dyn Shape,
filter: QueryFilter<'_>,
callback: impl FnMut(ColliderHandle) -> bool,
)
pub fn intersections_with_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_pos: &Isometry<f32>, shape: &dyn Shape, filter: QueryFilter<'_>, callback: impl FnMut(ColliderHandle) -> bool, )
Retrieve all the colliders intersecting the given shape.
§Parameters
colliders
- The set of colliders taking part in this pipeline.shapePos
- The position of the shape to test.shapeRot
- The orientation of the shape to test.shape
- The shape to test.filter
: set of rules used to determine which collider is taken into account by this scene query.callback
- A function called with the handles of each collider intersecting theshape
.
Trait Implementations§
Source§impl Clone for QueryPipeline
impl Clone for QueryPipeline
Source§fn clone(&self) -> QueryPipeline
fn clone(&self) -> QueryPipeline
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for QueryPipeline
impl !RefUnwindSafe for QueryPipeline
impl Send for QueryPipeline
impl Sync for QueryPipeline
impl Unpin for QueryPipeline
impl !UnwindSafe for QueryPipeline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.