diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-05-02 13:13:01 +0200 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2022-05-02 13:13:16 +0200 |
| commit | e63fa60d06f57b1f33c71ee7c09caffc7ef7597d (patch) | |
| tree | 21d03b2facd84c46cc0a63258f0b078b71afa8a1 /src | |
| parent | 936f655c67f03d6eae6c2c9fc2ad0647b54d74b7 (diff) | |
| download | rapier-e63fa60d06f57b1f33c71ee7c09caffc7ef7597d.tar.gz rapier-e63fa60d06f57b1f33c71ee7c09caffc7ef7597d.tar.bz2 rapier-e63fa60d06f57b1f33c71ee7c09caffc7ef7597d.zip | |
Backport fix for bug where changing collision groups would not be taken into account for pre-existing contacts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/geometry/contact_pair.rs | 7 | ||||
| -rw-r--r-- | src/geometry/narrow_phase.rs | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs index f4e7834..f57f0fa 100644 --- a/src/geometry/contact_pair.rs +++ b/src/geometry/contact_pair.rs @@ -77,6 +77,13 @@ impl ContactPair { } } + /// Clears all the contacts of this contact pair. + pub fn clear(&mut self) { + self.manifolds.clear(); + self.has_any_active_contact = false; + self.workspace = None; + } + /// Finds the contact with the smallest signed distance. /// /// If the colliders involved in this contact pair are penetrating, then diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index 18900b9..e4ee955 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -377,9 +377,9 @@ impl NarrowPhase { let co_changes: Option<&ColliderChanges> = colliders.get(handle.0); if let Some(co_changes) = co_changes { - if co_changes.needs_narrow_phase_update() { + if !co_changes.needs_narrow_phase_update() { // No flag relevant to the narrow-phase is enabled for this collider. - return; + continue; } if let Some(gid) = self.graph_indices.get(handle.0) { @@ -745,11 +745,13 @@ impl NarrowPhase { if !co_flags1.active_collision_types.test(rb_type1, rb_type2) && !co_flags2.active_collision_types.test(rb_type1, rb_type2) { + edge.weight = false; return; } // Filter based on collision groups. if !co_flags1.collision_groups.test(co_flags2.collision_groups) { + edge.weight = false; return; } @@ -760,6 +762,7 @@ impl NarrowPhase { if !co_flags1.active_collision_types.test(rb_type1, rb_type2) && !co_flags2.active_collision_types.test(rb_type1, rb_type2) { + edge.weight = false; return; } @@ -775,6 +778,7 @@ impl NarrowPhase { if !hooks.filter_intersection_pair(&context) { // No intersection allowed. + edge.weight = false; return; } } @@ -867,11 +871,13 @@ impl NarrowPhase { if !co_flags1.active_collision_types.test(rb_type1, rb_type2) && !co_flags2.active_collision_types.test(rb_type1, rb_type2) { + pair.clear(); return; } // Filter based on collision groups. if !co_flags1.collision_groups.test(co_flags2.collision_groups) { + pair.clear(); return; } @@ -892,6 +898,7 @@ impl NarrowPhase { solver_flags } else { // No contact allowed. + pair.clear(); return; } } else { |
