Introduce the PhysicsHook trait used for both contact filtering and contact modification.

This commit is contained in:
Crozet Sébastien
2021-02-23 11:24:54 +01:00
parent ad5c10672e
commit 00706e8b36
8 changed files with 160 additions and 58 deletions

View File

@@ -9,7 +9,10 @@ bitflags::bitflags! {
pub struct SolverFlags: u32 {
/// The constraint solver will take this contact manifold into
/// account for force computation.
const COMPUTE_IMPULSES = 0b01;
const COMPUTE_IMPULSES = 0b001;
/// The user-defined physics hooks will be used to
/// modify the solver contacts of this contact manifold.
const MODIFY_SOLVER_CONTACTS = 0b010;
}
}
@@ -104,6 +107,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>,
/// A user-defined piece of data.
pub user_data: u32,
}
/// A contact seen by the constraints solver for computing forces.
@@ -165,6 +170,7 @@ impl ContactManifoldData {
solver_flags,
normal: Vector::zeros(),
solver_contacts: Vec::new(),
user_data: 0,
}
}
@@ -205,9 +211,3 @@ impl ContactManifoldData {
// manifold.data.warmstart_multiplier = Self::min_warmstart_multiplier()
// }
}
/// A contact manifold that can be modified by the user.
pub struct ModifiableContactManifold<'a> {
manifold: &'a super::ContactManifold,
solver_contacts: &'a mut Vec<SolverContact>,
}