Query composed payloads with LoadNone

Is there any way to retreive a list of payloads on a composed prim when opening the stage with LoadNone?

I’ve tried the PrimCompositionQuery, but that doesn’t seem to return any payloads (when trying with LoadAll it does find them). I can get the payload list from the prim spec, but it seems this is pre-composition.

My use case is to process a usd file with all of its references composed, and take note of the external payloads without loading them.

example usda file:

#usda 1.0 (
    defaultPrim = "game"

def Game "game" {
    def "map_ref" (
        append payload = @map.usda@
        append references = </game/added>
    ) { }

    def "added" (
        append payload = @streaming_tiles/spawn_tile.usda@
    ) { }

rough example code I’m hoping to achieve:

UsdStageRefPtr stage = UsdStage::Open("game.usda", UsdStage::LoadNone);
pxr::UsdPrim game = stage->GetDefaultPrim();
UsdPrim map_ref = game.GetChild("map_ref");
get_payload_targets(map_ref); // returns [map.usda, streaming_tiles/spawn_tile.usda] 

Cheers for any help :slight_smile:

Hi @nathanday , unfortunately, the current “prim indexing” algorithm intentionally elides unloaded payload “nodes” in the composition graph, leading to the behavior you are seeing. We had a brief chat about possibly altering the way at least ComputeExpandedPrimIndex() works (which is what UsdPrimCompositionQuery uses) to include unloaded payloads, and you could file an Issue on GitHub about that.

In the meantime, I think you might be able to recover the info by fetching prim.GetPrimStack() and manually querying each primSpec in it for the payload field. In the common case this should be accurate without alot of work on your part. In the fully general case where the listOp-ness of payload is being leveraged, i.e. if there are deletedItems in a SdfListOp that yo ucome across, then you’re in for a rough ride, because you’d need to compose the listOps yourself, understanding that they only compose with each other within the same layerStack… and that information is not given to you in a PrimStack.

If you’re OK with your query being “overly conservative”, then you could just ignore deletedItems and just union the results of addedOrExplicitItems over the entries you find…