Apply articulation API to the correct body when converting to USD.

PiperOrigin-RevId: 776206773
Change-Id: I84b5687a9900b42fd208124414ac98feaaa9f8c4
This commit is contained in:
Sam Haves
2025-06-26 11:06:07 -07:00
committed by Copybara-Service
parent 1e319aebed
commit 24789f8fe5
2 changed files with 29 additions and 14 deletions
@@ -1821,6 +1821,17 @@ class ModelWriter {
: pxr::KindTokens->subcomponent;
SetPrimKind(data_, body_path, kind);
// If the parent is not the world body, but is child of the world body
// then we need to apply the articulation root API.
if (parent_id != kWorldIndex) {
int parent_parent_id =
mjs_getId(mjs_getParent(parent->element)->element);
if (parent_parent_id == kWorldIndex) {
ApplyApiSchema(data_, parent_path,
pxr::UsdPhysicsTokens->PhysicsArticulationRootAPI);
}
}
// Apply the PhysicsRigidBodyAPI schema if we are writing physics.
if (write_physics_) {
// If the body had a mass specified then it must have either inertia or
@@ -1926,13 +1937,6 @@ class ModelWriter {
pxr::UsdGeomTokens->Xform);
SetPrimKind(data_, world_group_path, pxr::KindTokens->group);
if (write_physics_) {
// Apply the PhysicsArticulationRootAPI to the world body so that
// everything under it is automatically considered an articulation.
ApplyApiSchema(data_, world_group_path,
pxr::UsdPhysicsTokens->PhysicsArticulationRootAPI);
}
return world_group_path;
}
};