Fix latent bug in multiccd so that we can never write more contacts than what the buffer space allows.
PiperOrigin-RevId: 958505449 Change-Id: I77cb1142405df5107be46ca0dbef6effc690028d
This commit is contained in:
committed by
Copybara-Service
parent
382af63dc3
commit
0bfa4e984c
@@ -1727,10 +1727,12 @@ static void polygonClip(mjCCDStatus* status, const mjtNum* face1, int nface1,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no pruning needed
|
// no pruning needed (cap to max contacts)
|
||||||
for (int i = 0; i < 3*npolygon; i += 3) {
|
int maxcon = sizeof(status->x2) / (3*sizeof(status->x2[0]));
|
||||||
copy3(status->x2 + i, polygon + i);
|
npolygon = (npolygon < maxcon) ? npolygon : maxcon;
|
||||||
sub3(status->x1 + i, status->x2 + i, dir);
|
for (int i = 0; i < npolygon; i++) {
|
||||||
|
copy3(status->x2 + 3*i, polygon + 3*i);
|
||||||
|
sub3(status->x1 + 3*i, status->x2 + 3*i, dir);
|
||||||
}
|
}
|
||||||
status->nx = npolygon;
|
status->nx = npolygon;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user