I am currently working on a bespoke USD importer for my pipeline and attempting to leverage bits of the USD importer code provided by Epic. Specifically, the UsdStageImportOptions combined with an AssetImportTask. I only want to leverage the geometry import aspects of it. I have noticed that the StaticMesh produced by the importer will point at a single USD stage but have various bits of metadata in a USD Mesh Asset User Data object on the StaticMesh. This seems to hold various prim paths and other information (such as variant choices).
The problem I am running into is that if I want to properly share assets between different stages that I import, identical meshes will be set as different StaticMesh when they theoretically should be re-used since I have that option set in the importer. I am not sure if it’s because the source USD files are different even though they reference the same source USD layer that contains the Mesh.
For example, I have Stage A which references Stage B and makes a variant choice on Prim A. If I use the importer on both Stage A and on Stage B, I get two different StaticMesh when it should be the same re-used asset. It could also be due to the variant being set explicity to ‘K’ in Stage A but when I import Stage B directly, the variant is ‘default’ (I think because it doesn’t say what it is actually reading in the StaticMesh asset). The problem is I cannot point the Stage B import at a variant choice.
Is there a better way to do what I am trying? Are there unexposed controls on the StaticMesh I can access? Do I have to add/change something in the USD Mesh Asset User Data object (is that what is controlling what StaticMesh is reading?), or do I need to be even more explicit in what I pass to the importer by referencing the exact Mesh prim for the variant choice I want rather than just pointing at the asset (i.e. Component kind) prim above it?