Fix the parsing of USD scenes that use ResetXformStack
Also add a new test for it PiperOrigin-RevId: 778114814 Change-Id: Ib019768ac45ecf7ec6d437199a3d1427557b2f06
This commit is contained in:
committed by
Copybara-Service
parent
50de1b3c2c
commit
072b327430
@@ -63,7 +63,6 @@
|
|||||||
#include <pxr/usd/usdPhysics/revoluteJoint.h>
|
#include <pxr/usd/usdPhysics/revoluteJoint.h>
|
||||||
#include <pxr/usd/usdPhysics/rigidBodyAPI.h>
|
#include <pxr/usd/usdPhysics/rigidBodyAPI.h>
|
||||||
#include <pxr/usd/usdPhysics/scene.h>
|
#include <pxr/usd/usdPhysics/scene.h>
|
||||||
#include <pxr/usd/usdPhysics/sphericalJoint.h>
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using pxr::MjcPhysicsTokens;
|
using pxr::MjcPhysicsTokens;
|
||||||
@@ -1350,7 +1349,7 @@ void ParseCurrentAndDescendants(mjSpec* spec, const pxr::UsdPrim& prim,
|
|||||||
if (child.HasAPI<pxr::UsdPhysicsRigidBodyAPI>()) {
|
if (child.HasAPI<pxr::UsdPhysicsRigidBodyAPI>()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (xform_cache.GetResetXformStack(prim)) {
|
if (xform_cache.GetResetXformStack(child)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ParseCurrentAndDescendants(spec, child, prim, body, xform_cache);
|
ParseCurrentAndDescendants(spec, child, prim, body, xform_cache);
|
||||||
@@ -1458,12 +1457,15 @@ pxr::UsdPrim GetNestingBodyPrim(const pxr::UsdPrim& prim,
|
|||||||
}
|
}
|
||||||
pxr::UsdPrim previous_prim = prim.GetParent();
|
pxr::UsdPrim previous_prim = prim.GetParent();
|
||||||
while (previous_prim.IsValid()) {
|
while (previous_prim.IsValid()) {
|
||||||
if (xform_cache.GetResetXformStack(previous_prim)) {
|
// If we find a rigid body, this is our answer. The prim is nested.
|
||||||
return pxr::UsdPrim();
|
|
||||||
}
|
|
||||||
if (previous_prim.HasAPI<pxr::UsdPhysicsRigidBodyAPI>()) {
|
if (previous_prim.HasAPI<pxr::UsdPhysicsRigidBodyAPI>()) {
|
||||||
return previous_prim;
|
return previous_prim;
|
||||||
}
|
}
|
||||||
|
// If we encounter a prim that resets the transform stack *before* finding
|
||||||
|
// a rigid body, the chain is broken. The prim is not nested.
|
||||||
|
if (xform_cache.GetResetXformStack(previous_prim)) {
|
||||||
|
return pxr::UsdPrim();
|
||||||
|
}
|
||||||
previous_prim = previous_prim.GetParent();
|
previous_prim = previous_prim.GetParent();
|
||||||
}
|
}
|
||||||
return pxr::UsdPrim();
|
return pxr::UsdPrim();
|
||||||
|
|||||||
Reference in New Issue
Block a user