Fix bug in cached meshes where convex hull was missing. Previously if a mesh was copied from the cache it would not have its convex hull if the original mesh that was cached didn't previously compute it.
Fixes #2609 PiperOrigin-RevId: 756223337 Change-Id: I54705456636c270607a17340b249047e0df75d0b
This commit is contained in:
committed by
Copybara-Service
parent
6cfea71985
commit
f4774a5449
@@ -65,6 +65,7 @@ GetCachedText(mjCCache& cache, const std::string& model,
|
||||
bool inserted = cache.PopulateData(resource,
|
||||
[&cached_text](const void* data) {
|
||||
cached_text = *(static_cast<const std::string*>(data));
|
||||
return true;
|
||||
});
|
||||
mju_closeResource(resource);
|
||||
mj_deleteVFS(&vfs);
|
||||
|
||||
@@ -42,14 +42,14 @@ static const char* const kDuplicateVerticesPath =
|
||||
"user/testdata/duplicate_vertices.xml";
|
||||
static const char* const kCubePath =
|
||||
"user/testdata/cube.xml";
|
||||
static const char* const kCubeCompletePath =
|
||||
"user/testdata/cube_complete.obj";
|
||||
static const char* const kTorusPath =
|
||||
"user/testdata/torus.xml";
|
||||
static const char* const kTorusMaxhullVertPath =
|
||||
"user/testdata/torus_maxhullvert.xml";
|
||||
static const char* const kTorusDefaultMaxhullVertPath =
|
||||
"user/testdata/torus_maxhullvert_default.xml";
|
||||
static const char* const kTorusShellPath =
|
||||
"user/testdata/torus_shell.xml";
|
||||
static const char* const kCompareInertiaPath =
|
||||
"user/testdata/inertia_compare.xml";
|
||||
static const char* const kConvexInertiaPath =
|
||||
@@ -1207,6 +1207,48 @@ TEST_F(MjCMeshTest, InvalidIndexInFace) {
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
TEST_F(MjCMeshTest, QhullCache) {
|
||||
static constexpr char xml1[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="box" file="cube_complete.obj"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" pos="0 0 2" mesh="box" contype="0" conaffinity="0"/>
|
||||
<geom type="mesh" pos="0 0 0" mesh="box" contype="0" conaffinity="0"/>
|
||||
</worldbody>
|
||||
</mujoco>)";
|
||||
|
||||
static constexpr char xml2[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="box" file="cube_complete.obj"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" pos="0 0 2" mesh="box"/>
|
||||
<geom type="mesh" pos="0 0 0" mesh="box"/>
|
||||
</worldbody>
|
||||
</mujoco>)";
|
||||
|
||||
mjVFS vfs;
|
||||
mj_defaultVFS(&vfs);
|
||||
mj_addFileVFS(&vfs, "", GetTestDataFilePath(kCubeCompletePath).c_str());
|
||||
|
||||
std::array<char, 1000> error;
|
||||
mjModel* model = LoadModelFromString(xml1, error.data(), error.size(), &vfs);
|
||||
ASSERT_THAT(model, NotNull()) << "Failed to load model: " << error.data();
|
||||
EXPECT_THAT(model->mesh_graphadr[0], -1);
|
||||
|
||||
mj_deleteModel(model);
|
||||
|
||||
model = LoadModelFromString(xml2, error.data(), error.size(), &vfs);
|
||||
ASSERT_THAT(model, NotNull()) << "Failed to load model: " << error.data();
|
||||
EXPECT_GT(model->mesh_graphadr[0], -1);
|
||||
|
||||
mj_deleteModel(model);
|
||||
mj_deleteVFS(&vfs);
|
||||
}
|
||||
|
||||
TEST_F(MjCMeshTest, LoadSkin) {
|
||||
const std::string xml_path = GetTestDataFilePath(kCubeSkinPath);
|
||||
std::array<char, 1024> error;
|
||||
|
||||
Reference in New Issue
Block a user