HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gprimAdapter.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_GPRIM_ADAPTER_H
8 #define PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
9 
10 /// \file usdImaging/gprimAdapter.h
11 
12 #include "pxr/pxr.h"
15 
17 
19 
20 
21 class UsdGeomGprim;
22 
23 /// \class UsdImagingGprimAdapter
24 ///
25 /// Delegate support for UsdGeomGrims.
26 ///
27 /// This adapter is provided as a base class for all adapters that want basic
28 /// Gprim data support, such as visibility, doubleSided, extent, displayColor,
29 /// displayOpacity, purpose, and transform.
30 ///
32 {
33 public:
35 
36  // ---------------------------------------------------------------------- //
37  /// \name Scene Index Support
38  // ---------------------------------------------------------------------- //
39 
42  UsdPrim const& prim,
43  TfToken const& subprim,
44  TfTokenVector const& properties,
45  UsdImagingPropertyInvalidationType invalidationType) override;
46  // ---------------------------------------------------------------------- //
47  /// \name Parallel Setup and Resolve
48  // ---------------------------------------------------------------------- //
49 
50  /// Thread Safe.
52  void TrackVariability(UsdPrim const& prim,
53  SdfPath const& cachePath,
54  HdDirtyBits* timeVaryingBits,
56  instancerContext = nullptr) const override;
57 
58  /// Thread Safe.
60  void UpdateForTime(UsdPrim const& prim,
61  SdfPath const& cachePath,
63  HdDirtyBits requestedBits,
65  instancerContext = nullptr) const override;
66 
67  // ---------------------------------------------------------------------- //
68  /// \name Change Processing
69  // ---------------------------------------------------------------------- //
70 
73  SdfPath const& cachePath,
74  TfToken const& property) override;
75 
77  void MarkDirty(UsdPrim const& prim,
78  SdfPath const& cachePath,
79  HdDirtyBits dirty,
80  UsdImagingIndexProxy* index) override;
81 
83  void MarkRefineLevelDirty(UsdPrim const& prim,
84  SdfPath const& cachePath,
85  UsdImagingIndexProxy* index) override;
86 
88  void MarkReprDirty(UsdPrim const& prim,
89  SdfPath const& cachePath,
90  UsdImagingIndexProxy* index) override;
91 
93  void MarkCullStyleDirty(UsdPrim const& prim,
94  SdfPath const& cachePath,
95  UsdImagingIndexProxy* index) override;
96 
98  void MarkRenderTagDirty(UsdPrim const& prim,
99  SdfPath const& cachePath,
100  UsdImagingIndexProxy* index) override;
101 
103  void MarkTransformDirty(UsdPrim const& prim,
104  SdfPath const& cachePath,
105  UsdImagingIndexProxy* index) override;
106 
108  void MarkVisibilityDirty(UsdPrim const& prim,
109  SdfPath const& cachePath,
110  UsdImagingIndexProxy* index) override;
111 
113  void MarkMaterialDirty(UsdPrim const& prim,
114  SdfPath const& cachePath,
115  UsdImagingIndexProxy* index) override;
116 
118  void MarkCollectionsDirty(UsdPrim const& prim,
119  SdfPath const& cachePath,
120  UsdImagingIndexProxy* index) override;
121 
122  // ---------------------------------------------------------------------- //
123  /// \name Utility methods
124  // ---------------------------------------------------------------------- //
125  /// Give derived classes an opportunity to override how we get points for
126  /// a prim. This is useful for implicit primitives.
128  virtual VtValue GetPoints(UsdPrim const& prim,
129  UsdTimeCode time) const;
130 
131  /// Returns color, Usd interpolation token, and optionally color indices for
132  /// a given prim, taking into account surface shader colors and explicitly
133  /// authored color on the prim. If indices is not nullptr and the color
134  /// value has indices, color will be set to the unflattened color value and
135  /// indices set to the color value's indices.
137  static bool GetColor(UsdPrim const& prim,
139  TfToken *interpolation,
140  VtValue *color,
141  VtIntArray *indices);
142 
143  /// Returns opacity, Usd interpolation token, and optionally opacity indices
144  /// for a given prim, taking into account surface shader opacity and
145  /// explicitly authored opacity on the prim. If indices is not nullptr and
146  /// the opacity value has indices, opacity will be set to the unflattened
147  /// opacity value and indices set to the opacity value's indices.
149  static bool GetOpacity(UsdPrim const& prim,
151  TfToken *interpolation,
152  VtValue *opacity,
153  VtIntArray *indices);
154 
155  // Helper function: add a given type of rprim, potentially with instancer
156  // name mangling, and add any bound shader.
158  SdfPath _AddRprim(TfToken const& primType,
159  UsdPrim const& usdPrim,
161  SdfPath const& materialUsdPath,
162  UsdImagingInstancerContext const* instancerContext);
163 
164  /// Reads the extent from the given prim. If the extent is not authored,
165  /// an empty GfRange3d is returned, the extent will not be computed.
167  GfRange3d GetExtent(UsdPrim const& prim,
168  SdfPath const& cachePath,
169  UsdTimeCode time) const override;
170 
171  /// Reads double-sided from the given prim. If not authored, returns false
173  bool GetDoubleSided(UsdPrim const& prim,
174  SdfPath const& cachePath,
175  UsdTimeCode time) const override;
176 
178  SdfPath GetMaterialId(UsdPrim const& prim,
179  SdfPath const& cachePath,
180  UsdTimeCode time) const override;
181  /// Gets the value of the parameter named key for the given prim (which
182  /// has the given cache path) and given time. If outIndices is not nullptr
183  /// and the value has indices, it will return the unflattened value and set
184  /// outIndices to the value's associated indices.
186  VtValue Get(UsdPrim const& prim,
187  SdfPath const& cachePath,
188  TfToken const& key,
190  VtIntArray *outIndices) const override;
191 
192  // For implicit prims such as capsules, cones, cylinders and planes, the
193  // "spine" axis along or about which the surface is aligned may be
194  // specified. This utility method returns a basis matrix that transforms
195  // points generated using "Z" as the spine axis to the desired axis.
197  static GfMatrix4d GetImplicitBasis(TfToken const &spineAxis);
198 
199 protected:
200 
202  void _RemovePrim(SdfPath const& cachePath,
203  UsdImagingIndexProxy* index) override;
204 
205  // Give derived classes an opportunity to block GprimAdapter processing
206  // of certain primvars.
208  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
209 
210  // Utility for gathering the names of primvars used by the gprim's
211  // materials, used in primvar filtering.
214  SdfPathVector const& materialUsdPaths,
215  UsdTimeCode time) const;
216 
217  /// Returns the primvar names known to be supported for the rprims
218  /// this adapter produces. These primvar names are excepted from primvar
219  /// filtering.
221  virtual TfTokenVector const& _GetRprimPrimvarNames() const;
222 };
223 
225 
226 #endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
USDIMAGING_API void _RemovePrim(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
USDIMAGING_API bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads double-sided from the given prim. If not authored, returns false.
USDIMAGING_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=nullptr) const override
Thread Safe.
#define USDIMAGING_API
Definition: api.h:23
USDIMAGING_API HdDataSourceLocatorSet InvalidateImagingSubprim(UsdPrim const &prim, TfToken const &subprim, TfTokenVector const &properties, UsdImagingPropertyInvalidationType invalidationType) override
GT_API const UT_StringHolder time
static USDIMAGING_API GfMatrix4d GetImplicitBasis(TfToken const &spineAxis)
uint32_t HdDirtyBits
Definition: types.h:143
USDIMAGING_API VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const override
USDIMAGING_API void MarkRefineLevelDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=nullptr) const override
Thread Safe.
virtual USDIMAGING_API TfTokenVector const & _GetRprimPrimvarNames() const
virtual USDIMAGING_API bool _IsBuiltinPrimvar(TfToken const &primvarName) const
Definition: token.h:70
std::vector< class SdfPath > SdfPathVector
USDIMAGING_API SdfPath GetMaterialId(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
static USDIMAGING_API bool GetColor(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *color, VtIntArray *indices)
USDIMAGING_API void MarkRenderTagDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Definition: prim.h:116
USDIMAGING_API void MarkCollectionsDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
USDIMAGING_API void MarkDirty(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits dirty, UsdImagingIndexProxy *index) override
USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
USDIMAGING_API void MarkCullStyleDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
static USDIMAGING_API bool GetOpacity(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *opacity, VtIntArray *indices)
GLuint color
Definition: glcorearb.h:1261
GLuint index
Definition: glcorearb.h:786
virtual USDIMAGING_API VtValue GetPoints(UsdPrim const &prim, UsdTimeCode time) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDIMAGING_API void MarkVisibilityDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &property) override
USDIMAGING_API void MarkMaterialDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API void MarkReprDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API SdfPath _AddRprim(TfToken const &primType, UsdPrim const &usdPrim, UsdImagingIndexProxy *index, SdfPath const &materialUsdPath, UsdImagingInstancerContext const *instancerContext)
USDIMAGING_API void MarkTransformDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Definition: value.h:146
virtual USDIMAGING_API TfTokenVector _CollectMaterialPrimvars(SdfPathVector const &materialUsdPaths, UsdTimeCode time) const
UsdImagingPropertyInvalidationType
Definition: types.h:17