Struct rapier3d::pipeline::QueryPipeline
source · [−]pub struct QueryPipeline { /* private fields */ }
Expand description
A pipeline for performing queries on all the colliders of a scene.
Implementations
sourceimpl QueryPipeline
impl QueryPipeline
sourcepub fn with_query_dispatcher<D>(d: D) -> Self where
D: 'static + QueryDispatcher,
pub fn with_query_dispatcher<D>(d: D) -> Self where
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(
&mut self,
islands: &IslandManager,
bodies: &RigidBodySet,
colliders: &ColliderSet
)
pub fn update(
&mut self,
islands: &IslandManager,
bodies: &RigidBodySet,
colliders: &ColliderSet
)
Update the acceleration structure on the query pipeline.
sourcepub fn update_with_mode(
&mut self,
islands: &IslandManager,
bodies: &RigidBodySet,
colliders: &ColliderSet,
mode: QueryPipelineMode
)
pub fn update_with_mode(
&mut self,
islands: &IslandManager,
bodies: &RigidBodySet,
colliders: &ColliderSet,
mode: QueryPipelineMode
)
Update the acceleration structure on the query pipeline.
sourcepub fn cast_ray(
&self,
colliders: &ColliderSet,
ray: &Ray,
max_toi: Real,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, Real)>
pub fn cast_ray(
&self,
colliders: &ColliderSet,
ray: &Ray,
max_toi: Real,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, Real)>
Find the closest intersection between a ray and a set of collider.
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.query_groups
: the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
: a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
sourcepub fn cast_ray_and_get_normal(
&self,
colliders: &ColliderSet,
ray: &Ray,
max_toi: Real,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, RayIntersection)>
pub fn cast_ray_and_get_normal(
&self,
colliders: &ColliderSet,
ray: &Ray,
max_toi: Real,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, RayIntersection)>
Find the closest intersection between a ray and a set of collider.
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.query_groups
: the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
: a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
sourcepub fn intersections_with_ray<'a>(
&self,
colliders: &'a ColliderSet,
ray: &Ray,
max_toi: Real,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>,
callback: impl FnMut(ColliderHandle, RayIntersection) -> bool
)
pub fn intersections_with_ray<'a>(
&self,
colliders: &'a ColliderSet,
ray: &Ray,
max_toi: Real,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>,
callback: impl FnMut(ColliderHandle, RayIntersection) -> bool
)
Find the all intersections between a ray and a set of collider 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.query_groups
: the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
: a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.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,
colliders: &ColliderSet,
shape_pos: &Isometry<Real>,
shape: &dyn Shape,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<ColliderHandle>
pub fn intersection_with_shape(
&self,
colliders: &ColliderSet,
shape_pos: &Isometry<Real>,
shape: &dyn Shape,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> 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.query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
sourcepub fn project_point(
&self,
colliders: &ColliderSet,
point: &Point<Real>,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, PointProjection)>
pub fn project_point(
&self,
colliders: &ColliderSet,
point: &Point<Real>,
solid: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> 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).query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
sourcepub fn intersections_with_point<'a>(
&self,
colliders: &'a ColliderSet,
point: &Point<Real>,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>,
callback: impl FnMut(ColliderHandle) -> bool
)
pub fn intersections_with_point<'a>(
&self,
colliders: &'a ColliderSet,
point: &Point<Real>,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>,
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.query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.callback
- A function called with each collider with a shape containing thepoint
.
sourcepub fn project_point_and_get_feature(
&self,
colliders: &ColliderSet,
point: &Point<Real>,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, PointProjection, FeatureId)>
pub fn project_point_and_get_feature(
&self,
colliders: &ColliderSet,
point: &Point<Real>,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> 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).query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
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
)
Finds all handles of all the colliders with an AABB intersecting the given AABB.
sourcepub fn cast_shape<'a>(
&self,
colliders: &'a ColliderSet,
shape_pos: &Isometry<Real>,
shape_vel: &Vector<Real>,
shape: &dyn Shape,
max_toi: Real,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, TOI)>
pub fn cast_shape<'a>(
&self,
colliders: &'a ColliderSet,
shape_pos: &Isometry<Real>,
shape_vel: &Vector<Real>,
shape: &dyn Shape,
max_toi: Real,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, TOI)>
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 toshapeVel.norm() * maxToi
.query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
sourcepub fn nonlinear_cast_shape(
&self,
colliders: &ColliderSet,
shape_motion: &NonlinearRigidMotion,
shape: &dyn Shape,
start_time: Real,
end_time: Real,
stop_at_penetration: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, TOI)>
pub fn nonlinear_cast_shape(
&self,
colliders: &ColliderSet,
shape_motion: &NonlinearRigidMotion,
shape: &dyn Shape,
start_time: Real,
end_time: Real,
stop_at_penetration: bool,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>
) -> Option<(ColliderHandle, TOI)>
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 wrt. 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.query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.
sourcepub fn intersections_with_shape<'a>(
&self,
colliders: &'a ColliderSet,
shape_pos: &Isometry<Real>,
shape: &dyn Shape,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>,
callback: impl FnMut(ColliderHandle) -> bool
)
pub fn intersections_with_shape<'a>(
&self,
colliders: &'a ColliderSet,
shape_pos: &Isometry<Real>,
shape: &dyn Shape,
query_groups: InteractionGroups,
filter: Option<&dyn Fn(ColliderHandle) -> bool>,
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.query_groups
- the interaction groups which will be tested against the collider’scontact_group
to determine if it should be taken into account by this query.filter
- a more fine-grained filter. A collider is taken into account by this query if itscontact_group
is compatible with thequery_groups
, and if thisfilter
is eitherNone
or returnstrue
.callback
- A function called with the handles of each collider intersecting theshape
.
Trait Implementations
sourceimpl Clone for QueryPipeline
impl Clone for QueryPipeline
sourcefn clone(&self) -> QueryPipeline
fn clone(&self) -> QueryPipeline
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for QueryPipeline
impl Send for QueryPipeline
impl Sync for QueryPipeline
impl Unpin for QueryPipeline
impl !UnwindSafe for QueryPipeline
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert 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
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcefn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcefn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcefn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more