Struct QueryPipeline

Source
pub struct QueryPipeline<'a> {
    pub dispatcher: &'a dyn QueryDispatcher,
    pub bvh: &'a Bvh,
    pub bodies: &'a RigidBodySet,
    pub colliders: &'a ColliderSet,
    pub filter: QueryFilter<'a>,
}
Expand description

The query pipeline responsible for running scene queries on the physics world.

This structure is generally obtained by calling BroadPhaseBvh::as_query_pipeline_mut.

Fields§

§dispatcher: &'a dyn QueryDispatcher

The query dispatcher for running geometric queries on leaf geometries.

§bvh: &'a Bvh

A bvh containing collider indices at its leaves.

§bodies: &'a RigidBodySet

Rigid-bodies potentially involved in the scene queries.

§colliders: &'a ColliderSet

Colliders potentially involved in the scene queries.

§filter: QueryFilter<'a>

The query filters for controlling what colliders should be ignored by the queries.

Implementations§

Source§

impl<'a> QueryPipeline<'a>

Source

pub fn with_filter(self, filter: QueryFilter<'a>) -> Self

Replaces Self::filter with different filtering rules.

Source

pub fn cast_ray( &self, ray: &Ray, max_toi: f32, solid: bool, ) -> 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 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 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, ray: &Ray, max_toi: f32, solid: bool, ) -> 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 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 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 intersect_ray( &'a self, ray: Ray, max_toi: f32, solid: bool, ) -> impl Iterator<Item = (ColliderHandle, &'a Collider, RayIntersection)> + 'a

Iterates through all the colliders intersecting a given ray.

§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 a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
Source

pub fn project_point( &self, point: &Point<f32>, _max_dist: f32, solid: bool, ) -> Option<(ColliderHandle, PointProjection)>

Find the projection of a point on the closest collider.

§Parameters
  • 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).
Source

pub fn intersect_point( &'a self, point: Point<f32>, ) -> impl Iterator<Item = (ColliderHandle, &'a Collider)> + 'a

Find all the colliders containing the given point.

§Parameters
  • point - The point used for the containment test.
Source

pub fn project_point_and_get_feature( &self, point: &Point<f32>, ) -> 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
  • point - The point to project.
Source

pub fn intersect_aabb_conservative( &'a self, aabb: Aabb, ) -> impl Iterator<Item = (ColliderHandle, &'a Collider)> + 'a

Finds all handles of all the colliders with an Aabb intersecting the given Aabb.

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( &self, shape_pos: &Isometry<f32>, shape_vel: &Vector<f32>, shape: &dyn Shape, options: ShapeCastOptions, ) -> 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
  • 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.
  • options - Options controlling the shape cast limits and behavior.
Source

pub fn cast_shape_nonlinear( &self, shape_motion: &NonlinearRigidMotion, shape: &dyn Shape, start_time: f32, end_time: f32, stop_at_penetration: bool, ) -> 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
  • 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.
Source

pub fn intersect_shape( &'a self, shape_pos: Isometry<f32>, shape: &'a dyn Shape, ) -> impl Iterator<Item = (ColliderHandle, &'a Collider)> + 'a

Retrieve all the colliders intersecting the given shape.

§Parameters
  • shapePos - The pose of the shape to test.
  • shape - The shape to test.

Trait Implementations§

Source§

impl<'a> Clone for QueryPipeline<'a>

Source§

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

Returns a duplicate 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 CompositeShape for QueryPipeline<'_>

Source§

fn map_part_at( &self, shape_id: u32, f: &mut dyn FnMut(Option<&Isometry<f32>>, &dyn Shape, Option<&dyn NormalConstraints>), )

Applies a function to one sub-shape of this composite shape. Read more
Source§

fn bvh(&self) -> &Bvh

Gets the acceleration structure of the composite shape.
Source§

impl TypedCompositeShape for QueryPipeline<'_>

Source§

type PartNormalConstraints = ()

Source§

type PartShape = dyn Shape

Source§

fn map_typed_part_at<T>( &self, shape_id: u32, f: impl FnMut(Option<&Isometry<f32>>, &Self::PartShape, Option<&Self::PartNormalConstraints>) -> T, ) -> Option<T>

Source§

fn map_untyped_part_at<T>( &self, shape_id: u32, f: impl FnMut(Option<&Isometry<f32>>, &dyn Shape, Option<&dyn NormalConstraints>) -> T, ) -> Option<T>

Source§

impl<'a> Copy for QueryPipeline<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for QueryPipeline<'a>

§

impl<'a> !RefUnwindSafe for QueryPipeline<'a>

§

impl<'a> !Send for QueryPipeline<'a>

§

impl<'a> !Sync for QueryPipeline<'a>

§

impl<'a> Unpin for QueryPipeline<'a>

§

impl<'a> !UnwindSafe for QueryPipeline<'a>

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> 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, 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> 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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V