HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sceneIndexPlugin.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_IMAGING_USD_IMAGING_SCENE_INDEX_PLUGIN_H
8 #define PXR_USD_IMAGING_USD_IMAGING_SCENE_INDEX_PLUGIN_H
9 
10 #include "pxr/pxr.h"
11 
13 
15 
17 #include "pxr/base/tf/type.h"
18 
19 #include <memory>
20 
22 
25  std::unique_ptr<class UsdImagingSceneIndexPlugin>;
26 
27 /// \class UsdImagingSceneIndexPlugin
28 ///
29 /// A base class for scene index plugins that can insert filtering
30 /// scene indices into UsdImaging, see sceneIndices.cpp for details.
31 ///
32 /// This is intended for UsdSkelImaging inserting scene indices implementing
33 /// the UsdSkel behaviors.
34 ///
35 /// Usage:
36 ///
37 /// class MyPlugin : public UsdImagingSceneIndexPlugin {
38 /// public:
39 /// HdSceneIndexBaseRefPtr
40 /// AppendSceneIndex(HdSceneIndexBaseRefPtr const &inputScene) override {
41 /// ...
42 /// }
43 /// };
44 ///
45 /// TF_REGISTRY_FUNCTION(UsdImagingSceneIndexPlugin)
46 /// {
47 /// // Also add to plugInfo.json.
48 /// UsdImagingSceneIndexPlugin::Define<MyPlugin>();
49 /// }
50 ///
52 {
53 public:
54  /// Override by client. Similar to HdSceneIndexPlugin::AppendSceneIndex.
55  virtual HdSceneIndexBaseRefPtr AppendSceneIndex(
56  HdSceneIndexBaseRefPtr const &inputScene) = 0;
57 
58  /// Clients can register additional HdFlattenedDataSourceProvider's that
59  /// UsdImagingCreateSceneIndices will pass to the flattening scene index.
60  ///
61  /// Clients can use
62  /// HdMakeDataSourceContainingFlattenedDataSourceProvider::Make
63  /// to create the values of the container data source.
64  ///
66  virtual HdContainerDataSourceHandle
68 
69  /// Clients can register additional names used by the (native) instance
70  /// aggregation scene index when grouping instances.
71  ///
72  /// For example, two instances with different material bindings cannot
73  /// be aggregated together and instantiated by the same instancer.
74  ///
75  /// UsdImagingCreateSceneIndices knows about several such bindings
76  /// already. Here, clients can add additional data sources that should
77  /// be expected by the aggregation scene index. These data sources
78  /// are identified by their name in the prim-level container data
79  /// source.
80  ///
82  virtual TfTokenVector
84 
85  /// Clients can register additional names of prim-level data sources
86  /// that should receive path-translation for any path-valued data
87  /// sources that point at instance proxies to point to corresponding
88  /// prototypes.
89  ///
91  virtual TfTokenVector
93 
96 
98  {
99  public:
101 
103  virtual ~FactoryBase();
104  };
105 
106  template<typename T>
107  class Factory : public FactoryBase
108  {
109  public:
111  return std::make_unique<T>();
112  }
113  };
114 
115  /// Call within TF_REGISTRY_FUNCTION(UsdImagingSceneIndexPlugin) to ensure
116  /// that UsdImaging can instantiate the client's subclass of
117  /// UsdImagingSceneIndexPlugin.
118  template<typename T>
119  static
120  void Define()
121  {
122  TfType::Define<T, TfType::Bases<UsdImagingSceneIndexPlugin>>()
123  .template SetFactory<Factory<T>>();
124  }
125 
126  /// Get an instance of each registered UsdImagingSceneIndexPlugin.
127  static
128  std::vector<UsdImagingSceneIndexPluginUniquePtr> GetAllSceneIndexPlugins();
129 };
130 
132 
133 #endif
virtual USDIMAGING_API ~UsdImagingSceneIndexPlugin()
UsdImagingSceneIndexPluginUniquePtr Create() override
virtual HdSceneIndexBaseRefPtr AppendSceneIndex(HdSceneIndexBaseRefPtr const &inputScene)=0
Override by client. Similar to HdSceneIndexPlugin::AppendSceneIndex.
#define USDIMAGING_API
Definition: api.h:23
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_REF_PTRS(HdSceneIndexBase)
virtual USDIMAGING_API TfTokenVector InstanceDataSourceNames()
Base class of all factory types.
Definition: type.h:56
virtual USDIMAGING_API ~FactoryBase()
static std::vector< UsdImagingSceneIndexPluginUniquePtr > GetAllSceneIndexPlugins()
Get an instance of each registered UsdImagingSceneIndexPlugin.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
virtual UsdImagingSceneIndexPluginUniquePtr Create()=0
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
virtual USDIMAGING_API HdContainerDataSourceHandle FlattenedDataSourceProviders()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
virtual USDIMAGING_API TfTokenVector ProxyPathTranslationDataSourceNames()
std::unique_ptr< class UsdImagingSceneIndexPlugin > UsdImagingSceneIndexPluginUniquePtr