Skip to main content

RapierQueryPipeline

Struct RapierQueryPipeline 

Source
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>

Source

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.

Source

pub fn collider_entity(&self, collider_handle: ColliderHandle) -> Entity

Retrieves the Entity for a given collider handle.

Source

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 to ray.dir.norm() * max_toi. Use Real::MAX for an unbounded ray.
  • solid: if this is true an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
Source

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 to ray.dir.norm() * max_toi. Use Real::MAX for an unbounded ray.
  • solid: if this is true an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
Source

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 to ray.dir.norm() * max_toi. Use Real::MAX for an unbounded ray.
  • solid: if this is true an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
Source

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.
Source

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 to true 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 to false 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).
Source

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.
Source

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. Use Real::MAX for an unbounded search.
Source

pub fn intersect_aabb_conservative( &'a self, aabb: Aabb3d, ) -> impl Iterator<Item = (Entity, &'a RapierCollider)> + 'a

Finds all the colliders with an Aabb intersecting the given Aabb, alongside their Rapier collider.

Note that the collider AABB taken into account is the one currently stored in the query pipeline’s BVH. It doesn’t recompute the latest collider AABB.

Source

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 to shape_vel.norm() * maxToi.
  • stop_at_penetration - If the casted shape starts in a penetration state with any collider, two results are possible. If stop_at_penetration is true then, the result will have a toi equal to start_time. If stop_at_penetration is false 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.
Source

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. If stop_at_penetration is true then, the result will have a toi equal to start_time. If stop_at_penetration is false 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.
Source

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.
Source

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 from shape are ignored.
Source

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 from shape are ignored.
Source

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.

Source

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>

Source§

fn clone(&self) -> RapierQueryPipeline<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for RapierQueryPipeline<'a>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> Template for T
where T: Clone + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more