diff --git a/pxr/usd/usdUtils/dependencies.cpp b/pxr/usd/usdUtils/dependencies.cpp index adeee98f3b..37b8d6f443 100644 --- a/pxr/usd/usdUtils/dependencies.cpp +++ b/pxr/usd/usdUtils/dependencies.cpp @@ -338,10 +338,16 @@ _FileAnalyzer::_RemapRefOrPayload(const RefOrPayloadType &refOrPayload) void _FileAnalyzer::_ProcessPayloads(const SdfPrimSpecHandle &primSpec) { - SdfPayloadsProxy payloadList = primSpec->GetPayloadList(); - payloadList.ModifyItemEdits(std::bind( - &_FileAnalyzer::_RemapRefOrPayload, - this, std::placeholders::_1)); + if (_remapPathFunc) { + primSpec->GetPayloadList().ModifyItemEdits(std::bind( + &_FileAnalyzer::_RemapRefOrPayload, + this, std::placeholders::_1)); + } else { + for (SdfPayload const& payload: + primSpec->GetPayloadList().GetAddedOrExplicitItems()) { + _ProcessDependency(payload.GetAssetPath(), _DepType::Payload); + } + } } void @@ -529,10 +535,16 @@ _FileAnalyzer::_ProcessMetadata(const SdfPrimSpecHandle &primSpec) void _FileAnalyzer::_ProcessReferences(const SdfPrimSpecHandle &primSpec) { - SdfReferencesProxy refList = primSpec->GetReferenceList(); - refList.ModifyItemEdits(std::bind( - &_FileAnalyzer::_RemapRefOrPayload, - this, std::placeholders::_1)); + if (_remapPathFunc) { + primSpec->GetReferenceList().ModifyItemEdits(std::bind( + &_FileAnalyzer::_RemapRefOrPayload, this, std::placeholders::_1)); + } else { + for (SdfReference const& reference: + primSpec->GetReferenceList().GetAddedOrExplicitItems()) { + _ProcessDependency(reference.GetAssetPath(), _DepType::Reference); + } + } } void diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py index ccf4a03adb..15dc5be6df 100644 --- a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py @@ -22,7 +22,7 @@ # KIND, either express or implied. See the Apache License for the specific # language governing permissions and limitations under the Apache License. from __future__ import print_function -from pxr import UsdUtils +from pxr import UsdUtils, Sdf import argparse, contextlib, sys, os @contextlib.contextmanager @@ -50,6 +50,11 @@ def presult(ostr, fileName, refType, refs): print('Error: cannot access file {}'.format(args.infile), file=sys.stderr) sys.exit(1) + # Open layer and turn off edit permission, to validate that the dependency + # extractor does not require modifying the layer + layer = Sdf.Layer.FindOrOpen(args.infile) + layer.SetPermissionToEdit(False) + sublayers, references, payloads = \ UsdUtils.ExtractExternalReferences(args.infile) with stream(args.outfile, 'w') as ofp: