I’m working on importing USD assets into our software. For handling scene graph instancing, since the prototype prim is generated at runtime, we want its prototype identifier to remain consistent every time the scene is opened.
Is it possible to use the reference path as a stable identifier?
Or is there another recommended way to ensure that the prototype identifier stays unchanged?
I don’t think this question has a good answer, but correct me if I am wrong.
The prototypes are created in a non-deterministic order, there is an env flag that you can use to try and force a specific order and people are using it via this issue but it seems like it isn’t a 100% guaranteed thing and was intended more for debugging.
The issue makes mention of providing some way to figure out what the original dynamic prototype name was, but I don’t know if that was ever provided.
It won’t be perfect, but since USD requires an Arc to instance something, you can make a best guess by comparing all the Arcs on a prim, as well as any variant selections on that Prim, as Prims that have the same Arcs in the same order should in theory be mapped to the same prototype, but I don’t think there is any way to confirm that between reloads of the stage.
I think it’s probably time we deploy a solution for retrieving a unique string from a prototype’s “instance key”, which won’t be pretty or particularly human meaningful, most likely, because the instancing key can get pretty big and complicated. Two caveats:
There are some open bugs we need to decide whether we want to address around additional pieces of prim data that might need to get added to instance keys, and we’d want to address those before providing this functionality so that the strings don’t change when those bugs get fixed.
If anything changes about the composition/population aspects of an instance or set of instances, the strings associated with those instances (and number and names of related prototypes) will change. So these “names” will only be stable if the stage and its referencing structure do not change.