Skip to content

Commit db72d0d

Browse files
kbayescopybara-github
authored andcommitted
Clamp dist in mj_geomDistanceCCD. Closes #2710
PiperOrigin-RevId: 785393424 Change-Id: I508cd2ad6f47ca022cc54f228247ca498fda691f
1 parent c2f5d0f commit db72d0d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/engine/engine_support.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,12 +1303,14 @@ static mjtNum mj_geomDistanceCCD(const mjModel* m, const mjData* d, int g1, int
13031303

13041304
mjtNum dist = mjc_ccd(&config, &status, &obj1, &obj2);
13051305

1306+
// witness points are only computed if dist <= distmax
13061307
if (fromto && status.nx > 0) {
13071308
mju_copy3(fromto, status.x1);
13081309
mju_copy3(fromto+3, status.x2);
13091310
}
13101311

1311-
return dist;
1312+
// clamp dist to distmax as mjc_ccd returns DBL_MAX if dist > distmax
1313+
return dist < distmax ? dist : distmax;
13121314
}
13131315

13141316

0 commit comments

Comments
 (0)