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 public:
51 
54  {}
55 
57  virtual ~UsdImagingGprimAdapter();
58 
59  // ---------------------------------------------------------------------- //
60  /// \name Parallel Setup and Resolve
61  // ---------------------------------------------------------------------- //
62 
63  /// Thread Safe.
65  virtual void TrackVariability(UsdPrim const& prim,
66  SdfPath const& cachePath,
67  HdDirtyBits* timeVaryingBits,
69  instancerContext = NULL) const override;
70 
71  /// Thread Safe.
73  virtual void UpdateForTime(UsdPrim const& prim,
74  SdfPath const& cachePath,
76  HdDirtyBits requestedBits,
78  instancerContext = NULL) const override;
79 
80  // ---------------------------------------------------------------------- //
81  /// \name Change Processing
82  // ---------------------------------------------------------------------- //
83 
85  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
86  SdfPath const& cachePath,
87  TfToken const& property) override;
88 
90  virtual void MarkDirty(UsdPrim const& prim,
91  SdfPath const& cachePath,
92  HdDirtyBits dirty,
93  UsdImagingIndexProxy* index) override;
94 
96  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
97  SdfPath const& cachePath,
98  UsdImagingIndexProxy* index) override;
99 
101  virtual void MarkReprDirty(UsdPrim const& prim,
102  SdfPath const& cachePath,
103  UsdImagingIndexProxy* index) override;
104 
106  virtual void MarkCullStyleDirty(UsdPrim const& prim,
107  SdfPath const& cachePath,
108  UsdImagingIndexProxy* index) override;
109 
111  virtual void MarkRenderTagDirty(UsdPrim const& prim,
112  SdfPath const& cachePath,
113  UsdImagingIndexProxy* index) override;
114 
116  virtual void MarkTransformDirty(UsdPrim const& prim,
117  SdfPath const& cachePath,
118  UsdImagingIndexProxy* index) override;
119 
121  virtual void MarkVisibilityDirty(UsdPrim const& prim,
122  SdfPath const& cachePath,
123  UsdImagingIndexProxy* index) override;
124 
126  virtual void MarkMaterialDirty(UsdPrim const& prim,
127  SdfPath const& cachePath,
128  UsdImagingIndexProxy* index) override;
129 
130  // ---------------------------------------------------------------------- //
131  /// \name Utility methods
132  // ---------------------------------------------------------------------- //
133  /// Give derived classes an opportunity to override how we get points for
134  /// a prim. This is useful for implicit primitives.
136  virtual VtValue GetPoints(UsdPrim const& prim,
137  SdfPath const& cachePath,
138  UsdTimeCode time) const;
139 
140  /// Returns color and Usd interpolation token for a given
141  /// prim, taking into account surface shader colors and explicitly
142  /// authored color on the prim.
144  static bool GetColor(UsdPrim const& prim,
146  TfToken *interpolation,
147  VtValue *color);
148 
149  /// Returns opacity and Usd interpolation token for a given
150  /// prim, taking into account surface shader opacity and explicitly
151  /// authored opacity on the prim.
153  static bool GetOpacity(UsdPrim const& prim,
155  TfToken *interpolation,
156  VtValue *opacity);
157 
158  // Helper function: add a given type of rprim, potentially with instancer
159  // name mangling, and add any bound shader.
161  SdfPath _AddRprim(TfToken const& primType,
162  UsdPrim const& usdPrim,
164  SdfPath const& materialUsdPath,
165  UsdImagingInstancerContext const* instancerContext);
166 
167  // Helper function: map USD path to UsdImaging cache path,
168  // applying any name-encoding required by the instancerContext.
170  static SdfPath _ResolveCachePath(SdfPath const& usdPath,
171  UsdImagingInstancerContext const* instancerContext);
172 
173 protected:
174 
176  virtual void _RemovePrim(SdfPath const& cachePath,
177  UsdImagingIndexProxy* index) override;
178 
179  // Give derived classes an opportunity to block GprimAdapter processing
180  // of certain primvars.
182  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
183 
184  // Utility for derived classes to try to find an inherited primvar.
187  TfToken const& primvarName) const;
188 
189 private:
190 
191  /// Reads the extent from the given prim. If the extent is not authored,
192  /// an empty GfRange3d is returned, the extent will not be computed.
193  GfRange3d _GetExtent(UsdPrim const& prim, UsdTimeCode time) const;
194 
195  /// Returns the doubleSided state for a given prim.
196  bool _GetDoubleSided(UsdPrim const& prim) const;
197 };
198 
199 
201 
202 #endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
virtual USDIMAGING_API HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &property) override
static USDIMAGING_API SdfPath _ResolveCachePath(SdfPath const &usdPath, UsdImagingInstancerContext const *instancerContext)
#define USDIMAGING_API
Definition: api.h:40
static USDIMAGING_API bool GetColor(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *color)
GT_API const UT_StringHolder time
GLuint index
Definition: glew.h:1814
uint32_t HdDirtyBits
Definition: types.h:127
virtual USDIMAGING_API void MarkDirty(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits dirty, UsdImagingIndexProxy *index) override
virtual USDIMAGING_API VtValue GetPoints(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
USDIMAGING_API UsdGeomPrimvar _GetInheritedPrimvar(UsdPrim const &prim, TfToken const &primvarName) 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
static USDIMAGING_API bool GetOpacity(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *opacity)
INT property
Definition: wglew.h:145
Definition: prim.h:132
virtual USDIMAGING_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
virtual USDIMAGING_API void MarkRefineLevelDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
GLuint color
Definition: glew.h:7902
Definition: path.h:288
virtual USDIMAGING_API ~UsdImagingGprimAdapter()
virtual USDIMAGING_API void MarkCullStyleDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
UsdImagingPrimAdapter BaseAdapter
Definition: gprimAdapter.h:50
virtual USDIMAGING_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
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
Definition: value.h:174
virtual USDIMAGING_API void MarkTransformDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override