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 
61  // ---------------------------------------------------------------------- //
63  // ---------------------------------------------------------------------- //
64 
65  USDIMAGING_API
66  HdDataSourceLocatorSet InvalidateImagingSubprim(
67  UsdPrim const& prim,
68  TfToken const& subprim,
69  TfTokenVector const& properties) override;
70 
71  // ---------------------------------------------------------------------- //
73  // ---------------------------------------------------------------------- //
74 
76  USDIMAGING_API
77  void TrackVariability(UsdPrim const& prim,
78  SdfPath const& cachePath,
79  HdDirtyBits* timeVaryingBits,
81  instancerContext = nullptr) const override;
82 
84  USDIMAGING_API
85  void UpdateForTime(UsdPrim const& prim,
86  SdfPath const& cachePath,
87  UsdTimeCode time,
88  HdDirtyBits requestedBits,
90  instancerContext = nullptr) const override;
91 
92  // ---------------------------------------------------------------------- //
94  // ---------------------------------------------------------------------- //
95 
96  USDIMAGING_API
97  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
98  SdfPath const& cachePath,
99  TfToken const& property) override;
100 
101  USDIMAGING_API
102  virtual void MarkDirty(UsdPrim const& prim,
103  SdfPath const& cachePath,
104  HdDirtyBits dirty,
105  UsdImagingIndexProxy* index) override;
106 
107  USDIMAGING_API
108  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
109  SdfPath const& cachePath,
110  UsdImagingIndexProxy* index) override;
111 
112  USDIMAGING_API
113  virtual void MarkReprDirty(UsdPrim const& prim,
114  SdfPath const& cachePath,
115  UsdImagingIndexProxy* index) override;
116 
117  USDIMAGING_API
118  virtual void MarkCullStyleDirty(UsdPrim const& prim,
119  SdfPath const& cachePath,
120  UsdImagingIndexProxy* index) override;
121 
122  USDIMAGING_API
123  virtual void MarkRenderTagDirty(UsdPrim const& prim,
124  SdfPath const& cachePath,
125  UsdImagingIndexProxy* index) override;
126 
127  USDIMAGING_API
128  virtual void MarkTransformDirty(UsdPrim const& prim,
129  SdfPath const& cachePath,
130  UsdImagingIndexProxy* index) override;
131 
132  USDIMAGING_API
133  virtual void MarkVisibilityDirty(UsdPrim const& prim,
134  SdfPath const& cachePath,
135  UsdImagingIndexProxy* index) override;
136 
137  USDIMAGING_API
138  virtual void MarkMaterialDirty(UsdPrim const& prim,
139  SdfPath const& cachePath,
140  UsdImagingIndexProxy* index) override;
141 
142  USDIMAGING_API
143  virtual void MarkCollectionsDirty(UsdPrim const& prim,
144  SdfPath const& cachePath,
145  UsdImagingIndexProxy* index) override;
146 
147  // ---------------------------------------------------------------------- //
149  // ---------------------------------------------------------------------- //
152  USDIMAGING_API
153  virtual VtValue GetPoints(UsdPrim const& prim,
154  UsdTimeCode time) const;
155 
161  USDIMAGING_API
162  static bool GetColor(UsdPrim const& prim,
163  UsdTimeCode time,
164  TfToken *interpolation,
165  VtValue *color,
166  VtIntArray *indices);
167 
173  USDIMAGING_API
174  static bool GetOpacity(UsdPrim const& prim,
175  UsdTimeCode time,
176  TfToken *interpolation,
177  VtValue *opacity,
178  VtIntArray *indices);
179 
180  // Helper function: add a given type of rprim, potentially with instancer
181  // name mangling, and add any bound shader.
182  USDIMAGING_API
183  SdfPath _AddRprim(TfToken const& primType,
184  UsdPrim const& usdPrim,
185  UsdImagingIndexProxy* index,
186  SdfPath const& materialUsdPath,
187  UsdImagingInstancerContext const* instancerContext);
188 
189  // Helper function: map USD path to UsdImaging cache path,
190  // applying any name-encoding required by the instancerContext.
191  USDIMAGING_API
192  static SdfPath _ResolveCachePath(SdfPath const& usdPath,
193  UsdImagingInstancerContext const* instancerContext);
194 
197  USDIMAGING_API
198  GfRange3d GetExtent(UsdPrim const& prim,
199  SdfPath const& cachePath,
200  UsdTimeCode time) const override;
201 
203  USDIMAGING_API
204  bool GetDoubleSided(UsdPrim const& prim,
205  SdfPath const& cachePath,
206  UsdTimeCode time) const override;
207 
208  USDIMAGING_API
209  SdfPath GetMaterialId(UsdPrim const& prim,
210  SdfPath const& cachePath,
211  UsdTimeCode time) const override;
216  USDIMAGING_API
217  VtValue Get(UsdPrim const& prim,
218  SdfPath const& cachePath,
219  TfToken const& key,
220  UsdTimeCode time,
221  VtIntArray *outIndices) const override;
222 
223  // For implicit prims such as capsules, cones, cylinders and planes, the
224  // "spine" axis along or about which the surface is aligned may be
225  // specified. This utility method returns a basis matrix that transforms
226  // points generated using "Z" as the spine axis to the desired axis.
227  USDIMAGING_API
228  static GfMatrix4d GetImplicitBasis(TfToken const &spineAxis);
229 
230 protected:
231 
232  USDIMAGING_API
233  virtual void _RemovePrim(SdfPath const& cachePath,
234  UsdImagingIndexProxy* index) override;
235 
236  // Give derived classes an opportunity to block GprimAdapter processing
237  // of certain primvars.
238  USDIMAGING_API
239  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
240 
241  // Utility for gathering the names of primvars used by the gprim's
242  // materials, used in primvar filtering.
243  USDIMAGING_API
244  virtual TfTokenVector _CollectMaterialPrimvars(
245  SdfPathVector const& materialUsdPaths,
246  UsdTimeCode time) const;
247 
251  USDIMAGING_API
252  virtual TfTokenVector const& _GetRprimPrimvarNames() const;
253 };
254 
255 
256 PXR_NAMESPACE_CLOSE_SCOPE
257 
258 #endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
Basic type: 3-dimensional floating point range.
Definition: range3d.h:63
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
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.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:87
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
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.
Represents a set of data source locators closed under descendancy.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:135
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,...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
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,...
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.
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.
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
virtual USDIMAGING_API TfTokenVector const & _GetRprimPrimvarNames() const
Returns the primvar names known to be supported for the rprims this adapter produces.
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:166