diff --git a/src/user/user_mesh.cc b/src/user/user_mesh.cc index c85e3cd9..db09b8fb 100644 --- a/src/user/user_mesh.cc +++ b/src/user/user_mesh.cc @@ -1637,7 +1637,7 @@ void mjCMesh::CheckMesh(mjtGeomInertia type) { if (!processed_) { return; } - if (invalidorientation_.first>=0 || invalidorientation_.second>=0) + if ((invalidorientation_.first>=0 || invalidorientation_.second>=0) && model->exactmeshinertia) throw mjCError(this, "faces of mesh '%s' have inconsistent orientation. Please check the " "faces containing the vertices %d and %d.", diff --git a/test/user/user_mesh_test.cc b/test/user/user_mesh_test.cc index 845dbba6..1eaaa0e1 100644 --- a/test/user/user_mesh_test.cc +++ b/test/user/user_mesh_test.cc @@ -464,19 +464,19 @@ TEST_F(MjCMeshTest, TinyInertiaFails) { "mass and inertia of moving bodies must be larger than mjMINVAL")); } -TEST_F(MjCMeshTest, MalformedFaceFails) { +TEST_F(MjCMeshTest, FlippedFaceAllowedInexactInertia) { const std::string xml_path = GetTestDataFilePath(kMalformedFaceOBJPath); std::array error; mjModel* model = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size()); - EXPECT_THAT(model, testing::IsNull()); - EXPECT_THAT(error.data(), HasSubstr( - "Error: faces of mesh 'malformed_face' have inconsistent orientation. " - "Please check the faces containing the vertices 1 and 2.")); + EXPECT_THAT(model, testing::NotNull()); + EXPECT_THAT(model->nmeshface, 4); + mj_deleteModel(model); } -TEST_F(MjCMeshTest, FlippedFaceFails) { +TEST_F(MjCMeshTest, FlippedFaceFailsExactInertia) { static constexpr char xml[] = R"( +