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