Loading...
Searching...
No Matches
dependencies.h File Reference

Utilities for the following tasks that require consideration of a USD asset's external dependencies: More...

+ Include dependency graph for dependencies.h:

Go to the source code of this file.

Typedefs

using UsdUtilsModifyAssetPathFn = std::function< std::string(const std::string &assetPath)>
 Callback that is used to modify asset paths in a layer.
 

Functions

USDUTILS_API void UsdUtilsExtractExternalReferences (const std::string &filePath, std::vector< std::string > *subLayers, std::vector< std::string > *references, std::vector< std::string > *payloads)
 Parses the file at filePath, identifying external references, and sorting them into separate type-based buckets.
 
USDUTILS_API bool UsdUtilsComputeAllDependencies (const SdfAssetPath &assetPath, std::vector< SdfLayerRefPtr > *layers, std::vector< std::string > *assets, std::vector< std::string > *unresolvedPaths, const std::function< UsdUtilsProcessingFunc > &processingFunc=std::function< UsdUtilsProcessingFunc >())
 Recursively computes all the dependencies of the given asset and populates layers with all the dependencies that can be opened as an SdfLayer.
 
USDUTILS_API void UsdUtilsModifyAssetPaths (const SdfLayerHandle &layer, const UsdUtilsModifyAssetPathFn &modifyFn)
 Helper function that visits every asset path in layer, calls modifyFn and replaces the value with the return value of modifyFn.
 

Detailed Description

Utilities for the following tasks that require consideration of a USD asset's external dependencies:

  • extracting asset dependencies from a USD file.
  • creating a USDZ package containing a given asset and all of its external dependencies.
  • some time in the future, localize a given asset and all of its dependencies into a specified directory.

Definition in file dependencies.h.

Typedef Documentation

◆ UsdUtilsModifyAssetPathFn

using UsdUtilsModifyAssetPathFn = std::function<std::string( const std::string& assetPath)>

Callback that is used to modify asset paths in a layer.

The assetPath will contain the string value that's authored. The returned value is the new value that should be authored in the layer. If the function returns an empty string, that value will be removed from the layer.

Definition at line 97 of file dependencies.h.

Function Documentation

◆ UsdUtilsComputeAllDependencies()

USDUTILS_API bool UsdUtilsComputeAllDependencies ( const SdfAssetPath assetPath,
std::vector< SdfLayerRefPtr > *  layers,
std::vector< std::string > *  assets,
std::vector< std::string > *  unresolvedPaths,
const std::function< UsdUtilsProcessingFunc > &  processingFunc = std::function< UsdUtilsProcessingFunc >() 
)

Recursively computes all the dependencies of the given asset and populates layers with all the dependencies that can be opened as an SdfLayer.

All of the resolved non-layer dependencies are populated in assets. Any unresolved (layer and non-layer) asset paths are populated in unresolvedPaths.

If a function is provided for the processingFunc parameter, it will be invoked on every asset path that is discovered during localization.
Refer to UsdUtilsDependencyInfo for general information on User processing functions. Any changes made to the paths during the invocation of this function will not be written to processed layers.

The input vectors to be populated with the results are cleared before any results are added to them.

Returns true if the given asset was resolved correctly.

◆ UsdUtilsExtractExternalReferences()

USDUTILS_API void UsdUtilsExtractExternalReferences ( const std::string &  filePath,
std::vector< std::string > *  subLayers,
std::vector< std::string > *  references,
std::vector< std::string > *  payloads 
)

Parses the file at filePath, identifying external references, and sorting them into separate type-based buckets.

Sublayers are returned in the sublayers vector, references, whether prim references, value clip references or values from asset path attributes, are returned in the references vector. Payload paths are returned in payloads.

Note
No recursive chasing of dependencies is performed; that is the client's responsibility, if desired.
Not all returned references are actually authored explicitly in the layer. For example, templated clip asset paths are resolved and expanded to include all available clip files that match the specified pattern.

◆ UsdUtilsModifyAssetPaths()

USDUTILS_API void UsdUtilsModifyAssetPaths ( const SdfLayerHandle &  layer,
const UsdUtilsModifyAssetPathFn modifyFn 
)

Helper function that visits every asset path in layer, calls modifyFn and replaces the value with the return value of modifyFn.

This modifies layer in place.

This can be useful in preparing a layer for consumption in contexts that do not have access to the ArResolver for which the layer's asset paths were authored: we can replace all paths with their fully resolved equivalents, for example.