mergingSceneIndex.h
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"
28 #include "pxr/imaging/hd/filteringSceneIndex.h"
29 
30 PXR_NAMESPACE_OPEN_SCOPE
31 
34 
43 {
44 public:
45 
46  static HdMergingSceneIndexRefPtr New() {
47  return TfCreateRefPtr(new HdMergingSceneIndex);
48  }
49 
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 
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  void _FillAddedEntriesRecursively(
92  const HdSceneIndexBaseRefPtr &newSceneIndex,
93  const SdfPath &primPath,
94  HdSceneIndexObserver::AddedPrimEntries * const addedEntries);
95 
96 
97  friend class _Observer;
98 
99  class _Observer : public HdSceneIndexObserver
100  {
101  public:
102  _Observer(HdMergingSceneIndex *owner)
103  : _owner(owner) {}
104 
105  void PrimsAdded(
106  const HdSceneIndexBase &sender,
107  const AddedPrimEntries &entries) override;
108 
109  void PrimsRemoved(
110  const HdSceneIndexBase &sender,
111  const RemovedPrimEntries &entries) override;
112 
113  void PrimsDirtied(
114  const HdSceneIndexBase &sender,
115  const DirtiedPrimEntries &entries) override;
116  private:
117  HdMergingSceneIndex *_owner;
118  };
119 
120  _Observer _observer;
121 
122  struct _InputEntry
123  {
124  HdSceneIndexBaseRefPtr sceneIndex;
125  SdfPath sceneRoot;
126 
127  _InputEntry(const HdSceneIndexBaseRefPtr &sceneIndex,
128  const SdfPath &sceneRoot)
129  : sceneIndex(sceneIndex)
130  , sceneRoot(sceneRoot)
131  {
132  }
133  };
134 
135  using _InputEntries = std::vector<_InputEntry>;
136 
137  _InputEntries _inputs;
138 };
139 
140 
141 PXR_NAMESPACE_CLOSE_SCOPE
142 
143 #endif //PXR_IMAGING_HD_MERGING_SCENE_H
HD_API std::vector< HdSceneIndexBaseRefPtr > GetInputScenes() const override
satisfying HdFilteringSceneIndex
Merges multiple scenes together.
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:49
Observer of scene data.
Abstract interface to scene data.
Definition: sceneIndex.h:62
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
HD_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource) for the object at primPath.
An abstract base class for scene indexes that have one or more input scene indexes which serve as a b...
HD_API void AddInputScene(const HdSceneIndexBaseRefPtr &inputScene, const SdfPath &activeInputSceneRoot)
Adds a scene with activeInputSceneRoot specifying the shallowest path at which prims should be consid...
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75
HD_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.