From c943797591fc5481889096e07a98bed89954d570 Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Mon, 17 Apr 2023 10:29:36 -0700 Subject: [PATCH] Make `shellinertia` ignore `exactmeshinertia`, which is only used for legacy volume computations. Fixes #759. PiperOrigin-RevId: 524884880 Change-Id: Ia5b64ee33802866f792cdad4acfec6d9baf2a9e9 --- src/user/user_mesh.cc | 4 ++-- src/user/user_objects.cc | 2 +- test/user/testdata/inertia_shell.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 @@ - +