HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mergingSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_MERGING_SCENE_H
25 #define PXR_IMAGING_HD_MERGING_SCENE_H
26 
27 #include "pxr/pxr.h"
29 
31 
34 
35 /// \class HdMergingSceneIndex
36 ///
37 /// Merges multiple scenes together. For prims which exist in more than one
38 /// input scene, data sources are overlayed (down to the leaf) with the earlier
39 /// inserted scene having the stronger opinion.
40 /// NOTE: This is currently the only example of a multi-input scene index and
41 /// therefore that pattern hasn't yet been broken into a base class.
43 {
44 public:
45 
46  static HdMergingSceneIndexRefPtr New() {
48  }
49 
50  /// Adds a scene with activeInputSceneRoot specifying the shallowest path
51  /// at which prims should be considered. This is an optional optimization
52  /// to avoid having to query multiple inputs when it's known in advance
53  /// which might be relevant for a given prim.
54  HD_API
55  void AddInputScene(
56  const HdSceneIndexBaseRefPtr &inputScene,
57  const SdfPath &activeInputSceneRoot);
58 
59  HD_API
60  void RemoveInputScene(const HdSceneIndexBaseRefPtr &sceneIndex);
61 
62  /// satisfying HdFilteringSceneIndex
63  HD_API
64  std::vector<HdSceneIndexBaseRefPtr> GetInputScenes() const override;
65 
66  // satisfying HdSceneIndexBase
67  HD_API
68  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
69 
70  HD_API
71  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
72 
73 protected:
74  HD_API
76 
77 private:
78 
79  void _PrimsAdded(
80  const HdSceneIndexBase &sender,
82 
83  void _PrimsRemoved(
84  const HdSceneIndexBase &sender,
86 
87  void _PrimsDirtied(
88  const HdSceneIndexBase &sender,
90 
91  friend class _Observer;
92 
93  class _Observer : public HdSceneIndexObserver
94  {
95  public:
97  : _owner(owner) {}
98 
99  void PrimsAdded(
100  const HdSceneIndexBase &sender,
101  const AddedPrimEntries &entries) override;
102 
103  void PrimsRemoved(
104  const HdSceneIndexBase &sender,
105  const RemovedPrimEntries &entries) override;
106 
107  void PrimsDirtied(
108  const HdSceneIndexBase &sender,
109  const DirtiedPrimEntries &entries) override;
110 
111  void PrimsRenamed(
112  const HdSceneIndexBase &sender,
113  const RenamedPrimEntries &entries) override;
114 
115  private:
116  HdMergingSceneIndex *_owner;
117  };
118 
119  _Observer _observer;
120 
121  struct _InputEntry
122  {
123  HdSceneIndexBaseRefPtr sceneIndex;
124  SdfPath sceneRoot;
125 
126  _InputEntry(const HdSceneIndexBaseRefPtr &sceneIndex,
127  const SdfPath &sceneRoot)
128  : sceneIndex(sceneIndex)
129  , sceneRoot(sceneRoot)
130  {
131  }
132  };
133 
134  using _InputEntries = std::vector<_InputEntry>;
135 
136  _InputEntries _inputs;
137 };
138 
139 
141 
142 #endif //PXR_IMAGING_HD_MERGING_SCENE_H
HD_API std::vector< HdSceneIndexBaseRefPtr > GetInputScenes() const override
satisfying HdFilteringSceneIndex
TfRefPtr< T > TfCreateRefPtr(T *ptr)
Definition: refPtr.h:1223
#define HD_API
Definition: api.h:40
HD_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
TF_DECLARE_REF_PTRS(HdMergingSceneIndex)
HD_API HdMergingSceneIndex()
Definition: path.h:290
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:211
static HdMergingSceneIndexRefPtr New()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HD_API void RemoveInputScene(const HdSceneIndexBaseRefPtr &sceneIndex)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HD_API void AddInputScene(const HdSceneIndexBaseRefPtr &inputScene, const SdfPath &activeInputSceneRoot)
HD_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override