dataSourcePrim.h
1 //
2 // Copyright 2020 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_DATA_SOURCE_PRIM_H
25 #define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_PRIM_H
26 
27 #include "pxr/imaging/hd/dataSource.h"
28 #include "pxr/imaging/hd/dataSourceTypeDefs.h"
29 
30 #include "pxr/usd/usd/prim.h"
31 
35 
36 #include "pxr/usdImaging/usdImaging/api.h"
37 #include "pxr/usdImaging/usdImaging/dataSourceStageGlobals.h"
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
45 {
46 public:
47  HD_DECLARE_DATASOURCE(UsdImagingDataSourceVisibility);
48 
52  TfTokenVector GetNames() override;
53 
57  HdDataSourceBaseHandle Get(const TfToken &name) override;
58 
59 private:
68  const UsdAttributeQuery &visibilityQuery,
69  const SdfPath &sceneIndexPath,
70  const UsdImagingDataSourceStageGlobals &stageGlobals);
71 
72 private:
73  UsdAttributeQuery _visibilityQuery;
74  const UsdImagingDataSourceStageGlobals &_stageGlobals;
75 };
76 
77 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceVisibility);
78 
79 
80 // ----------------------------------------------------------------------------
81 
86 {
87 public:
88  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePurpose);
89 
93  TfTokenVector GetNames() override;
94 
98  HdDataSourceBaseHandle Get(const TfToken &name) override;
99 
100 private:
108  const UsdAttributeQuery &purposeQuery,
109  const UsdImagingDataSourceStageGlobals &stageGlobals);
110 
111 private:
112  UsdAttributeQuery _purposeQuery;
113  const UsdImagingDataSourceStageGlobals &_stageGlobals;
114 };
115 
116 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePurpose);
117 
118 
119 // ----------------------------------------------------------------------------
120 
126 {
127 public:
128  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtentCoordinate);
129 
131  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
132 
134  GfVec3d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
135 
139  HdSampledDataSource::Time startTime,
140  HdSampledDataSource::Time endTime,
141  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
142 
143 private:
152  const HdVec3fArrayDataSourceHandle &extentAttr,
153  const SdfPath &attrPath,
154  unsigned int index);
155 
156 private:
157  HdVec3fArrayDataSourceHandle _extentAttr;
158  SdfPath _attrPath;
159  unsigned int _index;
160 };
161 
162 // ----------------------------------------------------------------------------
163 
168 {
169 public:
170  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtent);
171 
175  TfTokenVector GetNames() override;
176 
180  HdDataSourceBaseHandle Get(const TfToken &name) override;
181 
182 private:
191  const UsdAttributeQuery &extentQuery,
192  const SdfPath &sceneIndexPath,
193  const UsdImagingDataSourceStageGlobals &stageGlobals);
194 
195 private:
196  // Note: the constructor takes sceneIndexPath for change-tracking,
197  // but here we're storing the USD attribute path for error reporting!
198  SdfPath _attrPath;
199  HdVec3fArrayDataSourceHandle _extentAttr;
200 };
201 
202 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceExtent);
203 
204 
205 // ----------------------------------------------------------------------------
206 
212 {
213 public:
214  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformResetXformStack);
215 
217  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
218 
220  bool GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
221 
225  HdSampledDataSource::Time startTime,
226  HdSampledDataSource::Time endTime,
227  std::vector<HdSampledDataSource::Time> *outSampleTimes) override {
228  return false;
229  }
230 
231 private:
242  const UsdGeomXformable::XformQuery &xformQuery,
243  const UsdImagingDataSourceStageGlobals &stageGlobals);
244 
245 private:
246  UsdGeomXformable::XformQuery _xformQuery;
247  const UsdImagingDataSourceStageGlobals &_stageGlobals;
248 };
249 
250 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformResetXformStack);
251 
252 // ----------------------------------------------------------------------------
253 
261 {
262 public:
263 
264  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformMatrix);
265 
269  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
270 
274  GfMatrix4d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
275 
280  HdSampledDataSource::Time startTime,
281  HdSampledDataSource::Time endTime,
282  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
283 
284 private:
295  const UsdGeomXformable::XformQuery &xformQuery,
296  const UsdImagingDataSourceStageGlobals &stageGlobals);
297 
298 private:
299  UsdGeomXformable::XformQuery _xformQuery;
300  const UsdImagingDataSourceStageGlobals &_stageGlobals;
301 };
302 
303 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformMatrix);
304 
305 // ----------------------------------------------------------------------------
306 
317 {
318 public:
319  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXform);
320 
325  TfTokenVector GetNames() override;
326 
331  HdDataSourceBaseHandle Get(const TfToken &name) override;
332 
333 private:
344  const UsdGeomXformable::XformQuery &xformQuery,
345  const SdfPath &sceneIndexPath,
346  const UsdImagingDataSourceStageGlobals &stageGlobals);
347 
348 private:
349  UsdGeomXformable::XformQuery _xformQuery;
350  const UsdImagingDataSourceStageGlobals &_stageGlobals;
351 };
352 
353 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXform);
354 
355 // ----------------------------------------------------------------------------
356 
363 {
364 public:
365  HD_DECLARE_DATASOURCE(UsdImagingDataSourceModel);
366 
369  TfTokenVector GetNames() override;
370 
374  HdDataSourceBaseHandle Get(const TfToken &name) override;
375 
376 private:
386  const UsdGeomModelAPI &model,
387  const SdfPath &sceneIndexPath,
388  const UsdImagingDataSourceStageGlobals &stageGlobals);
389 
390 private:
391  UsdGeomModelAPI _model;
392  const SdfPath _sceneIndexPath;
393  const UsdImagingDataSourceStageGlobals &_stageGlobals;
394 };
395 
396 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceModel);
397 
398 // ----------------------------------------------------------------------------
399 
418 {
419 public:
420  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrim);
421 
425  USDIMAGING_API
426  TfTokenVector GetNames() override;
427 
430  USDIMAGING_API
431  HdDataSourceBaseHandle Get(const TfToken &name) override;
432 
435  USDIMAGING_API
437  UsdPrim const& prim,
438  const TfToken &subprim,
439  const TfTokenVector &properties);
440 
441 protected:
454  USDIMAGING_API
456  const SdfPath &sceneIndexPath,
457  UsdPrim usdPrim,
458  const UsdImagingDataSourceStageGlobals &stageGlobals);
459 
460  // Accessors, for derived classes...
461  const SdfPath &_GetSceneIndexPath() const {
462  return _sceneIndexPath;
463  }
464 
465  const UsdPrim &_GetUsdPrim() const {
466  return _usdPrim;
467  }
468 
469  const UsdImagingDataSourceStageGlobals &_GetStageGlobals() const {
470  return _stageGlobals;
471  }
472 
473 private:
474  const SdfPath _sceneIndexPath;
475  UsdPrim _usdPrim;
476  const UsdImagingDataSourceStageGlobals &_stageGlobals;
477 };
478 
479 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrim);
480 
481 PXR_NAMESPACE_CLOSE_SCOPE
482 
483 #endif // PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_PRIM_H
UsdGeomModelAPI extends the generic UsdModelAPI schema with geometry specific concepts such as cached...
Definition: modelAPI.h:148
bool GetTypedValue(HdSampledDataSource::Time shutterOffset) override
Returns bool at a given shutterOffset for the value of this flag.
VtValue GetValue(HdSampledDataSource::Time shutterOffset) override
Returns VtValue at a given shutterOffset for the value of this flag.
Object for efficiently making repeated queries for attribute values.
bool GetContributingSampleTimesForInterval(HdSampledDataSource::Time startTime, HdSampledDataSource::Time endTime, std::vector< HdSampledDataSource::Time > *outSampleTimes) override
Fills the outSampleTimes with the times between startTime and endTime that have valid sample data and...
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
Definition: dataSource.h:102
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the data source for the given 'name'.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the data source for the given 'name'.
Data source representing model API for a USD prim.
TfTokenVector GetNames() override
Returns the names contained in this data source.
Data source representing the "reset xform stack" flag for a USD xformable.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns data authored on USD prim (without resolving inherited) for attribute names of UsdImagingMode...
Data source representing prim purpose for a USD imageable.
TfTokenVector GetNames() override
Return attribute names of UsdImagingModelSchema.
Helper class that caches the ordered vector of UsGeomXformOps that contribute to the local transforma...
Definition: xformable.h:379
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Data source representing local prim extent.
VtValue GetValue(HdSampledDataSource::Time shutterOffset) override
Returns VtValue at a given shutterOffset for the value of this xform.
Data source representing a basic USD prim.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
This class is used as a context object with global stage information, that gets passed down to dataso...
A datasource representing a concretely-typed sampled value.
Definition: dataSource.h:196
Data source representing a container that stores a USD Xformable.
Represents a set of data source locators closed under descendancy.
TfTokenVector GetNames() override
Returns the names contained in this data source.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USDIMAGING_API TfTokenVector GetNames() override
Returns the names for which this data source can return meaningful results.
bool GetContributingSampleTimesForInterval(HdSampledDataSource::Time startTime, HdSampledDataSource::Time endTime, std::vector< HdSampledDataSource::Time > *outSampleTimes) override
Fills the outSampleTimes with the times between startTime and endTime that have valid sample data and...
static USDIMAGING_API HdDataSourceLocatorSet Invalidate(UsdPrim const &prim, const TfToken &subprim, const TfTokenVector &properties)
Returns the hydra attribute set we should invalidate if the value of the USD properties in properties...
TfTokenVector GetNames() override
Returns the names contained in this data source.
GfMatrix4d GetTypedValue(HdSampledDataSource::Time shutterOffset) override
Returns GfMatrix4d at a given shutterOffset for the value of this xform.
Data source representing a generic transform value accessor for a USD Xformable.
USDIMAGING_API UsdImagingDataSourcePrim(const SdfPath &sceneIndexPath, UsdPrim usdPrim, const UsdImagingDataSourceStageGlobals &stageGlobals)
Use to construct a new UsdImagingDataSourcePrim.
VtValue GetValue(HdSampledDataSource::Time shutterOffset) override
Returns VtValue at a given shutterOffset for the value of this flag.
USDIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the data source representing name, if valid.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the data source for the given 'name'.
Data source representing prim visibility for a USD imageable.
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
bool GetContributingSampleTimesForInterval(HdSampledDataSource::Time startTime, HdSampledDataSource::Time endTime, std::vector< HdSampledDataSource::Time > *outSampleTimes) override
Fills the outSampleTimes with the times between startTime and endTime that have valid sample data and...
Data source representing either the minimum or maximum of the local prim extent.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the data source for the given 'name'.
GfVec3d GetTypedValue(HdSampledDataSource::Time shutterOffset) override
Returns bool at a given shutterOffset for the value of this flag.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
TfTokenVector GetNames() override
Returns the names contained in this datasource.