Restore legacy center-of-mass computation when exactmeshinertia is false.

PiperOrigin-RevId: 464511268
Change-Id: Ic7c640d01e58dba5049e9fcb2c1b75d6bff4f956
This commit is contained in:
Alessio Quaglino
2022-08-01 05:11:42 -07:00
committed by Copybara-Service
parent 3d77eb1ef4
commit f15bcd04b5
+6 -1
View File
@@ -993,9 +993,14 @@ void mjCMesh::Process() {
// compute and add volume
const double vec[3] = {cen[0]-facecen[0], cen[1]-facecen[1], cen[2]-facecen[2]};
double vol = type==mjSHELL_MESH ? a : mjuu_dot3(vec, nrm) * a / 3;
GetVolumeRef(type) += vol;
// if legacy computation requested, then always positive
if (!model->exactmeshinertia) {
vol = fabs(vol);
}
// add pyramid com
GetVolumeRef(type) += vol;
for (j=0; j<3; j++) {
CoM[j] += vol*(cen[j]*3.0/4.0 + facecen[j]/4.0);
}