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  friend class _Observer;
92 
93  class _Observer : public HdSceneIndexObserver
94  {
95  public:
96  _Observer(HdMergingSceneIndex *owner)
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  private:
111  HdMergingSceneIndex *_owner;
112  };
113 
114  _Observer _observer;
115 
116  struct _InputEntry
117  {
118  HdSceneIndexBaseRefPtr sceneIndex;
119  SdfPath sceneRoot;
120 
121  _InputEntry(const HdSceneIndexBaseRefPtr &sceneIndex,
122  const SdfPath &sceneRoot)
123  : sceneIndex(sceneIndex)
124  , sceneRoot(sceneRoot)
125  {
126  }
127  };
128 
129  using _InputEntries = std::vector<_InputEntry>;
130 
131  _InputEntries _inputs;
132 };
133 
134 
135 PXR_NAMESPACE_CLOSE_SCOPE
136 
137 #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.