Loading...
Searching...
No Matches
dataSourcePrimvars.h
1//
2// Copyright 2022 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_PRIMVARS_H
8#define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_PRIMVARS_H
9
10#include "pxr/usdImaging/usdImaging/dataSourceAttribute.h"
11#include "pxr/usdImaging/usdImaging/dataSourceStageGlobals.h"
12
13#include "pxr/usd/usdGeom/primvar.h"
15
16PXR_NAMESPACE_OPEN_SCOPE
17
25{
26public:
27 HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrimvars);
28
30 HdDataSourceBaseHandle Get(const TfToken &name) override;
31
32private:
34 const SdfPath &sceneIndexPath,
35 UsdPrim const &usdPrim,
36 const UsdImagingDataSourceStageGlobals &stageGlobals);
37
38private:
39 static TfToken _GetPrefixedName(const TfToken &name);
40
41 // Path of the owning prim.
42 SdfPath _sceneIndexPath;
43
44 UsdPrim _usdPrim;
45
46 // Stage globals handle.
47 const UsdImagingDataSourceStageGlobals &_stageGlobals;
48};
49
50HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrimvars);
51
52// ----------------------------------------------------------------------------
53
54class UsdImagingDataSourceCustomPrimvars : public HdContainerDataSource
55{
56public:
57 HD_DECLARE_DATASOURCE(UsdImagingDataSourceCustomPrimvars);
58
59 USDIMAGING_API
60 TfTokenVector GetNames() override;
61
62 USDIMAGING_API
63 HdDataSourceBaseHandle Get(const TfToken &name) override;
64
65 struct Mapping {
66 Mapping(
67 const TfToken &primvarName,
68 const TfToken &usdAttrName,
69 const TfToken &interpolation = TfToken())
70 : primvarName(primvarName)
71 , usdAttrName(usdAttrName)
72 , interpolation(interpolation)
73 { }
74
75 TfToken primvarName;
76 TfToken usdAttrName;
77 TfToken interpolation;
78 };
79
80 // This map is passed to the constructor to specify non-"primvars:"
81 // attributes to include as primvars (e.g., "points" and "normals").
82 // The first token is the datasource name, and the second the USD name.
83 using Mappings = std::vector<Mapping>;
84
85 USDIMAGING_API
86 static HdDataSourceLocatorSet Invalidate(
87 const TfTokenVector &properties,
88 const Mappings &mappings);
89
90private:
91 UsdImagingDataSourceCustomPrimvars(
92 const SdfPath &sceneIndexPath,
93 UsdPrim const &usdPrim,
94 const Mappings &mappings,
95 const UsdImagingDataSourceStageGlobals &stageGlobals);
96
97 // Path of the owning prim.
98 SdfPath _sceneIndexPath;
99
100 UsdPrim _usdPrim;
101
102 // Stage globals handle.
103 const UsdImagingDataSourceStageGlobals &_stageGlobals;
104
105 const Mappings _mappings;
106};
107
108HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceCustomPrimvars);
109
110// ----------------------------------------------------------------------------
111
125{
126public:
127 HD_DECLARE_DATASOURCE(UsdImagingDataSourcePrimvar);
128
130 HdDataSourceBaseHandle Get(const TfToken & name) override;
131
132private:
134 const SdfPath &sceneIndexPath,
135 const TfToken &name,
136 const UsdImagingDataSourceStageGlobals &stageGlobals,
137 UsdAttributeQuery valueQuery,
138 UsdAttributeQuery indicesQuery,
139 HdTokenDataSourceHandle interpolation,
140 HdTokenDataSourceHandle role,
141 HdIntDataSourceHandle elementSize = nullptr);
142
143private:
144 const UsdImagingDataSourceStageGlobals &_stageGlobals;
145 UsdAttributeQuery _valueQuery;
146 UsdAttributeQuery _indicesQuery;
147 HdTokenDataSourceHandle _interpolation;
148 HdTokenDataSourceHandle _role;
149 HdIntDataSourceHandle _elementSize;
150};
151
152HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourcePrimvar);
153
154PXR_NAMESPACE_CLOSE_SCOPE
155
156#endif // PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_PRIMVARS_H
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
Definition: dataSource.h:99
virtual TfTokenVector GetNames()=0
Returns the list of names for which Get(...) is expected to return a non-null value.
virtual HdDataSourceBaseHandle Get(const TfToken &name)=0
Returns the child datasource of the given name.
Represents a set of data source locators closed under descendancy.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Object for efficiently making repeated queries for attribute values.
A data source representing a primvar.
TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
Data source representing USD primvars.
TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
This class is used as a context object with global stage information, that gets passed down to dataso...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440