Process meshes for computing the correct scaling even when they have flipped faces.

PiperOrigin-RevId: 469414367
Change-Id: Ia5c75b4f2c9fd592c81a1ec659720f9820c0dfbb
This commit is contained in:
Alessio Quaglino
2022-08-23 03:29:08 -07:00
committed by Copybara-Service
parent abc0a39b7a
commit 83ce236479
3 changed files with 23 additions and 14 deletions
+9 -14
View File
@@ -86,6 +86,7 @@ mjCMesh::mjCMesh(mjCModel* _model, mjCDef* _def) {
validvolume = true;
valideigenvalue = true;
validinequality = true;
processed = false;
// reset to default if given
if (_def) {
@@ -254,9 +255,8 @@ void mjCMesh::Compile(const mjVFS* vfs) {
}
// scale, center, orient, compute mass and inertia
if (validorientation) {
Process();
}
Process();
processed = true;
}
@@ -1165,6 +1165,9 @@ void mjCMesh::Process() {
// check that the mesh is valid
void mjCMesh::CheckMesh() {
if (!processed) {
return;
}
if (!validorientation)
throw mjCError(this, "faces have inconsistent orientation: %s", name.c_str());
if (!validarea)
@@ -1178,24 +1181,16 @@ void mjCMesh::CheckMesh() {
}
// compute inertia
// get inertia pointer
double* mjCMesh::GetInertiaBoxPtr(mjtMeshType type) {
CheckMesh();
if (type==mjSHELL_MESH) {
return boxsz_surface;
} else {
return boxsz_volume;
}
return type==mjSHELL_MESH ? boxsz_surface : boxsz_volume;
}
double& mjCMesh::GetVolumeRef(mjtMeshType type) {
CheckMesh();
if (type) {
return surface;
} else {
return volume;
}
return type==mjSHELL_MESH ? surface : volume;
}
+1
View File
@@ -491,6 +491,7 @@ class mjCMesh: public mjCBase {
bool validvolume; // false if the volume is too small
bool valideigenvalue; // false if inertia eigenvalue is too small
bool validinequality; // false if inertia inequality is not satisfied
bool processed; // false if the mesh has not been processed yet
// mesh properties computed by Compile
double pos_volume[3]; // CoM position