aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2024-06-02 19:23:36 +0200
committerSébastien Crozet <sebastien@crozet.re>2024-06-09 12:09:58 +0200
commitd9585de20bc158006e4669c251d5d8b3edfbf188 (patch)
tree292ed7d9ee0bf379fda6d69f0641a88819234187 /src/geometry
parent2041c9549dcc805ff5f7e9dd0bf648519f138348 (diff)
downloadrapier-d9585de20bc158006e4669c251d5d8b3edfbf188.tar.gz
rapier-d9585de20bc158006e4669c251d5d8b3edfbf188.tar.bz2
rapier-d9585de20bc158006e4669c251d5d8b3edfbf188.zip
feat: add the ability to disable all contacts between two links belonging to the same multibody
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/narrow_phase.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs
index 1eddd73..717fa25 100644
--- a/src/geometry/narrow_phase.rs
+++ b/src/geometry/narrow_phase.rs
@@ -835,12 +835,30 @@ impl NarrowPhase {
}
}
- if let Some((_, _, mb_link)) =
- multibody_joints.joint_between(co_parent1.handle, co_parent2.handle)
- {
- if !mb_link.joint.data.contacts_enabled {
- pair.clear();
- break 'emit_events;
+ let link1 = multibody_joints.rigid_body_link(co_parent1.handle);
+ let link2 = multibody_joints.rigid_body_link(co_parent2.handle);
+
+ if let (Some(link1),Some(link2)) = (link1, link2) {
+ // If both bodies belong to the same multibody, apply some additional built-in
+ // contact filtering rules.
+ if link1.multibody == link2.multibody {
+ // 1) check if self-contacts is enabled.
+ if let Some(mb) = multibody_joints.get_multibody(link1.multibody) {
+ if !mb.self_contacts_enabled() {
+ pair.clear();
+ break 'emit_events;
+ }
+ }
+
+ // 2) if they are attached by a joint, check if contacts is disabled.
+ if let Some((_, _, mb_link)) =
+ multibody_joints.joint_between(co_parent1.handle, co_parent2.handle)
+ {
+ if !mb_link.joint.data.contacts_enabled {
+ pair.clear();
+ break 'emit_events;
+ }
+ }
}
}
}