pub struct ContactManifold {
pub points: Vec<ContactPoint>,
pub normal: Vector,
pub friction: Scalar,
pub restitution: Scalar,
pub tangent_velocity: Vector,
}Expand description
A contact manifold describing a contact surface between two colliders, represented by a set of contact points and surface properties.
A manifold can typically be a single point, a line segment, or a polygon formed by its contact points. Each contact point in a manifold shares the same contact normal.
Fields§
§points: Vec<ContactPoint>The contact points in this manifold.
Each point in a manifold shares the same normal.
normal: VectorThe unit contact normal in world space, pointing from the first shape to the second.
The same normal is shared by all points in a manifold.
friction: ScalarThe effective coefficient of dynamic friction used for the contact surface.
restitution: ScalarThe effective coefficient of restitution used for the contact surface.
tangent_velocity: VectorThe desired relative linear velocity of the bodies along the surface,
expressed in world space as tangent_velocity2 - tangent_velocity1.
Defaults to zero. If set to a non-zero value, this can be used to simulate effects such as conveyor belts.
Implementations§
Source§impl ContactManifold
impl ContactManifold
Sourcepub fn new(
points: impl IntoIterator<Item = ContactPoint>,
normal: Vector,
) -> Self
pub fn new( points: impl IntoIterator<Item = ContactPoint>, normal: Vector, ) -> Self
Creates a new ContactManifold with the given contact points and surface normals,
expressed in local space.
index represents the index of the manifold in the collision.
Sourcepub fn total_normal_impulse(&self) -> Scalar
pub fn total_normal_impulse(&self) -> Scalar
The sum of the impulses applied at the contact points in the manifold along the contact normal.
Sourcepub fn max_normal_impulse(&self) -> Scalar
pub fn max_normal_impulse(&self) -> Scalar
The magnitude of the largest impulse applied at a contact point in the manifold along the contact normal.
Sourcepub fn match_contacts(
&mut self,
previous_contacts: &[ContactPoint],
distance_threshold: Scalar,
)
pub fn match_contacts( &mut self, previous_contacts: &[ContactPoint], distance_threshold: Scalar, )
Copies impulses from previous contacts to matching contacts in self.
Contacts are first matched based on their feature IDs, and if they are unknown,
matching is done based on contact positions using the given distance_threshold
for determining if points are too far away from each other to be considered matching.
Sourcepub fn prune_points(&mut self)
pub fn prune_points(&mut self)
Prunes the contact points in the manifold to a maximum of 4 points. This is done to improve performance and stability.
Sourcepub fn find_deepest_contact(&self) -> Option<&ContactPoint>
pub fn find_deepest_contact(&self) -> Option<&ContactPoint>
Returns the contact point 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 ContactManifold
impl Clone for ContactManifold
Source§fn clone(&self) -> ContactManifold
fn clone(&self) -> ContactManifold
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContactManifold
impl Debug for ContactManifold
Source§impl PartialEq for ContactManifold
impl PartialEq for ContactManifold
impl StructuralPartialEq for ContactManifold
Auto Trait Implementations§
impl Freeze for ContactManifold
impl RefUnwindSafe for ContactManifold
impl Send for ContactManifold
impl Sync for ContactManifold
impl Unpin for ContactManifold
impl UnwindSafe for ContactManifold
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>, 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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
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.