string SdfComputeAssetPathRelativeToLayer( const SdfLayerHandle& anchor, const string& assetPath) { if (not anchor) { TF_CODING_ERROR("Invalid anchor layer"); return string(); } if (assetPath.empty()) { TF_CODING_ERROR("Layer path is empty"); return string(); } TRACE_FUNCTION(); ArResolver& resolver = ArGetResolver(); // Relative paths are resolved using the look-here-first scheme, in // which we first look relative to the layer, then fall back to search // path resolution. string finalLayerPath = anchor->ComputeAbsolutePath(assetPath); if (not SdfLayer::IsAnonymousLayerIdentifier(finalLayerPath)) { if (resolver.IsSearchPath(assetPath) and resolver.Resolve(finalLayerPath).empty()) return assetPath; } return finalLayerPath; }