Include gap in body_margin, fixing mid-phase pruning of in-gap contacts.

The mid-phase BVH descent filter prunes body pairs using body_margin,
which was compiled as the max over geom margins, excluding gap. Broadphase
and the leaf-level test both use margin+gap, so any multi-geom body relying
on gap could silently lose its in-gap contacts when raw AABBs don't
overlap. Single-geom bodies take the leaf-leaf path and were unaffected.

PiperOrigin-RevId: 946967548
Change-Id: I6d92baa296f1a83be68b4dbfd64a96d1c7efd3c4
This commit is contained in:
Yuval Tassa
2026-07-13 05:04:08 -07:00
committed by Copybara-Service
parent f5f9d9efb7
commit dddb2767c6
7 changed files with 45 additions and 5 deletions
+1 -1
View File
@@ -2780,7 +2780,7 @@ void mjCBody::Compile(void) {
for (int i=0; i < geoms.size(); i++) {
contype |= geoms[i]->contype;
conaffinity |= geoms[i]->conaffinity;
margin = std::max(margin, geoms[i]->margin);
margin = std::max(margin, geoms[i]->margin + geoms[i]->gap);
}
// check conditions for free-joint alignment