Process meshes for computing the correct scaling even when they have flipped faces.
PiperOrigin-RevId: 469414367 Change-Id: Ia5c75b4f2c9fd592c81a1ec659720f9820c0dfbb
This commit is contained in:
committed by
Copybara-Service
parent
abc0a39b7a
commit
83ce236479
+9
-14
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user