pub struct RapierQueryPipeline<'a> {
pub query_pipeline: QueryPipeline<'a>,
}Expand description
Wrapper around QueryPipeline to provide bevy friendly methods.
This wrapper is designed to be short lived, made whenever necessary.
See RapierQueryPipeline::new_scoped to create one.
Fields§
§query_pipeline: QueryPipeline<'a>The query pipeline, which performs scene queries (ray-casting, point projection, etc.)
Implementations§
Source§impl<'a> RapierQueryPipeline<'a>
impl<'a> RapierQueryPipeline<'a>
Sourcepub fn new_scoped<T>(
broad_phase: &DefaultBroadPhase,
colliders: &RapierContextColliders,
rigid_bodies: &RapierRigidBodySet,
filter: &QueryFilter<'_>,
dispatcher: &dyn QueryDispatcher,
scoped_fn: impl FnOnce(RapierQueryPipeline<'_>) -> T,
) -> T
pub fn new_scoped<T>( broad_phase: &DefaultBroadPhase, colliders: &RapierContextColliders, rigid_bodies: &RapierRigidBodySet, filter: &QueryFilter<'_>, dispatcher: &dyn QueryDispatcher, scoped_fn: impl FnOnce(RapierQueryPipeline<'_>) -> T, ) -> T
Creates a temporary RapierQueryPipeline and passes it as a parameter to scoped_fn.
Sourcepub fn collider_entity(&self, collider_handle: ColliderHandle) -> Entity
pub fn collider_entity(&self, collider_handle: ColliderHandle) -> Entity
Retrieves the Entity for a given collider handle.
Sourcepub fn cast_ray(
&self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: f32,
solid: bool,
) -> Option<(Entity, f32)>
pub fn cast_ray( &self, ray_origin: Vect, ray_dir: Vect, max_toi: f32, solid: bool, ) -> Option<(Entity, f32)>
Find the closest intersection between a ray and a set of collider.
§Parameters
ray_origin: the starting point of the ray to cast.ray_dir: the direction of 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::MAXfor an unbounded ray.solid: if this istruean impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If thisfalsethen the ray will hit the shape’s boundary even if its starts inside of it.
Sourcepub fn cast_ray_and_get_normal(
&self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: f32,
solid: bool,
) -> Option<(Entity, RayIntersection)>
pub fn cast_ray_and_get_normal( &self, ray_origin: Vect, ray_dir: Vect, max_toi: f32, solid: bool, ) -> Option<(Entity, RayIntersection)>
Find the closest intersection between a ray and a set of collider.
§Parameters
ray_origin: the starting point of the ray to cast.ray_dir: the direction of 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::MAXfor an unbounded ray.solid: if this istruean impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If thisfalsethen the ray will hit the shape’s boundary even if its starts inside of it.
Sourcepub fn intersect_ray(
&'a self,
ray_origin: Vect,
ray_dir: Vect,
max_toi: f32,
solid: bool,
) -> impl Iterator<Item = (Entity, &'a RapierCollider, RayIntersection)> + 'a
pub fn intersect_ray( &'a self, ray_origin: Vect, ray_dir: Vect, max_toi: f32, solid: bool, ) -> impl Iterator<Item = (Entity, &'a RapierCollider, RayIntersection)> + 'a
Iterates through all the colliders intersecting a given ray, alongside their Rapier collider.
§Parameters
ray_origin: the starting point of the ray to cast.ray_dir: the direction of 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::MAXfor an unbounded ray.solid: if this istruean impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If thisfalsethen the ray will hit the shape’s boundary even if its starts inside of it.
Sourcepub fn intersect_shape(
&'a self,
shape_pos: Vect,
shape_rot: Rot,
shape: &'a (impl AsShape + ?Sized + 'a),
) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a
pub fn intersect_shape( &'a self, shape_pos: Vect, shape_rot: Rot, shape: &'a (impl AsShape + ?Sized + 'a), ) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a
Retrieve all the colliders intersecting the given shape, alongside their Rapier collider.
§Parameters
shape_pos- The position of the shape used for the intersection test.shape_rot- The orientation of the shape used for the intersection test.shape- The shape used for the intersection test.
Sourcepub fn project_point(
&self,
point: Vect,
max_dist: f32,
solid: bool,
) -> Option<(Entity, PointProjection)>
pub fn project_point( &self, point: Vect, max_dist: f32, solid: bool, ) -> Option<(Entity, PointProjection)>
Find the projection of a point on the closest collider.
§Parameters
point- The point to project.max_dist- The maximum distance between the point and its projection. Colliders further than this distance are ignored.solid- If this is set totruethen 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 tofalsethe 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).
Sourcepub fn intersect_point(
&'a self,
point: Vect,
) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a
pub fn intersect_point( &'a self, point: Vect, ) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a
Find all the colliders containing the given point, alongside their Rapier collider.
§Parameters
point- The point used for the containment test.
Sourcepub fn project_point_and_get_feature(
&self,
point: Vect,
max_dist: f32,
) -> Option<(Entity, PointProjection, FeatureId)>
pub fn project_point_and_get_feature( &self, point: Vect, max_dist: f32, ) -> Option<(Entity, PointProjection, FeatureId)>
Find the projection of a point on the boundary of the closest collider.
The results include the ID of the feature hit by the point.
§Parameters
point- The point to project.max_dist- The maximum distance between the point and its projection. Colliders further than this distance are ignored. UseReal::MAXfor an unbounded search.
Sourcepub fn intersect_aabb_conservative(
&'a self,
aabb: Aabb3d,
) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a
pub fn intersect_aabb_conservative( &'a self, aabb: Aabb3d, ) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a
Sourcepub fn cast_shape(
&'a self,
shape_pos: Vect,
shape_rot: Rot,
shape_vel: Vect,
shape: &(impl AsShape + ?Sized),
options: ShapeCastOptions,
) -> Option<(Entity, ShapeCastHit)>
pub fn cast_shape( &'a self, shape_pos: Vect, shape_rot: Rot, shape_vel: Vect, shape: &(impl AsShape + ?Sized), options: ShapeCastOptions, ) -> Option<(Entity, 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 ShapeCastHit, witness and normal 1 refer to the
collider hit and are in world-space, while witness and normal 2 refer to the cast shape and
are in its local-space (see ShapeCastHitDetails).
§Parameters
shape_pos- The initial translation of the shape to cast.shape_rot- The rotation 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 the casted shape starts in a penetration state with any collider, two results are possible. Ifstop_at_penetrationistruethen, the result will have atoiequal tostart_time. Ifstop_at_penetrationisfalsethen 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_timethat could result in tunnelling.
Sourcepub fn cast_shape_nonlinear(
&self,
shape_motion: &NonlinearMotion,
shape: &(impl AsShape + ?Sized),
start_time: f32,
end_time: f32,
stop_at_penetration: bool,
) -> Option<(Entity, ShapeCastHit)>
pub fn cast_shape_nonlinear( &self, shape_motion: &NonlinearMotion, shape: &(impl AsShape + ?Sized), start_time: f32, end_time: f32, stop_at_penetration: bool, ) -> Option<(Entity, ShapeCastHit)>
Casts a shape with an arbitrary continuous motion and retrieve the first collider it hits.
In the resulting ShapeCastHit, witness and normal 1 refer to the collider hit and are in
world-space, while witness and normal 2 refer to the cast shape and are in its local-space.
§Parameters
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_penetrationistruethen, the result will have atoiequal tostart_time. Ifstop_at_penetrationisfalsethen 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_timethat could result in tunnelling.
Sourcepub fn distance_to_shape(
&self,
shape_pos: Vect,
shape_rot: Rot,
shape: &(impl AsShape + ?Sized),
) -> Option<(Entity, f32)>
pub fn distance_to_shape( &self, shape_pos: Vect, shape_rot: Rot, shape: &(impl AsShape + ?Sized), ) -> Option<(Entity, f32)>
Computes the smallest distance between the given shape and the closest collider.
Returns the entity of the closest collider alongside that distance, which is 0.0 if they
are intersecting. Returns None if no collider passes the query filter.
§Parameters
shape_pos- The translation of the shape.shape_rot- The rotation of the shape.shape- The shape to compute the distance from.
Sourcepub fn closest_points_to_shape(
&self,
shape_pos: Vect,
shape_rot: Rot,
shape: &(impl AsShape + ?Sized),
max_dist: f32,
) -> Option<(Entity, ShapeClosestPoints)>
pub fn closest_points_to_shape( &self, shape_pos: Vect, shape_rot: Rot, shape: &(impl AsShape + ?Sized), max_dist: f32, ) -> Option<(Entity, ShapeClosestPoints)>
Computes the closest points between the given shape and the closest collider.
Returns the entity of the closest collider alongside the closest points. In
ShapeClosestPoints::WithinMargin, the first point is on the collider and the second
point is on shape, both in world-space. Returns None if no collider lies within
max_dist of shape.
§Parameters
shape_pos- The translation of the shape.shape_rot- The rotation of the shape.shape- The shape to compute the closest points from.max_dist- Colliders further than this distance fromshapeare ignored.
Sourcepub fn contact_with_shape(
&self,
shape_pos: Vect,
shape_rot: Rot,
shape: &(impl AsShape + ?Sized),
prediction: f32,
) -> Option<(Entity, ShapeContact)>
pub fn contact_with_shape( &self, shape_pos: Vect, shape_rot: Rot, shape: &(impl AsShape + ?Sized), prediction: f32, ) -> Option<(Entity, ShapeContact)>
Computes the contact between the given shape and the closest (or deepest penetrating) collider.
Returns the entity of that collider alongside the contact, where the first shape is the
collider and the second shape is shape; contact points and normals are in world-space.
Returns None if no collider lies within prediction of shape.
§Parameters
shape_pos- The translation of the shape.shape_rot- The rotation of the shape.shape- The shape to compute the contact with.prediction- Colliders further than this distance fromshapeare ignored.
Sourcepub fn bvh(&self) -> &'a Bvh
pub fn bvh(&self) -> &'a Bvh
The bounding volume hierarchy containing the world-space AABB of every collider.
This can be used for custom scene traversals. Each leaf index identifies a collider and
can be resolved with Self::bvh_leaf_collider. Note that the BVH itself ignores the
query filter.
Sourcepub fn bvh_leaf_collider(
&self,
leaf: u32,
) -> Option<(Entity, &'a RapierCollider)>
pub fn bvh_leaf_collider( &self, leaf: u32, ) -> Option<(Entity, &'a RapierCollider)>
Retrieves the entity and Rapier collider identified by a leaf index of Self::bvh.
Returns None if the collider doesn’t exist or is rejected by the query filter.
Trait Implementations§
Source§impl<'a> Clone for RapierQueryPipeline<'a>
impl<'a> Clone for RapierQueryPipeline<'a>
Source§fn clone(&self) -> RapierQueryPipeline<'a>
fn clone(&self) -> RapierQueryPipeline<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for RapierQueryPipeline<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for RapierQueryPipeline<'a>
impl<'a> !Send for RapierQueryPipeline<'a>
impl<'a> !Sync for RapierQueryPipeline<'a>
impl<'a> !UnwindSafe for RapierQueryPipeline<'a>
impl<'a> Freeze for RapierQueryPipeline<'a>
impl<'a> Unpin for RapierQueryPipeline<'a>
impl<'a> UnsafeUnpin for RapierQueryPipeline<'a>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>, which can then be
downcast into Box<dyn 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>, which 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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.