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 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_GPRIM_ADAPTER_H
25 #define PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
26 
27 /// \file usdImaging/gprimAdapter.h
28 
29 #include "pxr/pxr.h"
32 
34 
36 
37 
38 class UsdGeomGprim;
39 
40 /// \class UsdImagingGprimAdapter
41 ///
42 /// Delegate support for UsdGeomGrims.
43 ///
44 /// This adapter is provided as a base class for all adapters that want basic
45 /// Gprim data support, such as visibility, doubleSided, extent, displayColor,
46 /// displayOpacity, purpose, and transform.
47 ///
49 {
50 public:
52 
55  {}
56 
58  ~UsdImagingGprimAdapter() override;
59 
60  // ---------------------------------------------------------------------- //
61  /// \name Parallel Setup and Resolve
62  // ---------------------------------------------------------------------- //
63 
64  /// Thread Safe.
66  void TrackVariability(UsdPrim const& prim,
67  SdfPath const& cachePath,
68  HdDirtyBits* timeVaryingBits,
70  instancerContext = nullptr) const override;
71 
72  /// Thread Safe.
74  void UpdateForTime(UsdPrim const& prim,
75  SdfPath const& cachePath,
77  HdDirtyBits requestedBits,
79  instancerContext = nullptr) const override;
80 
81  // ---------------------------------------------------------------------- //
82  /// \name Change Processing
83  // ---------------------------------------------------------------------- //
84 
86  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
87  SdfPath const& cachePath,
88  TfToken const& property) override;
89 
91  virtual void MarkDirty(UsdPrim const& prim,
92  SdfPath const& cachePath,
93  HdDirtyBits dirty,
94  UsdImagingIndexProxy* index) override;
95 
97  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
98  SdfPath const& cachePath,
99  UsdImagingIndexProxy* index) override;
100 
102  virtual void MarkReprDirty(UsdPrim const& prim,
103  SdfPath const& cachePath,
104  UsdImagingIndexProxy* index) override;
105 
107  virtual void MarkCullStyleDirty(UsdPrim const& prim,
108  SdfPath const& cachePath,
109  UsdImagingIndexProxy* index) override;
110 
112  virtual void MarkRenderTagDirty(UsdPrim const& prim,
113  SdfPath const& cachePath,
114  UsdImagingIndexProxy* index) override;
115 
117  virtual void MarkTransformDirty(UsdPrim const& prim,
118  SdfPath const& cachePath,
119  UsdImagingIndexProxy* index) override;
120 
122  virtual void MarkVisibilityDirty(UsdPrim const& prim,
123  SdfPath const& cachePath,
124  UsdImagingIndexProxy* index) override;
125 
127  virtual void MarkMaterialDirty(UsdPrim const& prim,
128  SdfPath const& cachePath,
129  UsdImagingIndexProxy* index) override;
130 
132  virtual void MarkCollectionsDirty(UsdPrim const& prim,
133  SdfPath const& cachePath,
134  UsdImagingIndexProxy* index) override;
135 
136  // ---------------------------------------------------------------------- //
137  /// \name Utility methods
138  // ---------------------------------------------------------------------- //
139  /// Give derived classes an opportunity to override how we get points for
140  /// a prim. This is useful for implicit primitives.
142  virtual VtValue GetPoints(UsdPrim const& prim,
143  UsdTimeCode time) const;
144 
145  /// Returns color, Usd interpolation token, and optionally color indices for
146  /// a given prim, taking into account surface shader colors and explicitly
147  /// authored color on the prim. If indices is not nullptr and the color
148  /// value has indices, color will be set to the unflattened color value and
149  /// indices set to the color value's indices.
151  static bool GetColor(UsdPrim const& prim,
153  TfToken *interpolation,
154  VtValue *color,
155  VtIntArray *indices);
156 
157  /// Returns opacity, Usd interpolation token, and optionally opacity indices
158  /// for a given prim, taking into account surface shader opacity and
159  /// explicitly authored opacity on the prim. If indices is not nullptr and
160  /// the opacity value has indices, opacity will be set to the unflattened
161  /// opacity value and indices set to the opacity value's indices.
163  static bool GetOpacity(UsdPrim const& prim,
165  TfToken *interpolation,
166  VtValue *opacity,
167  VtIntArray *indices);
168 
169  // Helper function: add a given type of rprim, potentially with instancer
170  // name mangling, and add any bound shader.
172  SdfPath _AddRprim(TfToken const& primType,
173  UsdPrim const& usdPrim,
175  SdfPath const& materialUsdPath,
176  UsdImagingInstancerContext const* instancerContext);
177 
178  // Helper function: map USD path to UsdImaging cache path,
179  // applying any name-encoding required by the instancerContext.
181  static SdfPath _ResolveCachePath(SdfPath const& usdPath,
182  UsdImagingInstancerContext const* instancerContext);
183 
184  /// Reads the extent from the given prim. If the extent is not authored,
185  /// an empty GfRange3d is returned, the extent will not be computed.
187  GfRange3d GetExtent(UsdPrim const& prim,
188  SdfPath const& cachePath,
189  UsdTimeCode time) const override;
190 
191  /// Reads double-sided from the given prim. If not authored, returns false
193  bool GetDoubleSided(UsdPrim const& prim,
194  SdfPath const& cachePath,
195  UsdTimeCode time) const override;
196 
198  SdfPath GetMaterialId(UsdPrim const& prim,
199  SdfPath const& cachePath,
200  UsdTimeCode time) const override;
201  /// Gets the value of the parameter named key for the given prim (which
202  /// has the given cache path) and given time. If outIndices is not nullptr
203  /// and the value has indices, it will return the unflattened value and set
204  /// outIndices to the value's associated indices.
206  VtValue Get(UsdPrim const& prim,
207  SdfPath const& cachePath,
208  TfToken const& key,
210  VtIntArray *outIndices) const override;
211 
212 protected:
213 
215  virtual void _RemovePrim(SdfPath const& cachePath,
216  UsdImagingIndexProxy* index) override;
217 
218  // Give derived classes an opportunity to block GprimAdapter processing
219  // of certain primvars.
221  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
222 
223  // Utility for gathering the names of primvars used by the gprim's
224  // materials, used in primvar filtering.
227  SdfPathVector const& materialUsdPaths,
228  UsdTimeCode time) const;
229 
230  /// Returns the primvar names known to be supported for the rprims
231  /// this adapter produces. These primvar names are excepted from primvar
232  /// filtering.
234  virtual TfTokenVector const& _GetRprimPrimvarNames() const;
235 };
236 
237 
239 
240 #endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
virtual USDIMAGING_API HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &property) override
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.
static USDIMAGING_API SdfPath _ResolveCachePath(SdfPath const &usdPath, UsdImagingInstancerContext const *instancerContext)
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:40
GT_API const UT_StringHolder time
uint32_t HdDirtyBits
Definition: types.h:158
GLuint color
Definition: glcorearb.h:1261
virtual USDIMAGING_API void MarkDirty(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits dirty, UsdImagingIndexProxy *index) override
USDIMAGING_API VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const 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
virtual USDIMAGING_API void MarkMaterialDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
virtual USDIMAGING_API void MarkRenderTagDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Definition: token.h:87
virtual USDIMAGING_API void MarkReprDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
virtual USDIMAGING_API void MarkVisibilityDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
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)
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
INT property
Definition: wglew.h:145
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
virtual USDIMAGING_API void MarkRefineLevelDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Definition: path.h:290
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:211
virtual USDIMAGING_API void MarkCullStyleDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
static USDIMAGING_API bool GetOpacity(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *opacity, VtIntArray *indices)
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:91
virtual USDIMAGING_API void MarkCollectionsDirty(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)
virtual USDIMAGING_API void _RemovePrim(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API ~UsdImagingGprimAdapter() override
Definition: value.h:166
virtual USDIMAGING_API void MarkTransformDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
virtual USDIMAGING_API TfTokenVector _CollectMaterialPrimvars(SdfPathVector const &materialUsdPaths, UsdTimeCode time) const