Implement dominance.

This commit is contained in:
Crozet Sébastien
2021-02-24 13:26:51 +01:00
parent 3cc2738e5f
commit 96ecb877e2
11 changed files with 42 additions and 10 deletions

View File

@@ -113,6 +113,8 @@ pub struct ContactManifoldData {
/// The contacts that will be seen by the constraints solver for computing forces.
#[cfg_attr(feature = "serde-serialize", serde(skip))]
pub solver_contacts: Vec<SolverContact>,
/// The relative dominance of the bodies involved in this contact manifold.
pub relative_dominance: i16,
/// A user-defined piece of data.
pub user_data: u32,
}
@@ -122,7 +124,7 @@ pub struct ContactManifoldData {
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct SolverContact {
/// The index of the manifold contact used to generate this solver contact.
pub contact_id: u8,
pub(crate) contact_id: u8,
/// The world-space contact point.
pub point: Point<Real>,
/// The distance between the two original contacts points along the contact normal.
@@ -177,6 +179,7 @@ impl ContactManifoldData {
solver_flags,
normal: Vector::zeros(),
solver_contacts: Vec::new(),
relative_dominance: 0,
user_data: 0,
}
}

View File

@@ -555,6 +555,8 @@ impl NarrowPhase {
manifold.data.solver_contacts.clear();
manifold.data.body_pair = BodyPair::new(co1.parent(), co2.parent());
manifold.data.solver_flags = solver_flags;
manifold.data.relative_dominance =
rb1.effective_dominance_group() - rb2.effective_dominance_group();
manifold.data.normal = world_pos1 * manifold.local_n1;
// Generate solver contacts.