|
A scene index implementing USD native instancing. More...
#include <niPrototypePropagatingSceneIndex.h>
Public Types | |
using | SceneIndexAppendCallback = std::function< HdSceneIndexBaseRefPtr(const HdSceneIndexBaseRefPtr &inputScene)> |
Public Types inherited from TfRefBase | |
typedef void(* | UniqueChangedFuncPtr) (TfRefBase const *, bool) |
Public Member Functions | |
USDIMAGING_API HdSceneIndexPrim | GetPrim (const SdfPath &primPath) const override |
Returns a pair of (prim type, datasource) for the object at primPath . | |
USDIMAGING_API SdfPathVector | GetChildPrimPaths (const SdfPath &primPath) const override |
Returns the paths of all scene index prims located immediately below primPath . | |
USDIMAGING_API std::vector< HdSceneIndexBaseRefPtr > | GetInputScenes () const override |
virtual std::vector< HdSceneIndexBaseRefPtr > | GetInputScenes () const =0 |
Public Member Functions inherited from HdSceneIndexBase | |
HD_API void | AddObserver (const HdSceneIndexObserverPtr &observer) |
Adds an observer to this scene index. | |
HD_API void | RemoveObserver (const HdSceneIndexObserverPtr &observer) |
Removes an observer from this scene index; the given observer will no longer be forwarded notices. | |
virtual HdSceneIndexPrim | GetPrim (const SdfPath &primPath) const =0 |
Returns a pair of (prim type, datasource) for the object at primPath . | |
virtual SdfPathVector | GetChildPrimPaths (const SdfPath &primPath) const =0 |
Returns the paths of all scene index prims located immediately below primPath . | |
HdDataSourceBaseHandle | GetDataSource (const SdfPath &primPath, const HdDataSourceLocator &locator) const |
A convenience function: look up the object at primPath , and if successful return the datasource at locator within that prim. | |
HD_API void | SystemMessage (const TfToken &messageType, const HdDataSourceBaseHandle &args) |
Sends a message with optional arguments to this and any upstream input scene indices. | |
HD_API std::string | GetDisplayName () const |
Returns a value previously set by SetDisplayName. | |
HD_API void | SetDisplayName (const std::string &n) |
Allows for scene index instances to be identified in a more contextually relevant way. | |
HD_API void | AddTag (const TfToken &tag) |
Adds a specified tag token to a scene index instance. | |
HD_API void | RemoveTag (const TfToken &tag) |
Removes a specified tag token to a scene index instance. | |
HD_API bool | HasTag (const TfToken &tag) const |
Returns true if a specified tag token has been added to a scene index instance. | |
HD_API TfTokenVector | GetTags () const |
Returns all tag tokens currently added to a scene index instance. | |
Public Member Functions inherited from TfRefBase | |
TfRefBase (TfRefBase const &) | |
TfRefBase & | operator= (TfRefBase const &) |
size_t | GetCurrentCount () const |
Return the current reference count of this object. | |
bool | IsUnique () const |
Return true if only one TfRefPtr points to this object. | |
void | SetShouldInvokeUniqueChangedListener (bool shouldCall) |
Public Member Functions inherited from TfWeakBase | |
TfWeakBase (const TfWeakBase &) | |
const TfWeakBase & | __GetTfWeakBase__ () const |
const TfWeakBase & | operator= (const TfWeakBase &) |
void | EnableNotification2 () const |
TF_API void const * | GetUniqueIdentifier () const |
Static Public Member Functions | |
static USDIMAGING_API UsdImagingNiPrototypePropagatingSceneIndexRefPtr | New (HdSceneIndexBaseRefPtr const &inputSceneIndex, const TfTokenVector &instanceDataSourceNames, const SceneIndexAppendCallback &sceneIndexAppendCallback) |
Static Public Member Functions inherited from TfRefBase | |
static TF_API void | SetUniqueChangedListener (UniqueChangedListener listener) |
Friends | |
class | _InstanceAggregationSceneIndexObserver |
class | _MergingSceneIndexObserver |
Additional Inherited Members | |
Protected Member Functions inherited from HdSceneIndexBase | |
HD_API void | _SendPrimsAdded (const HdSceneIndexObserver::AddedPrimEntries &entries) |
Notify attached observers of prims added to the scene. | |
HD_API void | _SendPrimsRemoved (const HdSceneIndexObserver::RemovedPrimEntries &entries) |
Notify attached observers of prims removed from the scene. | |
HD_API void | _SendPrimsDirtied (const HdSceneIndexObserver::DirtiedPrimEntries &entries) |
Notify attached observers of datasource invalidations from the scene. | |
HD_API void | _SendPrimsRenamed (const HdSceneIndexObserver::RenamedPrimEntries &entries) |
Notify attached observers of prims (and their descendents) which have been renamed or reparented. | |
HD_API bool | _IsObserved () const |
Returns whether the scene index has any registered observers; this information can be used to skip work preparing notices when there are no observers. | |
virtual HD_API void | _SystemMessage (const TfToken &messageType, const HdDataSourceBaseHandle &args) |
Implement in order to react directly to system messages sent from downstream. | |
Protected Member Functions inherited from TfWeakBase | |
TfRefPtr< Tf_Remnant > | _Register () const |
template<class T > | |
TfRefPtr< Tf_Remnant > | _Register (T *tempRmnt) const |
bool | _HasRemnant () const |
A scene index implementing USD native instancing.
If combined with the UsdImagingPiPrototypePropagatingSceneIndex, the native instancing scene index has to be run after the point instancing scene index.
This scene index uses the UsdImagingNiInstanceAggregationSceneIndex to find all instances, aggregate them and insert instancers for each set of aggregated instances. This scene index then inserts flattened and possibly further transformed (e.g. applying draw mode) copies of the corresponding USD prototype underneath each of these instancers. Each of these copies is actually a UsdImagingNiPrototypePropagatingSceneIndex itself. This way, we can handle nested native instancing. In other words, we can call the UsdImagingNiPrototypePropagatingSceneIndex for a USD prototype and it will find the instances within that prototype.
The instancing scene index uses the instancedBy:prototypeRoot of the input scene index during aggregation. Typically, the input scene index will be a UsdImagingPiPrototypePropagatingSceneIndex which populates instancedBy:prototypeRoot based on which point instancer is instancing a prim.
This scene index is implemented by a merging scene index with the following inputs:
Example 1 (also see Example 1 in niInstanceAggregationSceneIndex.h)
USD:
def Xform "MyPrototype" { def Cube "MyCube" { } }
def "Cube_1" ( instanceable = true references = </MyPrototype> { }
Inputs of the UsdImagingNiPrototypePropagatingSceneIndex(inputSceneIndex):
* HdMergingSceneIndex * UsdImagingDrawModeSceneIndex (through SceneIndexAppendCallback) * HdFlatteningSceneIndex inputArgs = UsdImagingFlattenedDataSourceProviders() [So model:drawMode is also flattened] * UsdImaging_NiPrototypeSceneIndex forPrototype = false prototypeRootOverlayDs = null * UsdImaging_NiPrototypePruningSceneIndex forPrototype = false * inputSceneIndex (typically a UsdImagingPiPrototypePropagatingSceneIndex) * UsdImaging_NiInstanceAggregationSceneIndex forPrototype = false instanceDataSourceNames = ['materialBindings', 'purpose', 'model'] * UsdImagingDrawModeSceneIndex [... as above] * UsdImagingRerootingSceneIndex (inserted by _InstanceAggregationSceneIndexObserver::PrimsAdded through _MergingSceneIndexEntry) srcPrefix = /UsdNiInstancer dstPrefix = /UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer * UsdImagingNiPrototypePropagatingSceneIndex prototypeName = __Prototype_1 * HdMergingSceneIndex * UsdImagingDrawModeSceneIndex (through SceneIndexAppendCallback) * HdFlatteningSceneIndex inputArgs = UsdImagingFlattenedDataSourceProviders() [So model:drawMode is also flattened] * UsdImaging_NiPrototypeSceneIndex forPrototype = true * UsdImagingRerootingSceneIndex srcPrefix = /__PrototypeRoot1 dstPrefix = /UsdNiInstancer/UsdNiPrototype * inputSceneIndex * UsdImaging_NiInstanceAggregationSceneIndex forPrototype = true * UsdImagingDrawModeSceneIndex [... as just above]
UsdImagingNiPrototypePropagatingSceneIndex
/Cube_1 primType: "" dataSource: instance: # Useful for translating Usd proxy paths for selection.
instancer: /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer prototypeId: 0 instanceId: 0 purpose: # From flattening scene index purpose: geometry xform: # From flattening scene index matrix: [ identity matrix] primOrigin: scenePath: HdPrimOriginSchema::OriginPath(/Cube_1) ... /MyPrototype # Not referenced from a different file, so appears here
primType: "" /MyPrototype/MyCube primType: cube /UsdNiPropagatedPrototypes primType: "" /UsdNiPropagatedPrototypes/Bindings_423...234 primType: "" dataSource: purpose: # Added by instance aggregation scene index, copied from /Cube_1 purpose: geometry
instancer instead) /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1 primType: "" /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer primType: instancer dataSource: instancerTopology: instanceIndices: i0: [ 0 ] prototypes: [ /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer/UsdNiPrototype instanceLocations: [ /Cube_1 ] # for picking primvars: hydra:instanceTransforms: primvarValue: [ identity matrix ] interpolation: instance /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer/UsdNiPrototype primType: "" dataSource: instancedBy: paths: [ /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer ] prototypeRoot: /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1 /UsdNiInstancer/UsdNiPrototype purpose: # Added by prototype scene index, copied from /UsdNiPropagatedPrototypes/Bindings_423...234
purpose: geometry xform: # From flattening scene index matrix: [ identity matrix ] resetXformStack: true primOrigin: scenePath: HdPrimOriginSchema::OriginPath(.) /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer/UsdNiPrototype/MyCube primType: cube dataSource: instancedBy: paths: [ /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1/UsdNiInstancer ] prototypeRoot: /UsdNiPropagatedPrototypes/Bindings_423...234/__Prototype_1 /UsdNiInstancer/UsdNiPrototype purpose: # From flattening scene index purpose: geometry xform: # From flattening scene index matrix: [ identity matrix ] resetXformStack: true primOrigin: scenePath: HdPrimOriginSchema::OriginPath(MyCube)
Example 2:
def Xform "MyNestedPrototype" # Will become USD prototype /__Prototype_1 { def Cube "MyCube" { } }
def Xform "MyPrototype" # Will become USD prototype /__Prototype_2 { def "MyNestedInstance" ( instanceable = true references = </MyNestedPrototype> ) { } }
def Xform "MyInstance" ( instanceable = true references = </MyPrototype>) {
}
UsdImagingNiPrototypePropagatingSceneIndex
... /MyInstance primType: "" dataSource: instance: instancer: /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer prototypeId: 0 instanceId: 0 ... /UsdNiPropagatedPrototypes primType: "" /UsdNiPropagatedPrototypes/NoBindings primType: "" dataSource: ... /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2 primType: "" /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer primType: instancer dataSource: instanerTopology: prototypes: [ /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype ] ... /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/_Prototype_2 primType: "" /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/_Prototype_2/MyNestedInstance primType: "" dataSource: instancer: /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer prototypeId: 0 instanceId: 0 ... /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings primType: "" dataSource: ... /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1 primType: "" /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer primType: instancer dataSource: instanerTopology: prototypes: [ /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer/UsdPiPrototype ] ... instancedBy: paths: [ /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer ] prototypeRoot: /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer/UsdPiPrototype primType: "" dataSource: instancedBy: paths: [ /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer ] prototypeRoot: /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer/UsdPiPrototype ... /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer/UsdPiPrototype/MyCube primType: "cube" dataSource: instancedBy: paths: [ /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/UsdPiPrototype/UsdNiInstancer ] prototypeRoot: /UsdNiPropagatedPrototypes/NoBindings/__Prototype_2/UsdNiInstancer/UsdPiPrototype/UsdNiPropagatedPrototypes/NoBindings/__Prototype_1/UsdNiInstancer/UsdPiPrototype ...
Definition at line 303 of file niPrototypePropagatingSceneIndex.h.
using SceneIndexAppendCallback = std::function< HdSceneIndexBaseRefPtr(const HdSceneIndexBaseRefPtr &inputScene)> |
Definition at line 307 of file niPrototypePropagatingSceneIndex.h.
|
overridevirtual |
Returns the paths of all scene index prims located immediately below primPath
.
This function can be used to traverse the scene by recursing from SdfPath::AbsoluteRootPath()
; such a traversal is expected to give the same set of prims as the flattening of the scene index's PrimsAdded
and PrimsRemoved
messages. This function is expected to be threadsafe.
Implements HdSceneIndexBase.
|
overridevirtual |
Implements HdFilteringSceneIndexBase.
|
overridevirtual |
Returns a pair of (prim type, datasource) for the object at primPath
.
If no such object exists, the type will be the empty token and the datasource will be null. This function is expected to be threadsafe.
Implements HdSceneIndexBase.
|
friend |
Definition at line 349 of file niPrototypePropagatingSceneIndex.h.
|
friend |
Definition at line 373 of file niPrototypePropagatingSceneIndex.h.