|
Borrowing from The Core Kind Hierarchy, we review the primary kinds we use to create the model hierarchy.
We interrogate and author kinds on UsdPrim using UsdModelAPI::GetKind() and UsdModelAPI::SetKind(), in order to establish a Model Hierarchy, which is a contiguous prefix of a scene's namespace. The intention of model hierarchy is to recognize that we often organize our scenes into hierarchical collections of "components" each of which is a substantial, meaningful partition of the scene (generally, but not required to be, referenced assets), and codify that organization to facilitate navigating and reasoning about the scene at a high-level. In other words, Model Hierarchy acts as a scene's table of contents.
Assuming that the prims on a UsdStage are organized into assembly, group, and component models, we can use the Prim Predicate Flags UsdPrimIsModel
and UsdPrimIsGroup
in constructing predicates for UsdPrimRange and UsdStage::Traverse() that will visit all models on a stage, and no "sub-model" prims. UsdPrim::IsModel() and UsdPrim::IsGroup() answer the corresponding questions.
How does one "delete a prim" in USD? Considering that any given UsdPrim on a UsdStage may be comprised of SdfPrimSpec's from numerous layers, and that one or more (typically many) may not be editable by the user who wants to delete a prim or subtree rooted at a prim, the "obvious" approach of directly editing all of the participating layers, while possible, is not often practical or desirable.
Therefore USD provides a "non-destructive" and reversible form of prim deletion, which we call deactivation. One deactivates a prim using UsdPrim::SetActive(false)
, which sets the prim metadata active to false. For any prim on a stage whose active metadata resolves to false, we consider the prim to be deactivated, which has two important consequences: