Struct CompositeShapeRef

Source
pub struct CompositeShapeRef<'a, S: ?Sized>(pub &'a S);
Expand description

A helper struct that implements scene queries on any composite shapes.

For example, the RayCast implementation of a composite shape can use this wrapper or provide its own implementation. This is for working around the lack of specialization in (stable) rust. If we did have specialization, this would just be a blanket implementation of all the geometric query traits for all S: CompositeShape.

Tuple Fields§

§0: &'a S

Implementations§

Source§

impl<S: ?Sized + TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn closest_points_to_shape<D: ?Sized + QueryDispatcher>( &self, dispatcher: &D, pose12: &Isometry<f32>, shape2: &dyn Shape, margin: f32, ) -> Option<(u32, ClosestPoints)>

Returns the closest points between self and the given shape2 positioned at pose12 relative to self.

Returns the index of the sub-shape of self involved in the contact as well as the closest points information.

Returns ClosestPoints::Disjoint if self and shape2 are separated by a distance larger than margin.

Returns None if no closest point could be calculated (e.g. if the dispatcher doesn’t support the involved shapes at all, or if self is empty).

Source§

impl<S: ?Sized + CompositeShape> CompositeShapeRef<'_, S>

Source

pub fn contact_with_shape<D: ?Sized + QueryDispatcher>( &self, dispatcher: &D, pose12: &Isometry<f32>, shape2: &dyn Shape, prediction: f32, ) -> Option<(u32, Contact)>

Returns the closest/deepest contact between self and the given shape2 positioned at pose12 relative to self.

Returns None if self and shape2 are separated by a distance larger than prediction. Otherwise, returns the index of the sub-shape of self involved in the contact as well as the contact information.

Source§

impl<S: ?Sized + TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn distance_to_shape<D: ?Sized + QueryDispatcher>( &self, dispatcher: &D, pose12: &Isometry<f32>, shape2: &dyn Shape, ) -> Option<(u32, f32)>

Calculates the closest distance between self and the given shape2 positioned at pose12 relative to self.

Returns the distance and the index of the sub-shape of self that is closest to shape2.

Source§

impl<S: ?Sized + TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn intersects_shape<D: ?Sized + QueryDispatcher>( &self, dispatcher: &D, pose12: &Isometry<f32>, shape: &dyn Shape, ) -> Option<u32>

Returns the index of the shape in self that intersects the given other shape positioned at pose12 relative to self.

Returns None if no intersection is found.

Source§

impl<S: ?Sized + TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn cast_shape_nonlinear<D: ?Sized + QueryDispatcher>( &self, dispatcher: &D, motion1: &NonlinearRigidMotion, motion2: &NonlinearRigidMotion, shape2: &dyn Shape, start_time: f32, end_time: f32, stop_at_penetration: bool, ) -> Option<(u32, ShapeCastHit)>

Performs a non-linear shape-cast between self animated subject to the motion1 and the shape2 subject to the motion2.

Returns the shape-cast hit (if any) as well as the index of the sub-shape of self involved in the hit.

Source§

impl<S: TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn project_local_point_and_get_location( &self, point: &Point<f32>, max_dist: f32, solid: bool, ) -> Option<(u32, (PointProjection, <S::PartShape as PointQueryWithLocation>::Location))>

Project a point on this composite shape.

Returns the projected point as well as the index of the sub-shape of self that was hit. The third tuple element contains some shape-specific information about the projected point.

Source

pub fn project_local_point( &self, point: &Point<f32>, solid: bool, ) -> (u32, PointProjection)

Project a point on this composite shape.

Returns the projected point as well as the index of the sub-shape of self that was hit. If solid is false then the point will be projected to the closest boundary of self even if it is contained by one of its sub-shapes.

Source

pub fn project_local_point_and_get_feature( &self, point: &Point<f32>, ) -> (u32, (PointProjection, FeatureId))

Project a point on this composite shape.

Returns the projected point as well as the index of the sub-shape of self that was hit. The third tuple element contains some shape-specific information about the shape feature hit by the projection.

Source

pub fn contains_local_point(&self, point: &Point<f32>) -> Option<u32>

Returns the index of any sub-shape of self that contains the given point.

Source§

impl<S: TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<(u32, f32)>

Casts a ray on this composite shape.

The ray is effectively limited to a segment that starts at Ray::origin and ends at Ray::origin + Ray::direction * max_time_of_impact. Set max_time_of_impact to Real::MAX for an unbounded ray.

If solid is false, then the sub-shapes of self are seen as hollow and the ray won’t immediately stop until it reaches a boundary even if it started inside a shape.

Returns the ray’s time of impact and the index of the sub-shape of self that was hit. The hit point can be retrieved with ray.point_at(t) where t is the value returned by this function.

Source

pub fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<(u32, RayIntersection)>

Same as Self::cast_local_ray but also computes the normal at the hit location.

Source§

impl<S: ?Sized + TypedCompositeShape> CompositeShapeRef<'_, S>

Source

pub fn cast_shape<D: ?Sized + QueryDispatcher>( &self, dispatcher: &D, pose12: &Isometry<f32>, vel12: &Vector<f32>, g2: &dyn Shape, options: ShapeCastOptions, ) -> Option<(u32, ShapeCastHit)>

Performs a shape-cast between self and a shape2 positioned at pose12 and subject to a linear velocity vel12, relative to self.

Returns the shape-cast hit (if any) as well as the index of the sub-shape of self involved in the hit.

Auto Trait Implementations§

§

impl<'a, S> Freeze for CompositeShapeRef<'a, S>
where S: ?Sized,

§

impl<'a, S> RefUnwindSafe for CompositeShapeRef<'a, S>
where S: RefUnwindSafe + ?Sized,

§

impl<'a, S> Send for CompositeShapeRef<'a, S>
where S: Sync + ?Sized,

§

impl<'a, S> Sync for CompositeShapeRef<'a, S>
where S: Sync + ?Sized,

§

impl<'a, S> Unpin for CompositeShapeRef<'a, S>
where S: ?Sized,

§

impl<'a, S> UnwindSafe for CompositeShapeRef<'a, S>
where S: RefUnwindSafe + ?Sized,

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>

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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be 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> 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, 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