From fa16cf8c52d39106874b01bf915106d476bca808 Mon Sep 17 00:00:00 2001 From: Dan McGarry Date: Tue, 16 Mar 2021 13:22:56 -0700 Subject: [PATCH 1/3] Explicitly cast Ar file path string to an ArResolvedPath This was throwing errors when built against the latest version of USD. File path strings are explicitly cast elsewhere in the USD code, updating this one to follow suit. --- lib/usd/translators/shading/usdUVTextureReader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/usd/translators/shading/usdUVTextureReader.cpp b/lib/usd/translators/shading/usdUVTextureReader.cpp index 7386c85415..727952c2b6 100644 --- a/lib/usd/translators/shading/usdUVTextureReader.cpp +++ b/lib/usd/translators/shading/usdUVTextureReader.cpp @@ -266,7 +266,8 @@ bool PxrMayaUsdUVTexture_Reader::Read(UsdMayaPrimReaderContext* context) && !filePath.empty() && ArIsPackageRelativePath(filePath)) { // NOTE: (yliangsiew) Package-relatve path means that we are inside of a USDZ file. ArResolver& arResolver = ArGetResolver(); // NOTE: (yliangsiew) This is cached. - std::shared_ptr assetPtr = arResolver.OpenAsset(filePath); + std::shared_ptr assetPtr = arResolver.OpenAsset( + ArResolvedPath(filePath)); if (assetPtr == nullptr) { TF_WARN( "The file: %s could not be found within the USDZ archive for extraction.", From 53fdb5e1d3a356f37d5f8c7ccaea9f825e4af3a7 Mon Sep 17 00:00:00 2001 From: Dan McGarry Date: Tue, 16 Mar 2021 13:26:16 -0700 Subject: [PATCH 2/3] Explicitly cast path string to ArResolvedPath This throws an error when built against the latest USD. File path strings are being explicitly cast to ArResolvedPath objects when passed to ArResolver::OpenAsset elsewhere. Updating this call to follow this pattern. --- lib/usd/translators/shading/usdUVTextureReader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/usd/translators/shading/usdUVTextureReader.cpp b/lib/usd/translators/shading/usdUVTextureReader.cpp index 727952c2b6..e0fe2edd2a 100644 --- a/lib/usd/translators/shading/usdUVTextureReader.cpp +++ b/lib/usd/translators/shading/usdUVTextureReader.cpp @@ -266,8 +266,7 @@ bool PxrMayaUsdUVTexture_Reader::Read(UsdMayaPrimReaderContext* context) && !filePath.empty() && ArIsPackageRelativePath(filePath)) { // NOTE: (yliangsiew) Package-relatve path means that we are inside of a USDZ file. ArResolver& arResolver = ArGetResolver(); // NOTE: (yliangsiew) This is cached. - std::shared_ptr assetPtr = arResolver.OpenAsset( - ArResolvedPath(filePath)); + std::shared_ptr assetPtr = arResolver.OpenAsset(ArResolvedPath(filePath)); if (assetPtr == nullptr) { TF_WARN( "The file: %s could not be found within the USDZ archive for extraction.", From 294110cf97c9e3708f462bf77a270ca2583836b4 Mon Sep 17 00:00:00 2001 From: Dan McGarry Date: Thu, 18 Mar 2021 09:11:35 -0700 Subject: [PATCH 3/3] Check PXR_VERSION before attempting to use new API ArResolver::OpenAsset takes an ArResolvedPath in versions after 20.11. Add a version check when calling this function and passing an std::string and explicitly cast to an ArResolvedPath instead. --- lib/usd/translators/shading/usdUVTextureReader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/usd/translators/shading/usdUVTextureReader.cpp b/lib/usd/translators/shading/usdUVTextureReader.cpp index e0fe2edd2a..d1c4d8ef32 100644 --- a/lib/usd/translators/shading/usdUVTextureReader.cpp +++ b/lib/usd/translators/shading/usdUVTextureReader.cpp @@ -266,7 +266,12 @@ bool PxrMayaUsdUVTexture_Reader::Read(UsdMayaPrimReaderContext* context) && !filePath.empty() && ArIsPackageRelativePath(filePath)) { // NOTE: (yliangsiew) Package-relatve path means that we are inside of a USDZ file. ArResolver& arResolver = ArGetResolver(); // NOTE: (yliangsiew) This is cached. +#if PXR_VERSION > 2011 std::shared_ptr assetPtr = arResolver.OpenAsset(ArResolvedPath(filePath)); +#else + std::shared_ptr assetPtr = arResolver.OpenAsset(filePath); +#endif + if (assetPtr == nullptr) { TF_WARN( "The file: %s could not be found within the USDZ archive for extraction.",