feat: add the ability to disable all contacts between two links belonging to the same multibody

This commit is contained in:
Sébastien Crozet
2024-06-02 19:23:36 +02:00
committed by Sébastien Crozet
parent 2041c9549d
commit d9585de20b
2 changed files with 50 additions and 9 deletions

View File

@@ -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;
}
}
}
}
}