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§

source§

impl QueryPipeline

source

pub fn new() -> Self

Initializes an empty query pipeline.

source

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.

source

pub fn query_dispatcher(&self) -> &dyn QueryDispatcher

The query dispatcher used by this query pipeline for running scene queries.

source

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.

source

pub fn update(&mut self, bodies: &RigidBodySet, colliders: &ColliderSet)

Update the acceleration structure on the query pipeline.

source

pub fn update_with_mode( &mut self, bodies: &RigidBodySet, colliders: &ColliderSet, mode: QueryPipelineMode )

Update the acceleration structure on the query pipeline.

source

pub fn cast_ray( &self, bodies: &RigidBodySet, colliders: &ColliderSet, ray: &Ray, max_toi: Real, solid: bool, filter: QueryFilter<'_> ) -> 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 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.
  • filter: set of rules used to determine which collider is taken into account by this scene query.
source

pub fn cast_ray_and_get_normal( &self, bodies: &RigidBodySet, colliders: &ColliderSet, ray: &Ray, max_toi: Real, solid: bool, filter: QueryFilter<'_> ) -> 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 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.
  • filter: set of rules used to determine which collider is taken into account by this scene query.
source

pub fn intersections_with_ray<'a>( &self, bodies: &'a RigidBodySet, colliders: &'a ColliderSet, ray: &Ray, max_toi: Real, solid: bool, filter: QueryFilter<'_>, 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 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.
  • 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 returns false, this method will exit early, ignore any further raycast.
source

pub fn intersection_with_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_pos: &Isometry<Real>, 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.
source

pub fn project_point( &self, bodies: &RigidBodySet, colliders: &ColliderSet, point: &Point<Real>, 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 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).
  • filter: set of rules used to determine which collider is taken into account by this scene query.
source

pub fn intersections_with_point( &self, bodies: &RigidBodySet, colliders: &ColliderSet, point: &Point<Real>, 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 the point.
source

pub fn project_point_and_get_feature( &self, bodies: &RigidBodySet, colliders: &ColliderSet, point: &Point<Real>, 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 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).
  • filter: set of rules used to determine which collider is taken into account by this scene query.
source

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.

source

pub fn cast_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_pos: &Isometry<Real>, shape_vel: &Vector<Real>, 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 to shapeVel.norm() * maxToi.
  • stop_at_penetration - If set to false, 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 exist that penetration state.
  • filter: set of rules used to determine which collider is taken into account by this scene query.
source

pub fn nonlinear_cast_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_motion: &NonlinearRigidMotion, shape: &dyn Shape, start_time: Real, end_time: Real, 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. 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 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.
source

pub fn intersections_with_shape( &self, bodies: &RigidBodySet, colliders: &ColliderSet, shape_pos: &Isometry<Real>, 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 the shape.

Trait Implementations§

source§

impl Clone for QueryPipeline

source§

fn clone(&self) -> QueryPipeline

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Default for QueryPipeline

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for QueryPipeline

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for QueryPipeline

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> 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<T> Downcast for T
where T: Any,

source§

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

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.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

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

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

Convert &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
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

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> Same for T

§

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> ToOwned for T
where T: Clone,

§

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

§

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

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,