I’ve been experimenting with custom ArResolverContext
and populating it through CreateDefaultContextForAsset
. This works excellently for any code that opens a usd stage directly from the path.
I noticed in usdview it appeared the top level file reference was not using the resolver context but everything underneath it was. Distilling the code in usdview, I found
layer = Sdf.Layer.FindOrOpen(path)
ctx = Ar.GetResolver().CreateDefaultContextForAsset(path)
stage = Usd.Stage.Open(layer, sessionLayer, ctx, loadSet)
This looks incorrect to me. It also explains why the top level layer does not get the context. Based on what I’ve been learning, I would expect the code to require this structure.
ctx = Ar.GetResolver().CreateDefaultContextForAsset(path)
with Ar.ResolverContextBinder(ctx):
layer = Sdf.Layer.FindOrOpen(path)
stage = Usd.Stage.Open(layer, sessionLayer, ctx, loadSet)
Would the way usdview is currently loading the scene expected to be valid? Would either of these approaches be considered more valid than the other? I’m starting to worry we may be limited with what we can do with CreateDefaultContextForAsset since it seems to get used so inconsistently across existing tools and applications.