Skip to content

Commit 425985f

Browse files
authored
USD to SDF: Apply rigid body to Model not to Link (#889)
Signed-off-by: ahcorde <ahcorde@gmail.com>
1 parent a905f0c commit 425985f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

usd/src/UsdTestUtils.hh

-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ void CheckInertial(const pxr::UsdPrim &_usdPrim,
224224
}
225225
EXPECT_TRUE(checkedCOM);
226226

227-
EXPECT_EQ(_isRigid, _usdPrim.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
228227
EXPECT_EQ(_isRigid, _usdPrim.HasAPI<pxr::UsdPhysicsMassAPI>());
229228
}
230229
} // namespace testing

usd/src/sdf_parser/Link.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ namespace usd
8585
return errors;
8686
}
8787

88-
if (!pxr::UsdPhysicsRigidBodyAPI::Apply(linkPrim))
88+
if (!pxr::UsdPhysicsRigidBodyAPI::Apply(linkPrim.GetParent()))
8989
{
9090
errors.push_back(UsdError(sdf::usd::UsdErrorCode::FAILED_PRIM_API_APPLY,
91-
"Internal error: unable to mark link at path [" + _path
92-
+ "] as a rigid body, so mass properties won't be attached"));
91+
"Internal error: unable to mark model at path [" +
92+
linkPrim.GetParent().GetPath().GetString() + "] as a rigid body, "
93+
"so mass properties won't be attached"));
9394
return errors;
9495
}
9596

usd/src/sdf_parser/Link_Sdf2Usd_TEST.cc

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ TEST_F(UsdStageFixture, Link)
8282
std::string groundPlanePath = worldPath + "/" + "ground_plane";
8383
auto groundPlane = this->stage->GetPrimAtPath(pxr::SdfPath(groundPlanePath));
8484
ASSERT_TRUE(groundPlane);
85+
EXPECT_FALSE(groundPlane.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
8586
sdf::usd::testing::CheckPrimPose(groundPlane,
8687
ignition::math::Pose3d(
8788
ignition::math::Vector3d(0, 0, -0.125),
@@ -98,6 +99,7 @@ TEST_F(UsdStageFixture, Link)
9899
std::string boxPath = worldPath + "/" + "box";
99100
auto box = this->stage->GetPrimAtPath(pxr::SdfPath(boxPath));
100101
ASSERT_TRUE(box);
102+
EXPECT_TRUE(box.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
101103
sdf::usd::testing::CheckPrimPose(box,
102104
ignition::math::Pose3d(
103105
ignition::math::Vector3d(0, 0, 2.5),
@@ -116,6 +118,7 @@ TEST_F(UsdStageFixture, Link)
116118
std::string cylinderPath = worldPath + "/" + "cylinder";
117119
auto cylinder = this->stage->GetPrimAtPath(pxr::SdfPath(cylinderPath));
118120
ASSERT_TRUE(cylinder);
121+
EXPECT_TRUE(cylinder.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
119122
sdf::usd::testing::CheckPrimPose(cylinder,
120123
ignition::math::Pose3d(
121124
ignition::math::Vector3d(2, 0, 2.5),
@@ -135,6 +138,7 @@ TEST_F(UsdStageFixture, Link)
135138
std::string spherePath = worldPath + "/" + "sphere";
136139
auto sphere = this->stage->GetPrimAtPath(pxr::SdfPath(spherePath));
137140
ASSERT_TRUE(sphere);
141+
EXPECT_TRUE(sphere.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
138142
sdf::usd::testing::CheckPrimPose(sphere,
139143
ignition::math::Pose3d(
140144
ignition::math::Vector3d(4, 0, 2.5),
@@ -153,6 +157,7 @@ TEST_F(UsdStageFixture, Link)
153157
std::string capsulePath = worldPath + "/" + "capsule";
154158
auto capsule = this->stage->GetPrimAtPath(pxr::SdfPath(capsulePath));
155159
ASSERT_TRUE(capsule);
160+
EXPECT_TRUE(capsule.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
156161
sdf::usd::testing::CheckPrimPose(capsule,
157162
ignition::math::Pose3d(
158163
ignition::math::Vector3d(6, 0, 2.5),
@@ -171,6 +176,7 @@ TEST_F(UsdStageFixture, Link)
171176
std::string meshPath = worldPath + "/" + "mesh";
172177
auto mesh = this->stage->GetPrimAtPath(pxr::SdfPath(meshPath));
173178
ASSERT_TRUE(mesh);
179+
EXPECT_TRUE(mesh.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
174180
sdf::usd::testing::CheckPrimPose(mesh,
175181
ignition::math::Pose3d(
176182
ignition::math::Vector3d(8, 0, 2.5),

0 commit comments

Comments
 (0)