Change private->public spec for error checking in mjCSkin recompilation.
Fixes #2485. PiperOrigin-RevId: 735323174 Change-Id: Ifcc2055f6a74afaa18ad5228633f36f760adcffd
This commit is contained in:
committed by
Copybara-Service
parent
4d024f9421
commit
adc3cc06fa
+9
-10
@@ -2526,16 +2526,15 @@ void mjCSkin::Compile(const mjVFS* vfs) {
|
|||||||
// load file
|
// load file
|
||||||
if (!file_.empty()) {
|
if (!file_.empty()) {
|
||||||
// make sure data is not present
|
// make sure data is not present
|
||||||
if (!vert_.empty() ||
|
if (!spec_vert_.empty() ||
|
||||||
!texcoord_.empty() ||
|
!spec_texcoord_.empty() ||
|
||||||
!face_.empty() ||
|
!spec_face_.empty() ||
|
||||||
!bodyname_.empty() ||
|
!spec_bodyname_.empty() ||
|
||||||
!bindpos_.empty() ||
|
!spec_bindpos_.empty() ||
|
||||||
!bindquat_.empty() ||
|
!spec_bindquat_.empty() ||
|
||||||
!vertid_.empty() ||
|
!spec_vertid_.empty() ||
|
||||||
!vertweight_.empty() ||
|
!spec_vertweight_.empty()) {
|
||||||
!bodyid.empty()) {
|
throw mjCError(this, "Both skin data and file were specified: %s", file_.c_str());
|
||||||
throw mjCError(this, "Data already exists, trying to load from skin file: %s", file_.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove path from file if necessary
|
// remove path from file if necessary
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<mujoco>
|
||||||
|
<asset>
|
||||||
|
<mesh name="cube" file="cube.stl" scale=".05 .05 .05"/>
|
||||||
|
<skin name="skin" file="cube.skn"/>
|
||||||
|
</asset>
|
||||||
|
|
||||||
|
<worldbody>
|
||||||
|
<body name="box">
|
||||||
|
<geom type="box" mesh="cube"/>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</worldbody>
|
||||||
|
</mujoco>
|
||||||
@@ -66,6 +66,8 @@ static const char* const kDuplicateOBJPath =
|
|||||||
"user/testdata/duplicate.xml";
|
"user/testdata/duplicate.xml";
|
||||||
static const char* const kMalformedFaceOBJPath =
|
static const char* const kMalformedFaceOBJPath =
|
||||||
"user/testdata/malformed_face.xml";
|
"user/testdata/malformed_face.xml";
|
||||||
|
static const char* const kCubeSkinPath =
|
||||||
|
"user/testdata/cube_skin.xml";
|
||||||
|
|
||||||
using ::testing::ElementsAre;
|
using ::testing::ElementsAre;
|
||||||
using ::testing::HasSubstr;
|
using ::testing::HasSubstr;
|
||||||
@@ -1184,6 +1186,19 @@ TEST_F(MjCMeshTest, InvalidIndexInFace) {
|
|||||||
mj_deleteModel(model);
|
mj_deleteModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MjCMeshTest, LoadSkin) {
|
||||||
|
const std::string xml_path = GetTestDataFilePath(kCubeSkinPath);
|
||||||
|
std::array<char, 1024> error;
|
||||||
|
mjSpec* spec = mj_parseXML(xml_path.c_str(), 0, error.data(), error.size());
|
||||||
|
EXPECT_THAT(spec, NotNull()) << error.data();
|
||||||
|
mjModel* m1 = mj_compile(spec, 0);
|
||||||
|
EXPECT_THAT(m1, NotNull());
|
||||||
|
mj_deleteModel(m1);
|
||||||
|
mjModel* m2 = mj_compile(spec, 0);
|
||||||
|
EXPECT_THAT(m2, NotNull());
|
||||||
|
mj_deleteModel(m2);
|
||||||
|
mj_deleteSpec(spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user