Allow meshes with flipped faces if exactmeshinertia is false.
Fixes #1529. PiperOrigin-RevId: 617824308 Change-Id: I926c385475dd79f07e88fe1925ecbb2adb4f8917
This commit is contained in:
committed by
Copybara-Service
parent
624becca52
commit
b0daccc234
@@ -1637,7 +1637,7 @@ void mjCMesh::CheckMesh(mjtGeomInertia type) {
|
|||||||
if (!processed_) {
|
if (!processed_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (invalidorientation_.first>=0 || invalidorientation_.second>=0)
|
if ((invalidorientation_.first>=0 || invalidorientation_.second>=0) && model->exactmeshinertia)
|
||||||
throw mjCError(this,
|
throw mjCError(this,
|
||||||
"faces of mesh '%s' have inconsistent orientation. Please check the "
|
"faces of mesh '%s' have inconsistent orientation. Please check the "
|
||||||
"faces containing the vertices %d and %d.",
|
"faces containing the vertices %d and %d.",
|
||||||
|
|||||||
@@ -464,19 +464,19 @@ TEST_F(MjCMeshTest, TinyInertiaFails) {
|
|||||||
"mass and inertia of moving bodies must be larger than mjMINVAL"));
|
"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);
|
const std::string xml_path = GetTestDataFilePath(kMalformedFaceOBJPath);
|
||||||
std::array<char, 1024> error;
|
std::array<char, 1024> error;
|
||||||
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
|
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
|
||||||
EXPECT_THAT(model, testing::IsNull());
|
EXPECT_THAT(model, testing::NotNull());
|
||||||
EXPECT_THAT(error.data(), HasSubstr(
|
EXPECT_THAT(model->nmeshface, 4);
|
||||||
"Error: faces of mesh 'malformed_face' have inconsistent orientation. "
|
mj_deleteModel(model);
|
||||||
"Please check the faces containing the vertices 1 and 2."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MjCMeshTest, FlippedFaceFails) {
|
TEST_F(MjCMeshTest, FlippedFaceFailsExactInertia) {
|
||||||
static constexpr char xml[] = R"(
|
static constexpr char xml[] = R"(
|
||||||
<mujoco>
|
<mujoco>
|
||||||
|
<compiler exactmeshinertia="true"/>
|
||||||
<asset>
|
<asset>
|
||||||
<mesh name="example_mesh"
|
<mesh name="example_mesh"
|
||||||
vertex="0 0 0 1 0 0 0 1 0 0 0 1"
|
vertex="0 0 0 1 0 0 0 1 0 0 0 1"
|
||||||
|
|||||||
Reference in New Issue
Block a user