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 #include "pxr/usdImaging/usdImaging/dataSourcePrimvars.h"
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
46 {
47 public:
48  HD_DECLARE_DATASOURCE(UsdImagingDataSourceVisibility);
49 
53  TfTokenVector GetNames() override;
54 
58  HdDataSourceBaseHandle Get(const TfToken &name) override;
59 
60 private:
69  const UsdAttributeQuery &visibilityQuery,
70  const SdfPath &sceneIndexPath,
71  const UsdImagingDataSourceStageGlobals &stageGlobals);
72 
73 private:
74  UsdAttributeQuery _visibilityQuery;
75  const UsdImagingDataSourceStageGlobals &_stageGlobals;
76 };
77 
78 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceVisibility);
79 
80 
81 // ----------------------------------------------------------------------------
82 
87 {
88 public:
89  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePurpose);
90 
94  TfTokenVector GetNames() override;
95 
99  HdDataSourceBaseHandle Get(const TfToken &name) override;
100 
101 private:
109  const UsdAttributeQuery &purposeQuery,
110  const UsdImagingDataSourceStageGlobals &stageGlobals);
111 
112 private:
113  UsdAttributeQuery _purposeQuery;
114  const UsdImagingDataSourceStageGlobals &_stageGlobals;
115 };
116 
117 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePurpose);
118 
119 
120 // ----------------------------------------------------------------------------
121 
127 {
128 public:
129  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtentCoordinate);
130 
132  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
133 
135  GfVec3d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
136 
140  HdSampledDataSource::Time startTime,
141  HdSampledDataSource::Time endTime,
142  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
143 
144 private:
153  const HdVec3fArrayDataSourceHandle &extentAttr,
154  const SdfPath &attrPath,
155  unsigned int index);
156 
157 private:
158  HdVec3fArrayDataSourceHandle _extentAttr;
159  SdfPath _attrPath;
160  unsigned int _index;
161 };
162 
163 // ----------------------------------------------------------------------------
164 
169 {
170 public:
171  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtent);
172 
176  TfTokenVector GetNames() override;
177 
181  HdDataSourceBaseHandle Get(const TfToken &name) override;
182 
183 private:
192  const UsdAttributeQuery &extentQuery,
193  const SdfPath &sceneIndexPath,
194  const UsdImagingDataSourceStageGlobals &stageGlobals);
195 
196 private:
197  // Note: the constructor takes sceneIndexPath for change-tracking,
198  // but here we're storing the USD attribute path for error reporting!
199  SdfPath _attrPath;
200  HdVec3fArrayDataSourceHandle _extentAttr;
201 };
202 
203 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceExtent);
204 
205 
206 // ----------------------------------------------------------------------------
207 
213 {
214 public:
215  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformResetXformStack);
216 
218  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
219 
221  bool GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
222 
226  HdSampledDataSource::Time startTime,
227  HdSampledDataSource::Time endTime,
228  std::vector<HdSampledDataSource::Time> *outSampleTimes) override {
229  return false;
230  }
231 
232 private:
243  const UsdGeomXformable::XformQuery &xformQuery,
244  const UsdImagingDataSourceStageGlobals &stageGlobals);
245 
246 private:
247  UsdGeomXformable::XformQuery _xformQuery;
248  const UsdImagingDataSourceStageGlobals &_stageGlobals;
249 };
250 
251 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformResetXformStack);
252 
253 // ----------------------------------------------------------------------------
254 
262 {
263 public:
264 
265  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformMatrix);
266 
270  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
271 
275  GfMatrix4d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
276 
281  HdSampledDataSource::Time startTime,
282  HdSampledDataSource::Time endTime,
283  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
284 
285 private:
296  const UsdGeomXformable::XformQuery &xformQuery,
297  const UsdImagingDataSourceStageGlobals &stageGlobals);
298 
299 private:
300  UsdGeomXformable::XformQuery _xformQuery;
301  const UsdImagingDataSourceStageGlobals &_stageGlobals;
302 };
303 
304 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformMatrix);
305 
306 // ----------------------------------------------------------------------------
307 
318 {
319 public:
320  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXform);
321 
326  TfTokenVector GetNames() override;
327 
332  HdDataSourceBaseHandle Get(const TfToken &name) override;
333 
334 private:
345  const UsdGeomXformable::XformQuery &xformQuery,
346  const SdfPath &sceneIndexPath,
347  const UsdImagingDataSourceStageGlobals &stageGlobals);
348 
349 private:
350  UsdGeomXformable::XformQuery _xformQuery;
351  const UsdImagingDataSourceStageGlobals &_stageGlobals;
352 };
353 
354 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXform);
355 
356 // ----------------------------------------------------------------------------
357 
364 {
365 public:
366  HD_DECLARE_DATASOURCE(UsdImagingDataSourceModel);
367 
370  TfTokenVector GetNames() override;
371 
375  HdDataSourceBaseHandle Get(const TfToken &name) override;
376 
377 private:
387  const UsdGeomModelAPI &model,
388  const SdfPath &sceneIndexPath,
389  const UsdImagingDataSourceStageGlobals &stageGlobals);
390 
391 private:
392  UsdGeomModelAPI _model;
393  const SdfPath _sceneIndexPath;
394  const UsdImagingDataSourceStageGlobals &_stageGlobals;
395 };
396 
397 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceModel);
398 
399 // ----------------------------------------------------------------------------
400 
407 {
408 public:
409  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrimOrigin);
410 
411  TfTokenVector GetNames() override;
412 
415  HdDataSourceBaseHandle Get(const TfToken &name) override;
416 
417 private:
418  UsdImagingDataSourcePrimOrigin(const UsdPrim &usdPrim);
419 
420 private:
421  UsdPrim _usdPrim;
422 };
423 
424 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrimOrigin);
425 
426 // ----------------------------------------------------------------------------
427 
446 {
447 public:
448  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrim);
449 
453  USDIMAGING_API
454  TfTokenVector GetNames() override;
455 
458  USDIMAGING_API
459  HdDataSourceBaseHandle Get(const TfToken &name) override;
460 
463  USDIMAGING_API
465  UsdPrim const& prim,
466  const TfToken &subprim,
467  const TfTokenVector &properties);
468 
469 protected:
482  USDIMAGING_API
484  const SdfPath &sceneIndexPath,
485  UsdPrim usdPrim,
486  const UsdImagingDataSourceStageGlobals &stageGlobals);
487 
488  // Accessors, for derived classes...
489  const SdfPath &_GetSceneIndexPath() const {
490  return _sceneIndexPath;
491  }
492 
493  const UsdPrim &_GetUsdPrim() const {
494  return _usdPrim;
495  }
496 
497  const UsdImagingDataSourceStageGlobals &_GetStageGlobals() const {
498  return _stageGlobals;
499  }
500 
501 private:
502  const SdfPath _sceneIndexPath;
503  UsdPrim _usdPrim;
504  const UsdImagingDataSourceStageGlobals &_stageGlobals;
505 
506  UsdImagingDataSourcePrimvarsAtomicHandle _primvars;
507 };
508 
509 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrim);
510 
511 PXR_NAMESPACE_CLOSE_SCOPE
512 
513 #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.
TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
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:110
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.
Data source to access the underlying UsdPrim.
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:204
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...
HdDataSourceBaseHandle Get(const TfToken &name) override
Get(UsdImagingTokens->usdPrim) returns a data source containing the underyling UsdPrim.
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.