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 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usdImaging/usdImaging/api.h"
32 
33 #include "pxr/usd/usdGeom/xformCache.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 
38 class UsdGeomGprim;
39 
49 {
50 public:
52 
55  {}
56 
57  USDIMAGING_API
58  ~UsdImagingGprimAdapter() override;
59 
60  // ---------------------------------------------------------------------- //
62  // ---------------------------------------------------------------------- //
63 
65  USDIMAGING_API
66  void TrackVariability(UsdPrim const& prim,
67  SdfPath const& cachePath,
68  HdDirtyBits* timeVaryingBits,
70  instancerContext = nullptr) const override;
71 
73  USDIMAGING_API
74  void UpdateForTime(UsdPrim const& prim,
75  SdfPath const& cachePath,
76  UsdTimeCode time,
77  HdDirtyBits requestedBits,
79  instancerContext = nullptr) const override;
80 
81  // ---------------------------------------------------------------------- //
83  // ---------------------------------------------------------------------- //
84 
85  USDIMAGING_API
86  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
87  SdfPath const& cachePath,
88  TfToken const& property) override;
89 
90  USDIMAGING_API
91  virtual void MarkDirty(UsdPrim const& prim,
92  SdfPath const& cachePath,
93  HdDirtyBits dirty,
94  UsdImagingIndexProxy* index) override;
95 
96  USDIMAGING_API
97  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
98  SdfPath const& cachePath,
99  UsdImagingIndexProxy* index) override;
100 
101  USDIMAGING_API
102  virtual void MarkReprDirty(UsdPrim const& prim,
103  SdfPath const& cachePath,
104  UsdImagingIndexProxy* index) override;
105 
106  USDIMAGING_API
107  virtual void MarkCullStyleDirty(UsdPrim const& prim,
108  SdfPath const& cachePath,
109  UsdImagingIndexProxy* index) override;
110 
111  USDIMAGING_API
112  virtual void MarkRenderTagDirty(UsdPrim const& prim,
113  SdfPath const& cachePath,
114  UsdImagingIndexProxy* index) override;
115 
116  USDIMAGING_API
117  virtual void MarkTransformDirty(UsdPrim const& prim,
118  SdfPath const& cachePath,
119  UsdImagingIndexProxy* index) override;
120 
121  USDIMAGING_API
122  virtual void MarkVisibilityDirty(UsdPrim const& prim,
123  SdfPath const& cachePath,
124  UsdImagingIndexProxy* index) override;
125 
126  USDIMAGING_API
127  virtual void MarkMaterialDirty(UsdPrim const& prim,
128  SdfPath const& cachePath,
129  UsdImagingIndexProxy* index) override;
130 
131  // ---------------------------------------------------------------------- //
133  // ---------------------------------------------------------------------- //
136  USDIMAGING_API
137  virtual VtValue GetPoints(UsdPrim const& prim,
138  UsdTimeCode time) const;
139 
145  USDIMAGING_API
146  static bool GetColor(UsdPrim const& prim,
147  UsdTimeCode time,
148  TfToken *interpolation,
149  VtValue *color,
150  VtIntArray *indices);
151 
157  USDIMAGING_API
158  static bool GetOpacity(UsdPrim const& prim,
159  UsdTimeCode time,
160  TfToken *interpolation,
161  VtValue *opacity,
162  VtIntArray *indices);
163 
164  // Helper function: add a given type of rprim, potentially with instancer
165  // name mangling, and add any bound shader.
166  USDIMAGING_API
167  SdfPath _AddRprim(TfToken const& primType,
168  UsdPrim const& usdPrim,
169  UsdImagingIndexProxy* index,
170  SdfPath const& materialUsdPath,
171  UsdImagingInstancerContext const* instancerContext);
172 
173  // Helper function: map USD path to UsdImaging cache path,
174  // applying any name-encoding required by the instancerContext.
175  USDIMAGING_API
176  static SdfPath _ResolveCachePath(SdfPath const& usdPath,
177  UsdImagingInstancerContext const* instancerContext);
178 
181  USDIMAGING_API
182  GfRange3d GetExtent(UsdPrim const& prim,
183  SdfPath const& cachePath,
184  UsdTimeCode time) const override;
185 
187  USDIMAGING_API
188  bool GetDoubleSided(UsdPrim const& prim,
189  SdfPath const& cachePath,
190  UsdTimeCode time) const override;
191 
192  USDIMAGING_API
193  SdfPath GetMaterialId(UsdPrim const& prim,
194  SdfPath const& cachePath,
195  UsdTimeCode time) const override;
200  USDIMAGING_API
201  VtValue Get(UsdPrim const& prim,
202  SdfPath const& cachePath,
203  TfToken const& key,
204  UsdTimeCode time,
205  VtIntArray *outIndices) const override;
206 
207 protected:
208 
209  USDIMAGING_API
210  virtual void _RemovePrim(SdfPath const& cachePath,
211  UsdImagingIndexProxy* index) override;
212 
213  // Give derived classes an opportunity to block GprimAdapter processing
214  // of certain primvars.
215  USDIMAGING_API
216  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
217 
218  // Utility for derived classes to try to find an inherited primvar.
219  USDIMAGING_API
220  UsdGeomPrimvar _GetInheritedPrimvar(UsdPrim const& prim,
221  TfToken const& primvarName) const;
222 
223 };
224 
225 
226 PXR_NAMESPACE_CLOSE_SCOPE
227 
228 #endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
USDIMAGING_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=nullptr) const override
Thread Safe.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
Delegate support for UsdGeomGrims.
Definition: gprimAdapter.h:48
virtual USDIMAGING_API VtValue GetPoints(UsdPrim const &prim, 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:87
USDIMAGING_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=nullptr) const override
Thread Safe.
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:65
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.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:132
static USDIMAGING_API bool GetOpacity(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *opacity, VtIntArray *indices)
Returns opacity, Usd interpolation token, and optionally opacity indices for a given prim...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
USDIMAGING_API VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const override
Gets the value of the parameter named key for the given prim (which has the given cache path) and giv...
static USDIMAGING_API bool GetColor(UsdPrim const &prim, UsdTimeCode time, TfToken *interpolation, VtValue *color, VtIntArray *indices)
Returns color, Usd interpolation token, and optionally color indices for a given prim, taking into account surface shader colors and explicitly authored color on the prim.
Base class for all geometric primitives.
Definition: gprim.h:66
USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads the extent from the given prim.
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:168