Fix authoring type mismatch for geoms sizes attributes.

Fixes wrong sizes being displayed in usdview.
Also introduce a new test to ensure we catch as many of those kinds of errors as possible in the future.

PiperOrigin-RevId: 764388588
Change-Id: Id3c878edd054fe5272c42c9f960c65c850655559
This commit is contained in:
Robin Alazard
2025-05-28 13:19:06 -07:00
committed by Copybara-Service
parent 287f46b220
commit fc69ef1084
4 changed files with 91 additions and 13 deletions
@@ -37,9 +37,11 @@
#include <pxr/usd/sdf/declareHandles.h>
#include <pxr/usd/sdf/fileFormat.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/sdf/schema.h>
#include <pxr/usd/usd/common.h>
#include <pxr/usd/usd/modelAPI.h>
#include <pxr/usd/usd/prim.h>
#include <pxr/usd/usd/primRange.h> // IWYU pragma: keep, used for TraverseAll
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdGeom/capsule.h>
#include <pxr/usd/usdGeom/cube.h>
@@ -450,6 +452,30 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestKindAuthoring) {
pxr::KindTokens->subcomponent);
}
TEST_F(MjcfSdfFileFormatPluginTest, TestAttributesMatchSchemaTypes) {
// TODO(robinalazard): Make the scene much more comprehensive. We ideally want
// to test all the prims that the plugin can generate.
static constexpr char kXml[] = R"(
<mujoco model="test">
<worldbody>
<geom type="plane" name="plane_geom" size="10 20 0.1"/>
<geom type="box" name="box_geom" size="10 20 30"/>
<geom type="sphere" name="sphere_geom" size="10 20 30"/>
<geom type="capsule" name="capsule_geom" size="10 20 30"/>
<geom type="cylinder" name="cylinder_geom" size="10 20 30"/>
<geom type="ellipsoid" name="ellipsoid_geom" size="10 20 30"/>
</worldbody>
</mujoco>
)";
pxr::SdfLayerRefPtr layer = LoadLayer(kXml);
auto stage = pxr::UsdStage::Open(layer);
for (const auto& prim : stage->TraverseAll()) {
ExpectAllAuthoredAttributesMatchSchemaTypes(prim);
}
}
TEST_F(MjcfSdfFileFormatPluginTest, TestGeomsPrims) {
static constexpr char kXml[] = R"(
<mujoco model="test">