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 #include "pxr/usdImaging/usdImaging/types.h"
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
47 {
48 public:
49  HD_DECLARE_DATASOURCE(UsdImagingDataSourceVisibility);
50 
54  TfTokenVector GetNames() override;
55 
59  HdDataSourceBaseHandle Get(const TfToken &name) override;
60 
61 private:
70  const UsdAttributeQuery &visibilityQuery,
71  const SdfPath &sceneIndexPath,
72  const UsdImagingDataSourceStageGlobals &stageGlobals);
73 
74 private:
75  UsdAttributeQuery _visibilityQuery;
76  const UsdImagingDataSourceStageGlobals &_stageGlobals;
77 };
78 
79 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceVisibility);
80 
81 
82 // ----------------------------------------------------------------------------
83 
88 {
89 public:
90  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePurpose);
91 
95  TfTokenVector GetNames() override;
96 
100  HdDataSourceBaseHandle Get(const TfToken &name) override;
101 
102 private:
110  const UsdAttributeQuery &purposeQuery,
111  const UsdImagingDataSourceStageGlobals &stageGlobals);
112 
113 private:
114  UsdAttributeQuery _purposeQuery;
115  const UsdImagingDataSourceStageGlobals &_stageGlobals;
116 };
117 
118 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePurpose);
119 
120 
121 // ----------------------------------------------------------------------------
122 
128 {
129 public:
130  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtentCoordinate);
131 
133  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
134 
136  GfVec3d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
137 
141  HdSampledDataSource::Time startTime,
142  HdSampledDataSource::Time endTime,
143  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
144 
145 private:
154  const HdVec3fArrayDataSourceHandle &extentDs,
155  const SdfPath &attrPath,
156  unsigned int index);
157 
158 private:
159  HdVec3fArrayDataSourceHandle _extentDs;
160  SdfPath _attrPath;
161  unsigned int _index;
162 };
163 
164 // ----------------------------------------------------------------------------
165 
170 {
171 public:
172  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtent);
173 
177  TfTokenVector GetNames() override;
178 
182  HdDataSourceBaseHandle Get(const TfToken &name) override;
183 
184 private:
193  const UsdAttributeQuery &extentQuery,
194  const SdfPath &sceneIndexPath,
195  const UsdImagingDataSourceStageGlobals &stageGlobals);
196 
197 private:
198  // Note: the constructor takes sceneIndexPath for change-tracking,
199  // but here we're storing the USD attribute path for error reporting!
200  SdfPath _attrPath;
201  HdVec3fArrayDataSourceHandle _extentDs;
202 };
203 
204 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceExtent);
205 
206 // ----------------------------------------------------------------------------
207 
212 {
213 public:
214  HD_DECLARE_DATASOURCE(UsdImagingDataSourceExtentsHint);
215 
218  size_t GetNumElements() override;
219 
222  HdDataSourceBaseHandle GetElement(size_t element) override;
223 
224 private:
233  const UsdAttributeQuery &extentQuery,
234  const SdfPath &sceneIndexPath,
235  const UsdImagingDataSourceStageGlobals &stageGlobals);
236 
237 private:
238  // Note: the constructor takes sceneIndexPath for change-tracking,
239  // but here we're storing the USD attribute path for error reporting!
240  SdfPath _attrPath;
241  HdVec3fArrayDataSourceHandle _extentDs;
242 };
243 
244 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceExtent);
245 
246 
247 // ----------------------------------------------------------------------------
248 
254 {
255 public:
256  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformResetXformStack);
257 
259  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
260 
262  bool GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
263 
267  HdSampledDataSource::Time startTime,
268  HdSampledDataSource::Time endTime,
269  std::vector<HdSampledDataSource::Time> *outSampleTimes) override {
270  return false;
271  }
272 
273 private:
284  const UsdGeomXformable::XformQuery &xformQuery,
285  const UsdImagingDataSourceStageGlobals &stageGlobals);
286 
287 private:
288  UsdGeomXformable::XformQuery _xformQuery;
289  const UsdImagingDataSourceStageGlobals &_stageGlobals;
290 };
291 
292 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformResetXformStack);
293 
294 // ----------------------------------------------------------------------------
295 
303 {
304 public:
305 
306  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXformMatrix);
307 
311  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override;
312 
316  GfMatrix4d GetTypedValue(HdSampledDataSource::Time shutterOffset) override;
317 
322  HdSampledDataSource::Time startTime,
323  HdSampledDataSource::Time endTime,
324  std::vector<HdSampledDataSource::Time> *outSampleTimes) override;
325 
326 private:
337  const UsdGeomXformable::XformQuery &xformQuery,
338  const UsdImagingDataSourceStageGlobals &stageGlobals);
339 
340 private:
341  UsdGeomXformable::XformQuery _xformQuery;
342  const UsdImagingDataSourceStageGlobals &_stageGlobals;
343 };
344 
345 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXformMatrix);
346 
347 // ----------------------------------------------------------------------------
348 
359 {
360 public:
361  HD_DECLARE_DATASOURCE(UsdImagingDataSourceXform);
362 
367  TfTokenVector GetNames() override;
368 
373  HdDataSourceBaseHandle Get(const TfToken &name) override;
374 
375 private:
386  const UsdGeomXformable::XformQuery &xformQuery,
387  const SdfPath &sceneIndexPath,
388  const UsdImagingDataSourceStageGlobals &stageGlobals);
389 
390 private:
391  UsdGeomXformable::XformQuery _xformQuery;
392  const UsdImagingDataSourceStageGlobals &_stageGlobals;
393 };
394 
395 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceXform);
396 
397 // ----------------------------------------------------------------------------
398 
405 {
406 public:
407  HD_DECLARE_DATASOURCE(UsdImagingDataSourceModel);
408 
411  TfTokenVector GetNames() override;
412 
416  HdDataSourceBaseHandle Get(const TfToken &name) override;
417 
418 private:
428  const UsdGeomModelAPI &model,
429  const SdfPath &sceneIndexPath,
430  const UsdImagingDataSourceStageGlobals &stageGlobals);
431 
432 private:
433  UsdGeomModelAPI _model;
434  const SdfPath _sceneIndexPath;
435  const UsdImagingDataSourceStageGlobals &_stageGlobals;
436 };
437 
438 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceModel);
439 
440 // ----------------------------------------------------------------------------
441 
448 {
449 public:
450  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrimOrigin);
451 
452  TfTokenVector GetNames() override;
453 
456  HdDataSourceBaseHandle Get(const TfToken &name) override;
457 
458 private:
459  UsdImagingDataSourcePrimOrigin(const UsdPrim &usdPrim);
460 
461 private:
462  UsdPrim _usdPrim;
463 };
464 
465 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrimOrigin);
466 
467 // ----------------------------------------------------------------------------
468 
487 {
488 public:
489  HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrim);
490 
494  USDIMAGING_API
495  TfTokenVector GetNames() override;
496 
499  USDIMAGING_API
500  HdDataSourceBaseHandle Get(const TfToken &name) override;
501 
504  USDIMAGING_API
506  UsdPrim const& prim,
507  const TfToken &subprim,
508  const TfTokenVector &properties,
509  UsdImagingPropertyInvalidationType invalidationType);
510 
511 protected:
524  USDIMAGING_API
526  const SdfPath &sceneIndexPath,
527  UsdPrim usdPrim,
528  const UsdImagingDataSourceStageGlobals &stageGlobals);
529 
530  // Accessors, for derived classes...
531  const SdfPath &_GetSceneIndexPath() const {
532  return _sceneIndexPath;
533  }
534 
535  const UsdPrim &_GetUsdPrim() const {
536  return _usdPrim;
537  }
538 
539  const UsdImagingDataSourceStageGlobals &_GetStageGlobals() const {
540  return _stageGlobals;
541  }
542 
543 private:
544  const SdfPath _sceneIndexPath;
545  UsdPrim _usdPrim;
546  const UsdImagingDataSourceStageGlobals &_stageGlobals;
547 };
548 
549 HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrim);
550 
551 PXR_NAMESPACE_CLOSE_SCOPE
552 
553 #endif // PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_PRIM_H
A datasource representing indexed data.
Definition: dataSource.h:142
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
size_t GetNumElements() override
Returns number of vec3 pairs authored on extentsHint.
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:87
static USDIMAGING_API HdDataSourceLocatorSet Invalidate(UsdPrim const &prim, const TfToken &subprim, const TfTokenVector &properties, UsdImagingPropertyInvalidationType invalidationType)
Returns the hydra attribute set we should invalidate if the value of the USD properties in properties...
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:135
Data source representing extents hint of a model API prim.
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.
GfMatrix4d GetTypedValue(HdSampledDataSource::Time shutterOffset) override
Returns GfMatrix4d at a given shutterOffset for the value of this xform.
HdDataSourceBaseHandle GetElement(size_t element) override
Returns i-th pair of vec3 authored on extentsHint as extent schema.
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:62
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.