Skip to content

Commit a905f0c

Browse files
authored
USD to SDF: Returned errors in USDWorld (#896)
Signed-off-by: ahcorde <ahcorde@gmail.com>
1 parent 0eea69f commit a905f0c

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

usd/src/usd_parser/USDMaterial.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ namespace sdf
144144
assetPath(pxr::TfToken("diffuse_texture"), variantShader);
145145
pbrWorkflow.SetAlbedoMap(materialPath.GetAssetPath());
146146
std::string fullAlbedoName =
147-
ignition::common::findFile(materialPath.GetAssetPath());
147+
ignition::common::findFile(ignition::common::basename(
148+
materialPath.GetAssetPath()));
148149
UsdErrors errorCopy = copyFile(
149150
fullAlbedoName, materialPath.GetAssetPath());
150151
if (!errorCopy.empty())
@@ -160,7 +161,8 @@ namespace sdf
160161
assetPath(pxr::TfToken("normalmap_texture"), variantShader);
161162
pbrWorkflow.SetNormalMap(materialPath.GetAssetPath());
162163
std::string fullNormalName =
163-
ignition::common::findFile(materialPath.GetAssetPath());
164+
ignition::common::findFile(ignition::common::basename(
165+
materialPath.GetAssetPath()));
164166
auto errorCopy = copyFile(fullNormalName,
165167
materialPath.GetAssetPath());
166168
if (!errorCopy.empty())
@@ -176,7 +178,8 @@ namespace sdf
176178
pxr::TfToken("reflectionroughness_texture"), variantShader);
177179
pbrWorkflow.SetRoughnessMap(materialPath.GetAssetPath());
178180
std::string fullRoughnessName =
179-
ignition::common::findFile(materialPath.GetAssetPath());
181+
ignition::common::findFile(ignition::common::basename(
182+
materialPath.GetAssetPath()));
180183
auto errorCopy = copyFile(
181184
fullRoughnessName, materialPath.GetAssetPath());
182185
if (!errorCopy.empty())
@@ -192,7 +195,8 @@ namespace sdf
192195
pxr::TfToken("metallic_texture"), variantShader);
193196
pbrWorkflow.SetMetalnessMap(materialPath.GetAssetPath());
194197
std::string fullMetalnessName =
195-
ignition::common::findFile(materialPath.GetAssetPath());
198+
ignition::common::findFile(ignition::common::basename(
199+
materialPath.GetAssetPath()));
196200
auto errorCopy = copyFile(
197201
fullMetalnessName, materialPath.GetAssetPath());
198202
if (!errorCopy.empty())

usd/src/usd_parser/USDWorld.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ namespace usd
4242
{
4343
UsdErrors errors;
4444
USDData usdData(_inputFileName);
45-
usdData.Init();
46-
usdData.ParseMaterials();
45+
errors = usdData.Init();
46+
if (!errors.empty())
47+
return errors;
48+
errors = usdData.ParseMaterials();
49+
if (!errors.empty())
50+
return errors;
4751

4852
auto reference = pxr::UsdStage::Open(_inputFileName);
4953
if (!reference)

usd/src/usd_parser/usd2sdf_TEST.cc

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <ignition/common/Filesystem.hh>
2222
#include <ignition/common/TempDirectory.hh>
23+
#include <ignition/common/Util.hh>
2324

2425
#include <ignition/utilities/ExtraTestMacros.hh>
2526

@@ -74,6 +75,10 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
7475
{
7576
const auto tmp = ignition::common::createTempDirectory("usd",
7677
ignition::common::tempDirectoryPath());
78+
79+
auto systemPaths = ignition::common::systemPaths();
80+
systemPaths->AddFilePaths(ignition::common::joinPaths(
81+
sdf::testing::TestFile("usd"), "materials", "textures"));
7782
// Check a good SDF file
7883
{
7984
const std::string path = sdf::testing::TestFile("usd", "upAxisZ.usda");

0 commit comments

Comments
 (0)