HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sceneIndexObserver.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_SCENE_INDEX_OBSERVER_H
25 #define PXR_IMAGING_HD_SCENE_INDEX_OBSERVER_H
26 
27 #include "pxr/pxr.h"
28 
30 
31 #include "pxr/usd/sdf/path.h"
32 
33 #include "pxr/imaging/hd/api.h"
35 
37 
38 class HdSceneIndexBase;
39 
42 
43 /// \class HdSceneIndexObserver
44 ///
45 /// Observer of scene data. From the time an observer is registered with
46 /// a scene index, the scene index will send it diffs as the scene changes.
47 ///
49 {
50 public:
51 
52  HD_API
53  virtual ~HdSceneIndexObserver();
54 
55  /// A notice indicating a prim of a given type was added to the scene.
56  /// Note that \p primPath might already exist in the scene, in which case
57  /// this acts as a resync or change-of-primtype notice.
59  {
62 
65  : primPath(primPath)
66  , primType(primType)
67  {
68  }
69  };
71 
72  //----------------------------------
73 
74  /// A notice indicating a prim subtree was removed from the scene.
75  /// Note that all prims which are descendants of \p primPath should be
76  /// removed as well.
78  {
80 
82  : primPath(primPath)
83  {}
84  };
85 
87 
88  //----------------------------------
89 
90  /// A notice indicating a prim was invalidated. \p dirtyLocators identifies
91  /// a set of datasources for which data needs to be re-pulled. Locators
92  /// are hierarchical: if \p primvars was invalidated, \p primvars/color
93  /// was considered invalidated as well. This notice only affects the named
94  /// prim; descendants of \p primPath are unaffected.
96  {
99 
101  const SdfPath &primPath,
103  : primPath(primPath)
104  , dirtyLocators(dirtyLocators)
105  {}
106  };
107 
109 
110  //----------------------------------
111 
112  /// A notice indicating a prim (and its descendents) was renamed or
113  /// reparented.
115  {
119  const SdfPath &oldPrimPath,
120  const SdfPath &newPrimPath)
121  : oldPrimPath(oldPrimPath)
122  , newPrimPath(newPrimPath)
123  {}
124  };
125 
127 
128  //-------------------------------------------------------------------------
129 
130  /// A notification indicating prims have been added to the scene. The
131  /// set of scene prims compiled from added/removed notices should match
132  /// the set from a traversal based on \p sender.GetChildPrimNames. Each
133  /// prim has a path and type. It's possible for \p PrimsAdded to be called
134  /// for prims that already exist; in that case, observers should be sure to
135  /// update the prim type, in case it changed, and resync the prim. This
136  /// function is not expected to be threadsafe.
137  HD_API
138  virtual void PrimsAdded(
139  const HdSceneIndexBase &sender,
140  const AddedPrimEntries &entries) = 0;
141 
142  /// A notification indicating prims have been removed from the scene.
143  /// Note that this message is considered hierarchical; if \p /Path is
144  /// removed, \p /Path/child is considered removed as well. This function is
145  /// not expected to be threadsafe.
146  HD_API
147  virtual void PrimsRemoved(
148  const HdSceneIndexBase &sender,
149  const RemovedPrimEntries &entries) = 0;
150 
151  /// A notification indicating prim datasources have been invalidated.
152  /// This message is not considered hierarchical on \p primPath; if \p
153  /// /Path is dirtied, \p /Path/child is not necessarily dirtied. However
154  /// datasource locators are considered hierarchical: if \p primvars is
155  /// dirtied on a prim, \p primvars/color is considered dirtied as well.
156  /// This function is not expected to be threadsafe.
157  HD_API
158  virtual void PrimsDirtied(
159  const HdSceneIndexBase &sender,
160  const DirtiedPrimEntries &entries) = 0;
161 
162  /// A notification indicating prims (and their descendants) have been
163  /// renamed or reparented.
164  /// This function is not expected to be threadsafe.
165  HD_API
166  virtual void PrimsRenamed(
167  const HdSceneIndexBase &sender,
168  const RenamedPrimEntries &entries) = 0;
169 
170  /// A utility for converting prims renamed messages into equivalent removed
171  /// and added notices.
172  HD_API
174  const HdSceneIndexBase &sender,
175  const HdSceneIndexObserver::RenamedPrimEntries &renamedEntries,
176  HdSceneIndexObserver::RemovedPrimEntries *outputRemovedEntries,
177  HdSceneIndexObserver::AddedPrimEntries *outputAddedEntries);
178 
179  /// A utility for converting prims renamed messages into equivalent removed
180  /// and added notices at the observer level
181  HD_API
183  const HdSceneIndexBase &sender,
184  const HdSceneIndexObserver::RenamedPrimEntries &renamedEntries,
185  HdSceneIndexObserver *observer);
186 
187 
188 
189 
190 
191 };
192 
194 
195 #endif // PXR_IMAGING_HD_SCENE_INDEX_OBSERVER_H
virtual HD_API void PrimsDirtied(const HdSceneIndexBase &sender, const DirtiedPrimEntries &entries)=0
TF_DECLARE_WEAK_PTRS(HdSceneIndexObserver)
HdDataSourceLocatorSet dirtyLocators
#define HD_API
Definition: api.h:40
TF_DECLARE_WEAK_AND_REF_PTRS(HdSceneIndexBase)
SdfPath oldPrimPath
RemovedPrimEntry(const SdfPath &primPath)
Definition: token.h:87
virtual HD_API void PrimsRenamed(const HdSceneIndexBase &sender, const RenamedPrimEntries &entries)=0
SdfPath primPath
AddedPrimEntry()
virtual HD_API void PrimsRemoved(const HdSceneIndexBase &sender, const RemovedPrimEntries &entries)=0
SdfPath newPrimPath
SdfPath primPath
Definition: path.h:291
AddedPrimEntry(const SdfPath &primPath, const TfToken &primType)
TfToken primType
DirtiedPrimEntry(const SdfPath &primPath, const HdDataSourceLocatorSet &dirtyLocators)
virtual HD_API ~HdSceneIndexObserver()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
virtual HD_API void PrimsAdded(const HdSceneIndexBase &sender, const AddedPrimEntries &entries)=0
SdfPath primPath
RenamedPrimEntry(const SdfPath &oldPrimPath, const SdfPath &newPrimPath)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static HD_API void ConvertPrimsRenamedToRemovedAndAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RenamedPrimEntries &renamedEntries, HdSceneIndexObserver::RemovedPrimEntries *outputRemovedEntries, HdSceneIndexObserver::AddedPrimEntries *outputAddedEntries)