def GetPrimLoadability(prim): """Return a tuple of (isLoadable, isLoaded) for 'prim', according to the following rules: A prim is loadable if it is active, and either of the following are true: * prim has a payload * prim is a model group The latter is useful because loading is recursive on a UsdStage, and it is convenient to be able to (e.g.) load everything loadable in a set. A prim 'isLoaded' only if there are no unloaded prims beneath it, i.e. it is stating whether the prim is "fully loaded". This is a debatable definition, but seems useful for usdview's purposes.""" if not (prim.IsActive() and (prim.IsGroup() or prim.HasPayload())): return (False, True) # XXX Note that we are potentially traversing the entire stage here. # If this becomes a performance issue, we can cast this query into C++, # cache results, etc. for p in Usd.TreeIterator(prim, Usd.PrimIsActive): if not p.IsLoaded(): return (True, False) return (True, True)