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 USDIMAGING_GPRIM_ADAPTER_H
25 #define USDIMAGING_GPRIM_ADAPTER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usdImaging/usdImaging/api.h"
31 #include "pxr/usdImaging/usdImaging/primAdapter.h"
32 
33 #include "pxr/usd/usdGeom/xformCache.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 
38 class UsdGeomGprim;
39 
49 public:
51 
54  {}
55 
56  USDIMAGING_API
57  virtual ~UsdImagingGprimAdapter();
58 
59  // ---------------------------------------------------------------------- //
61  // ---------------------------------------------------------------------- //
62 
64  USDIMAGING_API
65  virtual void TrackVariability(UsdPrim const& prim,
66  SdfPath const& cachePath,
67  HdDirtyBits* timeVaryingBits,
69  instancerContext = NULL) const override;
70 
72  USDIMAGING_API
73  virtual void UpdateForTime(UsdPrim const& prim,
74  SdfPath const& cachePath,
75  UsdTimeCode time,
76  HdDirtyBits requestedBits,
78  instancerContext = NULL) const override;
79 
80  // ---------------------------------------------------------------------- //
82  // ---------------------------------------------------------------------- //
83 
84  USDIMAGING_API
85  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
86  SdfPath const& cachePath,
87  TfToken const& property) override;
88 
89  USDIMAGING_API
90  virtual void MarkDirty(UsdPrim const& prim,
91  SdfPath const& cachePath,
92  HdDirtyBits dirty,
93  UsdImagingIndexProxy* index) override;
94 
95  USDIMAGING_API
96  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
97  SdfPath const& cachePath,
98  UsdImagingIndexProxy* index) override;
99 
100  USDIMAGING_API
101  virtual void MarkReprDirty(UsdPrim const& prim,
102  SdfPath const& cachePath,
103  UsdImagingIndexProxy* index) override;
104 
105  USDIMAGING_API
106  virtual void MarkCullStyleDirty(UsdPrim const& prim,
107  SdfPath const& cachePath,
108  UsdImagingIndexProxy* index) override;
109 
110  USDIMAGING_API
111  virtual void MarkRenderTagDirty(UsdPrim const& prim,
112  SdfPath const& cachePath,
113  UsdImagingIndexProxy* index) override;
114 
115  USDIMAGING_API
116  virtual void MarkTransformDirty(UsdPrim const& prim,
117  SdfPath const& cachePath,
118  UsdImagingIndexProxy* index) override;
119 
120  USDIMAGING_API
121  virtual void MarkVisibilityDirty(UsdPrim const& prim,
122  SdfPath const& cachePath,
123  UsdImagingIndexProxy* index) override;
124 
125  USDIMAGING_API
126  virtual void MarkMaterialDirty(UsdPrim const& prim,
127  SdfPath const& cachePath,
128  UsdImagingIndexProxy* index) override;
129 
130  // ---------------------------------------------------------------------- //
132  // ---------------------------------------------------------------------- //
135  USDIMAGING_API
136  virtual VtValue GetPoints(UsdPrim const& prim,
137  SdfPath const& cachePath,
138  UsdTimeCode time) const;
139 
143  USDIMAGING_API
144  static bool GetColor(UsdPrim const& prim,
145  UsdTimeCode time,
146  TfToken *interpolation,
147  VtValue *color);
148 
152  USDIMAGING_API
153  static bool GetOpacity(UsdPrim const& prim,
154  UsdTimeCode time,
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.
160  USDIMAGING_API
161  SdfPath _AddRprim(TfToken const& primType,
162  UsdPrim const& usdPrim,
163  UsdImagingIndexProxy* index,
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.
169  USDIMAGING_API
170  static SdfPath _ResolveCachePath(SdfPath const& usdPath,
171  UsdImagingInstancerContext const* instancerContext);
172 
173 protected:
174 
175  USDIMAGING_API
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.
181  USDIMAGING_API
182  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
183 
184  // Utility for derived classes to try to find an inherited primvar.
185  USDIMAGING_API
186  UsdGeomPrimvar _GetInheritedPrimvar(UsdPrim const& prim,
187  TfToken const& primvarName) const;
188 
189 private:
190 
193  GfRange3d _GetExtent(UsdPrim const& prim, UsdTimeCode time) const;
194 
196  bool _GetDoubleSided(UsdPrim const& prim) const;
197 };
198 
199 
200 PXR_NAMESPACE_CLOSE_SCOPE
201 
202 #endif //USDIMAGING_GPRIM_ADAPTER_H
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
virtual USDIMAGING_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
virtual USDIMAGING_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
Delegate support for UsdGeomGrims.
Definition: gprimAdapter.h:48
static USDIMAGING_API bool GetOpacity(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *opacity)
Returns opacity and Usd interpolation token for a given prim, taking into account surface shader opac...
virtual USDIMAGING_API VtValue GetPoints(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Give derived classes an opportunity to override how we get points for a prim.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
static USDIMAGING_API bool GetColor(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *color)
Returns color and Usd interpolation token for a given prim, taking into account surface shader colors...
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
Base class for all PrimAdapters.
Definition: primAdapter.h:67
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:131
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Base class for all geometric primitives.
Definition: gprim.h:66
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars...
Definition: primvar.h:260
virtual USDIMAGING_API HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &property) override
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182