All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
indexProxy.h
Go to the documentation of this file.
1//
2// Copyright 2018 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_INDEX_PROXY_H
8#define PXR_USD_IMAGING_USD_IMAGING_INDEX_PROXY_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usdImaging/usdImaging/api.h"
15
16#include "pxr/usd/sdf/path.h"
17#include "pxr/usd/usd/prim.h"
18
19#include "pxr/base/tf/token.h"
20
21
22PXR_NAMESPACE_OPEN_SCOPE
23
24
31public:
53
54
58 USDIMAGING_API
59 void AddDependency(SdfPath const& cachePath,
60 UsdPrim const& usdPrim);
61
72 USDIMAGING_API
73 void InsertRprim(TfToken const& primType,
74 SdfPath const& cachePath,
75 UsdPrim const& usdPrim,
76 UsdImagingPrimAdapterSharedPtr adapter =
77 UsdImagingPrimAdapterSharedPtr());
78
79 USDIMAGING_API
80 void InsertSprim(TfToken const& primType,
81 SdfPath const& cachePath,
82 UsdPrim const& usdPrim,
83 UsdImagingPrimAdapterSharedPtr adapter =
84 UsdImagingPrimAdapterSharedPtr());
85
86 USDIMAGING_API
87 void InsertBprim(TfToken const& primType,
88 SdfPath const& cachePath,
89 UsdPrim const& usdPrim,
90 UsdImagingPrimAdapterSharedPtr adapter =
91 UsdImagingPrimAdapterSharedPtr());
92
93 USDIMAGING_API
94 void InsertInstancer(SdfPath const& cachePath,
95 UsdPrim const& usdPrim,
96 UsdImagingPrimAdapterSharedPtr adapter =
97 UsdImagingPrimAdapterSharedPtr());
98
99 // Mark a prim as needing follow-up work by the delegate, either
100 // TrackVariability or UpdateForTime. Both of these are automatically
101 // called on Insert*, but sometimes need to be manually triggered as well.
102 USDIMAGING_API
103 void RequestTrackVariability(SdfPath const& cachePath);
104
105 USDIMAGING_API
106 void RequestUpdateForTime(SdfPath const& cachePath);
107
108 //
109 // All removals are deferred to avoid surprises during change processing.
110 //
111
112 // Removes the Rprim at the specified cache path.
113 void RemoveRprim(SdfPath const& cachePath) {
114 _rprimsToRemove.push_back(cachePath);
115 _hdPrimInfoToRemove.push_back(cachePath);
116 _RemoveDependencies(cachePath);
117 }
118
119 // Removes the Sprim at the specified cache path.
120 void RemoveSprim(TfToken const& primType, SdfPath const& cachePath) {
121 _TypeAndPath primToRemove = {primType, cachePath};
122 _sprimsToRemove.push_back(primToRemove);
123 _hdPrimInfoToRemove.push_back(cachePath);
124 _RemoveDependencies(cachePath);
125 }
126
127 // Removes the Bprim at the specified cache path.
128 void RemoveBprim(TfToken const& primType, SdfPath const& cachePath) {
129 _TypeAndPath primToRemove = {primType, cachePath};
130 _bprimsToRemove.push_back(primToRemove);
131 _hdPrimInfoToRemove.push_back(cachePath);
132 _RemoveDependencies(cachePath);
133 }
134
135 // Removes the HdInstancer at the specified cache path.
136 void RemoveInstancer(SdfPath const& cachePath) {
137 _instancersToRemove.push_back(cachePath);
138 _hdPrimInfoToRemove.push_back(cachePath);
139 _RemoveDependencies(cachePath);
140 }
141
142 USDIMAGING_API
143 void MarkRprimDirty(SdfPath const& cachePath, HdDirtyBits dirtyBits);
144
145 USDIMAGING_API
146 void MarkSprimDirty(SdfPath const& cachePath, HdDirtyBits dirtyBits);
147
148 USDIMAGING_API
149 void MarkBprimDirty(SdfPath const& cachePath, HdDirtyBits dirtyBits);
150
151 USDIMAGING_API
152 void MarkInstancerDirty(SdfPath const& cachePath, HdDirtyBits dirtyBits);
153
154 USDIMAGING_API
155 bool IsRprimTypeSupported(TfToken const& typeId) const;
156
157 USDIMAGING_API
158 bool IsSprimTypeSupported(TfToken const& typeId) const;
159
160 USDIMAGING_API
161 bool IsBprimTypeSupported(TfToken const& typeId) const;
162
163 // Check if the given path has been populated yet.
164 USDIMAGING_API
165 bool IsPopulated(SdfPath const& cachePath) const;
166
167 // Recursively repopulate the specified usdPath into the render index.
168 USDIMAGING_API
169 void Repopulate(SdfPath const& usdPath);
170
171 USDIMAGING_API
172 UsdImagingPrimAdapterSharedPtr GetMaterialAdapter(
173 UsdPrim const& materialPrim);
174
175 // XXX: This is a workaround for some bugs in USD edit processing, and
176 // the weird use of HdPrimInfo by instanced prims. It removes the dependency
177 // between a hydra prim and whatever USD prim is in its primInfo, since this
178 // dependency is automatically inserted and for instanced prims will
179 // erroneously add a dependency between a hydra prototype and
180 // a USD instancer.
181 //
182 // Pending some refactoring, hopefully this API will disappear.
183 USDIMAGING_API
184 void RemovePrimInfoDependency(SdfPath const& cachePath);
185
186private:
187 friend class UsdImagingDelegate;
189 UsdImagingDelegate::_Worker* worker)
190 : _delegate(delegate)
191 , _worker(worker)
192 {}
193
194 // Sort and de-duplicate "repopulate" paths to prevent double-inserts.
195 // Called by UsdImagingDelegate::ApplyPendingUpdates.
196 void _UniqueifyPathsToRepopulate();
197
198 UsdImagingDelegate::_HdPrimInfo*
199 _AddHdPrimInfo(SdfPath const& cachePath,
200 UsdPrim const& usdPrim,
201 UsdImagingPrimAdapterSharedPtr const& adapter);
202
203 USDIMAGING_API
204 void _RemoveDependencies(SdfPath const& cachePath);
205
206 SdfPathVector const& _GetUsdPathsToRepopulate() {
207 return _usdPathsToRepopulate;
208 }
209 void _ProcessRemovals();
210
211 void _AddTask(SdfPath const& usdPath);
212
213 struct _TypeAndPath {
214 TfToken primType;
215 SdfPath cachePath;
216 };
217
218 typedef std::vector<_TypeAndPath> _TypeAndPathVector;
219
220 typedef std::vector<UsdImagingDelegate::_DependencyMap::value_type>
221 _DependencyVector;
222
223 UsdImagingDelegate* _delegate;
224 UsdImagingDelegate::_Worker* _worker;
225 SdfPathVector _usdPathsToRepopulate;
226 SdfPathVector _rprimsToRemove;
227 _TypeAndPathVector _sprimsToRemove;
228 _TypeAndPathVector _bprimsToRemove;
229 SdfPathVector _instancersToRemove;
230 SdfPathVector _hdPrimInfoToRemove;
231 _DependencyVector _dependenciesToRemove;
232};
233
234
235PXR_NAMESPACE_CLOSE_SCOPE
236
237#endif //PXR_USD_IMAGING_USD_IMAGING_INDEX_PROXY_H
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition: delegate.h:67
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:30
USDIMAGING_API void AddDependency(SdfPath const &cachePath, UsdPrim const &usdPrim)
A note on paths/prims: the core function of UsdImagingIndexProxy and UsdImagingDelegate is to maintai...
USDIMAGING_API void InsertRprim(TfToken const &primType, SdfPath const &cachePath, UsdPrim const &usdPrim, UsdImagingPrimAdapterSharedPtr adapter=UsdImagingPrimAdapterSharedPtr())
Insert a hydra prim with the specified cache path.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...