pub struct ContactManifold {
pub entity_a: Entity,
pub entity_b: Entity,
pub contacts: Vec<ContactPoint>,
pub friction: f32,
pub static_friction: f32,
pub restitution: f32,
pub lifetime: u32,
}Expand description
Up to four contact points between a pair of bodies, along with the combined material properties needed by the constraint solver.
§Contact limit & point selection
Physics engines conventionally cap manifolds at 4 points because that is the minimum required to fully constrain a convex face-face contact. When a 5th point would be added we keep the configuration that maximises the contact area while retaining the deepest point:
- Always keep the deepest point (most important for penetration resolution).
- Fill the remaining 3 slots by greedily maximising the minimum distance to any already-selected point (farthest-point heuristic — O(n) per slot).
This gives a good approximation of the convex hull of the contact patch without an expensive full hull computation.
Fields§
§entity_a: Entity§entity_b: Entity§contacts: Vec<ContactPoint>At most 4 contact points.
friction: f32Combined dynamic friction coefficient (geometric mean of both materials).
static_friction: f32Combined static friction coefficient.
restitution: f32Combined coefficient of restitution (max of both materials).
lifetime: u32Number of consecutive physics frames this manifold has been alive. Incremented by the pipeline each frame; reset when the collision ends.
Implementations§
Source§impl ContactManifold
impl ContactManifold
Sourcepub fn new(entity_a: Entity, entity_b: Entity) -> ContactManifold
pub fn new(entity_a: Entity, entity_b: Entity) -> ContactManifold
Create a new manifold. Entity order is normalised (lower id → entity_a) so that cache lookups with either ordering always hit.
Sourcepub fn add_contact(&mut self, contact: ContactPoint)
pub fn add_contact(&mut self, contact: ContactPoint)
Add contact to the manifold, warm-starting from any existing point
that is within MERGE_RADIUS in world space.
If the manifold is already at capacity (4 points) and no merge occurs, the 5-point set is reduced back to 4 using the area-maximisation heuristic described in the type-level docs.
Trait Implementations§
Source§impl Clone for ContactManifold
impl Clone for ContactManifold
Source§fn clone(&self) -> ContactManifold
fn clone(&self) -> ContactManifold
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ContactManifold
impl RefUnwindSafe for ContactManifold
impl Send for ContactManifold
impl Sync for ContactManifold
impl Unpin for ContactManifold
impl UnsafeUnpin for ContactManifold
impl UnwindSafe for ContactManifold
Blanket Implementations§
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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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 more