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 
53  bool Has(const TfToken &name) override;
54 
58  TfTokenVector GetNames() override;
59 
63  HdDataSourceBaseHandle Get(const TfToken &name) override;
64 
65 private:
74  const UsdAttributeQuery &visibilityQuery,
75  const SdfPath &sceneIndexPath,
76  const UsdImagingDataSourceStageGlobals &stageGlobals);
77 
78 private:
79  UsdAttributeQuery _visibilityQuery;
80  const UsdImagingDataSourceStageGlobals &_stageGlobals;
81 };
82 
83 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceVisibility);
84 
85 
86 // ----------------------------------------------------------------------------
87 
92 {
93 public:
94  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePurpose);
95 
100  bool Has(const TfToken &name) override;
101 
105  TfTokenVector GetNames() override;
106 
110  HdDataSourceBaseHandle Get(const TfToken &name) override;
111 
112 private:
120  const UsdAttributeQuery &purposeQuery,
121  const UsdImagingDataSourceStageGlobals &stageGlobals);
122 
123 private:
124  UsdAttributeQuery _purposeQuery;
125  const UsdImagingDataSourceStageGlobals &_stageGlobals;
126 };
127 
128 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePurpose);
129 
130 
131 // ----------------------------------------------------------------------------
132 
138 {
139 public:
140  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtentCoordinate);
141 
143  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
144 
146  GfVec3d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
147 
151  HdSampledDataSource::Time startTime,
152  HdSampledDataSource::Time endTime,
153  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
154 
155 private:
164  const HdVec3fArrayDataSourceHandle &extentAttr,
165  const SdfPath &attrPath,
166  unsigned int index);
167 
168 private:
169  HdVec3fArrayDataSourceHandle _extentAttr;
170  SdfPath _attrPath;
171  unsigned int _index;
172 };
173 
174 // ----------------------------------------------------------------------------
175 
180 {
181 public:
182  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtent);
183 
188  bool Has(const TfToken &name) override;
189 
193  TfTokenVector GetNames() override;
194 
198  HdDataSourceBaseHandle Get(const TfToken &name) override;
199 
200 private:
209  const UsdAttributeQuery &extentQuery,
210  const SdfPath &sceneIndexPath,
211  const UsdImagingDataSourceStageGlobals &stageGlobals);
212 
213 private:
214  // Note: the constructor takes sceneIndexPath for change-tracking,
215  // but here we're storing the USD attribute path for error reporting!
216  SdfPath _attrPath;
217  HdVec3fArrayDataSourceHandle _extentAttr;
218 };
219 
220 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceExtent);
221 
222 
223 // ----------------------------------------------------------------------------
224 
230 {
231 public:
232  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformResetXformStack);
233 
235  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
236 
238  bool GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
239 
243  HdSampledDataSource::Time startTime,
244  HdSampledDataSource::Time endTime,
245  std::vector<HdSampledDataSource::Time> *outSampleTimes) override {
246  return false;
247  }
248 
249 private:
260  const UsdGeomXformable::XformQuery &xformQuery,
261  const UsdImagingDataSourceStageGlobals &stageGlobals);
262 
263 private:
264  UsdGeomXformable::XformQuery _xformQuery;
265  const UsdImagingDataSourceStageGlobals &_stageGlobals;
266 };
267 
268 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformResetXformStack);
269 
270 // ----------------------------------------------------------------------------
271 
279 {
280 public:
281 
282  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformMatrix);
283 
287  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
288 
292  GfMatrix4d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
293 
298  HdSampledDataSource::Time startTime,
299  HdSampledDataSource::Time endTime,
300  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
301 
302 private:
313  const UsdGeomXformable::XformQuery &xformQuery,
314  const UsdImagingDataSourceStageGlobals &stageGlobals);
315 
316 private:
317  UsdGeomXformable::XformQuery _xformQuery;
318  const UsdImagingDataSourceStageGlobals &_stageGlobals;
319 };
320 
321 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformMatrix);
322 
323 // ----------------------------------------------------------------------------
324 
335 {
336 public:
337  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXform);
338 
344  bool Has(const TfToken &name) override;
345 
350  TfTokenVector GetNames() override;
351 
356  HdDataSourceBaseHandle Get(const TfToken &name) override;
357 
358 private:
369  const UsdGeomXformable::XformQuery &xformQuery,
370  const SdfPath &sceneIndexPath,
371  const UsdImagingDataSourceStageGlobals &stageGlobals);
372 
373 private:
374  UsdGeomXformable::XformQuery _xformQuery;
375  const UsdImagingDataSourceStageGlobals &_stageGlobals;
376 };
377 
378 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXform);
379 
380 // ----------------------------------------------------------------------------
381 
388 {
389 public:
390  HD_DECLARE_DATASOURCE(UsdImagingDataSourceModel);
391 
394  bool Has(const TfToken &name) override;
395 
398  TfTokenVector GetNames() override;
399 
403  HdDataSourceBaseHandle Get(const TfToken &name) override;
404 
405 private:
415  const UsdGeomModelAPI &model,
416  const SdfPath &sceneIndexPath,
417  const UsdImagingDataSourceStageGlobals &stageGlobals);
418 
419 private:
420  UsdGeomModelAPI _model;
421  const SdfPath _sceneIndexPath;
422  const UsdImagingDataSourceStageGlobals &_stageGlobals;
423 };
424 
425 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceModel);
426 
427 // ----------------------------------------------------------------------------
428 
447 {
448 public:
449  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrim);
450 
454  USDIMAGING_API
455  bool Has(const TfToken &name) override;
456 
460  USDIMAGING_API
461  TfTokenVector GetNames() override;
462 
465  USDIMAGING_API
466  HdDataSourceBaseHandle Get(const TfToken &name) override;
467 
470  USDIMAGING_API
472  const TfToken &subprim, const TfTokenVector &properties);
473 
474 protected:
487  USDIMAGING_API
489  const SdfPath &sceneIndexPath,
490  UsdPrim usdPrim,
491  const UsdImagingDataSourceStageGlobals &stageGlobals);
492 
493  // Accessors, for derived classes...
494  const SdfPath &_GetSceneIndexPath() const {
495  return _sceneIndexPath;
496  }
497 
498  const UsdPrim &_GetUsdPrim() const {
499  return _usdPrim;
500  }
501 
502  const UsdImagingDataSourceStageGlobals &_GetStageGlobals() const {
503  return _stageGlobals;
504  }
505 
506 private:
507  const SdfPath _sceneIndexPath;
508  UsdPrim _usdPrim;
509  const UsdImagingDataSourceStageGlobals &_stageGlobals;
510 };
511 
512 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrim);
513 
514 PXR_NAMESPACE_CLOSE_SCOPE
515 
516 #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.
static USDIMAGING_API HdDataSourceLocatorSet Invalidate(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.
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.
USDIMAGING_API bool Has(const TfToken &name) override
Returns whether or not this data source can return a meaningful data source for name.
VtValue GetValue(HdSampledDataSource::Time shutterOffset) override
Returns VtValue at a given shutterOffset for the value of this xform.
bool Has(const TfToken &name) override
Returns whether or not this container can return something meaningful for name.
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:201
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:132
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...
TfTokenVector GetNames() override
Returns the names contained in this data source.
bool Has(const TfToken &name) override
Returns true if name matches an attribute in UsdImagingModelSchema.
bool Has(const TfToken &name) override
Returns whether or not this container can return something meaningful for name.
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 Has(const TfToken &name) override
Returns whether or not this container can return something meaningful for name.
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...
bool Has(const TfToken &name) override
Returns whether or not this container can return something meaningful for name.
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.