pub struct ContactPair {
pub collider1: Entity,
pub collider2: Entity,
pub body1: Option<Entity>,
pub body2: Option<Entity>,
pub manifolds: Vec<ContactManifold>,
pub flags: ContactPairFlags,
}
Expand description
A contact pair between two colliders.
Each contact pair has one or more contact manifolds, which represent contact surfaces between the two colliders. Each of these manifolds contains one or more contact points.
Contact pairs exist in the ContactGraph
between colliders whose ColliderAabb
s
are overlapping, even if the colliders themselves are not touching.
Fields§
§collider1: Entity
The first collider entity in the contact.
collider2: Entity
The second collider entity in the contact.
body1: Option<Entity>
The entity of the first body involved in the contact.
body2: Option<Entity>
The entity of the second body involved in the contact.
manifolds: Vec<ContactManifold>
A list of contact manifolds between two colliders. Each manifold contains one or more contact points, but each contact in a given manifold shares the same contact normal.
flags: ContactPairFlags
Flag indicating the status and type of the contact pair.
Implementations§
Source§impl ContactPair
impl ContactPair
Sourcepub fn new(collider1: Entity, collider2: Entity) -> Self
pub fn new(collider1: Entity, collider2: Entity) -> Self
Creates a new ContactPair
with the given entities.
Sourcepub fn total_normal_impulse(&self) -> Vector
pub fn total_normal_impulse(&self) -> Vector
Computes the sum of all impulses applied along contact normals between the contact pair.
To get the corresponding force, divide the impulse by Time::<Substeps>::delta_secs()
.
Sourcepub fn total_normal_impulse_magnitude(&self) -> Scalar
pub fn total_normal_impulse_magnitude(&self) -> Scalar
Computes the sum of the magnitudes of all impulses applied along contact normals between the contact pair.
This is the sum of impulse magnitudes, not the magnitude of the total_normal_impulse
.
To get the corresponding force, divide the impulse by Time::<Substeps>::delta_secs()
.
Sourcepub fn max_normal_impulse(&self) -> (Scalar, Vector)
pub fn max_normal_impulse(&self) -> (Scalar, Vector)
Finds the largest impulse between the contact pair, and the associated world-space contact normal, pointing from the first shape to the second.
To get the corresponding force, divide the impulse by Time::<Substeps>::delta_secs()
.
Sourcepub fn total_normal_force(&self, delta_time: Scalar) -> Scalar
👎Deprecated since 0.3.0: Use total_normal_impulse
instead, and divide it by Time<Substeps>::delta_secs()
pub fn total_normal_force(&self, delta_time: Scalar) -> Scalar
total_normal_impulse
instead, and divide it by Time<Substeps>::delta_secs()
The force corresponding to the total normal impulse applied over delta_time
.
Because contacts are solved over several substeps, delta_time
should
typically use Time<Substeps>::delta_secs()
.
Sourcepub fn is_touching(&self) -> bool
pub fn is_touching(&self) -> bool
Returns true
if the colliders are touching, including sensors.
Sourcepub fn aabbs_disjoint(&self) -> bool
pub fn aabbs_disjoint(&self) -> bool
Returns true
if the AABBs of the colliders are no longer overlapping.
Sourcepub fn collision_started(&self) -> bool
pub fn collision_started(&self) -> bool
Returns true
if a collision started during the current frame.
Sourcepub fn collision_ended(&self) -> bool
pub fn collision_ended(&self) -> bool
Returns true
if a collision ended during the current frame.
Sourcepub fn events_enabled(&self) -> bool
pub fn events_enabled(&self) -> bool
Returns true
if collision events are enabled for the contact pair.
Sourcepub fn find_deepest_contact(&self) -> Option<&ContactPoint>
pub fn find_deepest_contact(&self) -> Option<&ContactPoint>
Returns the contact with the largest penetration depth.
If the objects are separated but there is still a speculative contact, the penetration depth will be negative.
If there are no contacts, None
is returned.
Trait Implementations§
Source§impl Clone for ContactPair
impl Clone for ContactPair
Source§fn clone(&self) -> ContactPair
fn clone(&self) -> ContactPair
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ContactPair
impl Debug for ContactPair
Source§impl PartialEq for ContactPair
impl PartialEq for ContactPair
impl StructuralPartialEq for ContactPair
Auto Trait Implementations§
impl Freeze for ContactPair
impl RefUnwindSafe for ContactPair
impl Send for ContactPair
impl Sync for ContactPair
impl Unpin for ContactPair
impl UnwindSafe for ContactPair
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
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>
. 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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
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> 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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> Pointable for T
impl<T> Pointable for T
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.