Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf/h…
Browse files Browse the repository at this point in the history
…eaderGuard
  • Loading branch information
ahcorde committed Mar 23, 2022
2 parents f9fe0c7 + 425985f commit 5700eb5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
1 change: 0 additions & 1 deletion usd/src/UsdTestUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ void CheckInertial(const pxr::UsdPrim &_usdPrim,
}
EXPECT_TRUE(checkedCOM);

EXPECT_EQ(_isRigid, _usdPrim.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
EXPECT_EQ(_isRigid, _usdPrim.HasAPI<pxr::UsdPhysicsMassAPI>());
}
} // namespace testing
Expand Down
7 changes: 4 additions & 3 deletions usd/src/sdf_parser/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ namespace usd
return errors;
}

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

Expand Down
6 changes: 6 additions & 0 deletions usd/src/sdf_parser/Link_Sdf2Usd_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ TEST_F(UsdStageFixture, Link)
std::string groundPlanePath = worldPath + "/" + "ground_plane";
auto groundPlane = this->stage->GetPrimAtPath(pxr::SdfPath(groundPlanePath));
ASSERT_TRUE(groundPlane);
EXPECT_FALSE(groundPlane.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
sdf::usd::testing::CheckPrimPose(groundPlane,
ignition::math::Pose3d(
ignition::math::Vector3d(0, 0, -0.125),
Expand All @@ -98,6 +99,7 @@ TEST_F(UsdStageFixture, Link)
std::string boxPath = worldPath + "/" + "box";
auto box = this->stage->GetPrimAtPath(pxr::SdfPath(boxPath));
ASSERT_TRUE(box);
EXPECT_TRUE(box.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
sdf::usd::testing::CheckPrimPose(box,
ignition::math::Pose3d(
ignition::math::Vector3d(0, 0, 2.5),
Expand All @@ -116,6 +118,7 @@ TEST_F(UsdStageFixture, Link)
std::string cylinderPath = worldPath + "/" + "cylinder";
auto cylinder = this->stage->GetPrimAtPath(pxr::SdfPath(cylinderPath));
ASSERT_TRUE(cylinder);
EXPECT_TRUE(cylinder.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
sdf::usd::testing::CheckPrimPose(cylinder,
ignition::math::Pose3d(
ignition::math::Vector3d(2, 0, 2.5),
Expand All @@ -135,6 +138,7 @@ TEST_F(UsdStageFixture, Link)
std::string spherePath = worldPath + "/" + "sphere";
auto sphere = this->stage->GetPrimAtPath(pxr::SdfPath(spherePath));
ASSERT_TRUE(sphere);
EXPECT_TRUE(sphere.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
sdf::usd::testing::CheckPrimPose(sphere,
ignition::math::Pose3d(
ignition::math::Vector3d(4, 0, 2.5),
Expand All @@ -153,6 +157,7 @@ TEST_F(UsdStageFixture, Link)
std::string capsulePath = worldPath + "/" + "capsule";
auto capsule = this->stage->GetPrimAtPath(pxr::SdfPath(capsulePath));
ASSERT_TRUE(capsule);
EXPECT_TRUE(capsule.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
sdf::usd::testing::CheckPrimPose(capsule,
ignition::math::Pose3d(
ignition::math::Vector3d(6, 0, 2.5),
Expand All @@ -171,6 +176,7 @@ TEST_F(UsdStageFixture, Link)
std::string meshPath = worldPath + "/" + "mesh";
auto mesh = this->stage->GetPrimAtPath(pxr::SdfPath(meshPath));
ASSERT_TRUE(mesh);
EXPECT_TRUE(mesh.HasAPI<pxr::UsdPhysicsRigidBodyAPI>());
sdf::usd::testing::CheckPrimPose(mesh,
ignition::math::Pose3d(
ignition::math::Vector3d(8, 0, 2.5),
Expand Down
12 changes: 8 additions & 4 deletions usd/src/usd_parser/USDMaterial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ namespace sdf
assetPath(pxr::TfToken("diffuse_texture"), variantShader);
pbrWorkflow.SetAlbedoMap(materialPath.GetAssetPath());
std::string fullAlbedoName =
ignition::common::findFile(materialPath.GetAssetPath());
ignition::common::findFile(ignition::common::basename(
materialPath.GetAssetPath()));
UsdErrors errorCopy = copyFile(
fullAlbedoName, materialPath.GetAssetPath());
if (!errorCopy.empty())
Expand All @@ -160,7 +161,8 @@ namespace sdf
assetPath(pxr::TfToken("normalmap_texture"), variantShader);
pbrWorkflow.SetNormalMap(materialPath.GetAssetPath());
std::string fullNormalName =
ignition::common::findFile(materialPath.GetAssetPath());
ignition::common::findFile(ignition::common::basename(
materialPath.GetAssetPath()));
auto errorCopy = copyFile(fullNormalName,
materialPath.GetAssetPath());
if (!errorCopy.empty())
Expand All @@ -176,7 +178,8 @@ namespace sdf
pxr::TfToken("reflectionroughness_texture"), variantShader);
pbrWorkflow.SetRoughnessMap(materialPath.GetAssetPath());
std::string fullRoughnessName =
ignition::common::findFile(materialPath.GetAssetPath());
ignition::common::findFile(ignition::common::basename(
materialPath.GetAssetPath()));
auto errorCopy = copyFile(
fullRoughnessName, materialPath.GetAssetPath());
if (!errorCopy.empty())
Expand All @@ -192,7 +195,8 @@ namespace sdf
pxr::TfToken("metallic_texture"), variantShader);
pbrWorkflow.SetMetalnessMap(materialPath.GetAssetPath());
std::string fullMetalnessName =
ignition::common::findFile(materialPath.GetAssetPath());
ignition::common::findFile(ignition::common::basename(
materialPath.GetAssetPath()));
auto errorCopy = copyFile(
fullMetalnessName, materialPath.GetAssetPath());
if (!errorCopy.empty())
Expand Down
8 changes: 6 additions & 2 deletions usd/src/usd_parser/USDWorld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ namespace usd
{
UsdErrors errors;
USDData usdData(_inputFileName);
usdData.Init();
usdData.ParseMaterials();
errors = usdData.Init();
if (!errors.empty())
return errors;
errors = usdData.ParseMaterials();
if (!errors.empty())
return errors;

auto reference = pxr::UsdStage::Open(_inputFileName);
if (!reference)
Expand Down
5 changes: 5 additions & 0 deletions usd/src/usd_parser/usd2sdf_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <ignition/common/Filesystem.hh>
#include <ignition/common/TempDirectory.hh>
#include <ignition/common/Util.hh>

#include <ignition/utilities/ExtraTestMacros.hh>

Expand Down Expand Up @@ -74,6 +75,10 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
{
const auto tmp = ignition::common::createTempDirectory("usd",
ignition::common::tempDirectoryPath());

auto systemPaths = ignition::common::systemPaths();
systemPaths->AddFilePaths(ignition::common::joinPaths(
sdf::testing::TestFile("usd"), "materials", "textures"));
// Check a good SDF file
{
const std::string path = sdf::testing::TestFile("usd", "upAxisZ.usda");
Expand Down

0 comments on commit 5700eb5

Please sign in to comment.