diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-10-27 13:36:53 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-10-27 14:35:01 +0100 |
| commit | cb6a7ff9468347735ef63db9a9e38faeb476981b (patch) | |
| tree | 49f3a20afbd5a3be4c3d9de25f630f6b353e6406 /src/geometry/collider.rs | |
| parent | 3def91d62eba6ca2486fdaa386f78d82923c705a (diff) | |
| download | rapier-cb6a7ff9468347735ef63db9a9e38faeb476981b.tar.gz rapier-cb6a7ff9468347735ef63db9a9e38faeb476981b.tar.bz2 rapier-cb6a7ff9468347735ef63db9a9e38faeb476981b.zip | |
Add solver flags for controlling whether or not some contacts should be taken into account by the constraints solver.
Diffstat (limited to 'src/geometry/collider.rs')
| -rw-r--r-- | src/geometry/collider.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index 7147e95..f53d75a 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -204,6 +204,7 @@ pub struct Collider { /// The restitution coefficient of this collider. pub restitution: f32, pub(crate) collision_groups: InteractionGroups, + pub(crate) solver_groups: InteractionGroups, pub(crate) contact_graph_index: ColliderGraphIndex, pub(crate) proximity_graph_index: ColliderGraphIndex, pub(crate) proxy_index: usize, @@ -261,6 +262,11 @@ impl Collider { self.collision_groups } + /// The solver groups used by this collider. + pub fn solver_groups(&self) -> InteractionGroups { + self.solver_groups + } + /// The density of this collider. pub fn density(&self) -> f32 { self.density @@ -304,10 +310,12 @@ pub struct ColliderBuilder { pub delta: Isometry<f32>, /// Is this collider a sensor? pub is_sensor: bool, - /// The user-data of the collider beind built. + /// The user-data of the collider being built. pub user_data: u128, /// The collision groups for the collider being built. pub collision_groups: InteractionGroups, + /// The solver groups for the collider being built. + pub solver_groups: InteractionGroups, } impl ColliderBuilder { @@ -322,6 +330,7 @@ impl ColliderBuilder { is_sensor: false, user_data: 0, collision_groups: InteractionGroups::all(), + solver_groups: InteractionGroups::all(), } } @@ -442,6 +451,15 @@ impl ColliderBuilder { self } + /// Sets the solver groups used by this collider. + /// + /// Forces between two colliders in contact will be computed iff their solver groups are + /// compatible. See [InteractionGroups::test] for details. + pub fn solver_groups(mut self, groups: InteractionGroups) -> Self { + self.solver_groups = groups; + self + } + /// Sets whether or not the collider built by this builder is a sensor. pub fn sensor(mut self, is_sensor: bool) -> Self { self.is_sensor = is_sensor; @@ -523,6 +541,8 @@ impl ColliderBuilder { contact_graph_index: InteractionGraph::<Contact>::invalid_graph_index(), proximity_graph_index: InteractionGraph::<Proximity>::invalid_graph_index(), proxy_index: crate::INVALID_USIZE, + collision_groups: self.collision_groups, + solver_groups: self.solver_groups, user_data: self.user_data, } } |
