diff --git a/src/user/user_mesh.cc b/src/user/user_mesh.cc index f1a701ee..a921b4cb 100644 --- a/src/user/user_mesh.cc +++ b/src/user/user_mesh.cc @@ -1047,7 +1047,7 @@ void mjCMesh::Process() { double vol = type==mjSHELL_MESH ? a : mjuu_dot3(vec, nrm) * a / 3; // if legacy computation requested, then always positive - if (!model->exactmeshinertia) { + if (!model->exactmeshinertia && type==mjVOLUME_MESH) { vol = fabs(vol); } @@ -1093,7 +1093,7 @@ void mjCMesh::Process() { double vol = type==mjSHELL_MESH ? a : mjuu_dot3(cen, nrm) * a / 3; // if legacy computation requested, then always positive - if (!model->exactmeshinertia) { + if (!model->exactmeshinertia && type==mjVOLUME_MESH) { vol = fabs(vol); } diff --git a/src/user/user_objects.cc b/src/user/user_objects.cc index 46290d36..8fc1a200 100644 --- a/src/user/user_objects.cc +++ b/src/user/user_objects.cc @@ -1201,7 +1201,7 @@ double mjCGeom::GetVolume(void) { } mjCMesh* pmesh = model->meshes[meshid]; - if (model->exactmeshinertia) { + if (model->exactmeshinertia || typeinertia==mjSHELL_MESH) { return pmesh->GetVolumeRef(typeinertia); } else { return pmesh->boxsz_volume[0]*pmesh->boxsz_volume[1]*pmesh->boxsz_volume[2]*8; diff --git a/test/user/testdata/inertia_shell.xml b/test/user/testdata/inertia_shell.xml index 2b26a2cb..f64141aa 100644 --- a/test/user/testdata/inertia_shell.xml +++ b/test/user/testdata/inertia_shell.xml @@ -1,5 +1,5 @@ - +