Move OBJ handling to a mjpDecoder.

PiperOrigin-RevId: 875194599
Change-Id: I2cccc683d69a217f1817e70d16bc1815e366d00c
This commit is contained in:
Sam Haves
2026-02-25 09:11:54 -08:00
committed by Copybara-Service
parent abdea379af
commit b907ffedaa
12 changed files with 258 additions and 109 deletions
+20 -3
View File
@@ -12,7 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
mujoco_test(user_model_test ADDITIONAL_LINK_LIBRARIES absl::str_format)
mujoco_test(
user_model_test
PROPERTIES
ENVIRONMENT
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
ADDITIONAL_LINK_LIBRARIES absl::str_format
)
mujoco_test(user_objects_test)
@@ -23,9 +29,20 @@ mujoco_test(
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:elasticity>"
)
mujoco_test(user_flex_test)
mujoco_test(
user_flex_test
PROPERTIES
ENVIRONMENT
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
)
mujoco_test(user_mesh_test ADDITIONAL_LINK_LIBRARIES absl::str_format)
mujoco_test(
user_mesh_test
PROPERTIES
ENVIRONMENT
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
ADDITIONAL_LINK_LIBRARIES absl::str_format
)
mujoco_test(user_composite_test)
+6 -3
View File
@@ -71,6 +71,9 @@ static const char* const kMalformedFaceOBJPath =
static const char* const kCubeSkinPath =
"user/testdata/cube_skin.xml";
static const char* const kNoDecoderForMeshErrorMsh =
"no decoder found for mesh";
using ::testing::ElementsAre;
using ::testing::HasSubstr;
using ::testing::IsNull;
@@ -110,7 +113,7 @@ TEST_F(MjCMeshTest, UnknownMeshFormat) {
LoadModelFromString(xml.c_str(), error.data(), error.size(), &vfs);
ASSERT_THAT(model, testing::IsNull())
<< "Should fail to load a mesh named: " << name;
EXPECT_THAT(error.data(), HasSubstr("unknown or unsupported mesh file: "));
EXPECT_THAT(error.data(), HasSubstr(kNoDecoderForMeshErrorMsh));
EXPECT_THAT(error.data(), HasSubstr(name));
}
@@ -300,7 +303,7 @@ TEST_F(MjCMeshTest, LoadMSHWithContentTypeError) {
// should error with unknown file type
mjModel* model = LoadModelFromString(xml, error, error_sz, &vfs);
EXPECT_THAT(model, IsNull());
EXPECT_THAT(error, HasSubstr("unsupported mesh type: 'model/unknown'"));
EXPECT_THAT(error, HasSubstr(kNoDecoderForMeshErrorMsh));
mj_deleteVFS(&vfs);
}
@@ -327,7 +330,7 @@ TEST_F(MjCMeshTest, LoadMSHWithInvalidContentType) {
// should error with unknown file type
mjModel* model = LoadModelFromString(xml, error, error_sz, &vfs);
EXPECT_THAT(model, IsNull());
EXPECT_THAT(error, HasSubstr("invalid content type: 'model'"));
EXPECT_THAT(error, HasSubstr(kNoDecoderForMeshErrorMsh));
mj_deleteVFS(&vfs);
}
+6 -1
View File
@@ -14,7 +14,12 @@
mujoco_test(xml_api_test)
mujoco_test(xml_native_reader_test)
mujoco_test(
xml_native_reader_test
PROPERTIES
ENVIRONMENT
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:obj_decoder>"
)
mujoco_test(xml_utils_test)