gprimAdapter.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
8 #define PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
9 
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usdImaging/usdImaging/api.h"
14 #include "pxr/usdImaging/usdImaging/instanceablePrimAdapter.h"
15 
16 #include "pxr/usd/usdGeom/xformCache.h"
17 
18 PXR_NAMESPACE_OPEN_SCOPE
19 
20 
21 class UsdGeomGprim;
22 
32 {
33 public:
35 
36  // ---------------------------------------------------------------------- //
38  // ---------------------------------------------------------------------- //
39 
40  USDIMAGING_API
41  HdDataSourceLocatorSet InvalidateImagingSubprim(
42  UsdPrim const& prim,
43  TfToken const& subprim,
44  TfTokenVector const& properties,
45  UsdImagingPropertyInvalidationType invalidationType) override;
46  // ---------------------------------------------------------------------- //
48  // ---------------------------------------------------------------------- //
49 
51  USDIMAGING_API
52  void TrackVariability(UsdPrim const& prim,
53  SdfPath const& cachePath,
54  HdDirtyBits* timeVaryingBits,
56  instancerContext = nullptr) const override;
57 
59  USDIMAGING_API
60  void UpdateForTime(UsdPrim const& prim,
61  SdfPath const& cachePath,
62  UsdTimeCode time,
63  HdDirtyBits requestedBits,
65  instancerContext = nullptr) const override;
66 
67  // ---------------------------------------------------------------------- //
69  // ---------------------------------------------------------------------- //
70 
71  USDIMAGING_API
72  HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
73  SdfPath const& cachePath,
74  TfToken const& property) override;
75 
76  USDIMAGING_API
77  void MarkDirty(UsdPrim const& prim,
78  SdfPath const& cachePath,
79  HdDirtyBits dirty,
80  UsdImagingIndexProxy* index) override;
81 
82  USDIMAGING_API
83  void MarkRefineLevelDirty(UsdPrim const& prim,
84  SdfPath const& cachePath,
85  UsdImagingIndexProxy* index) override;
86 
87  USDIMAGING_API
88  void MarkReprDirty(UsdPrim const& prim,
89  SdfPath const& cachePath,
90  UsdImagingIndexProxy* index) override;
91 
92  USDIMAGING_API
93  void MarkCullStyleDirty(UsdPrim const& prim,
94  SdfPath const& cachePath,
95  UsdImagingIndexProxy* index) override;
96 
97  USDIMAGING_API
98  void MarkRenderTagDirty(UsdPrim const& prim,
99  SdfPath const& cachePath,
100  UsdImagingIndexProxy* index) override;
101 
102  USDIMAGING_API
103  void MarkTransformDirty(UsdPrim const& prim,
104  SdfPath const& cachePath,
105  UsdImagingIndexProxy* index) override;
106 
107  USDIMAGING_API
108  void MarkVisibilityDirty(UsdPrim const& prim,
109  SdfPath const& cachePath,
110  UsdImagingIndexProxy* index) override;
111 
112  USDIMAGING_API
113  void MarkMaterialDirty(UsdPrim const& prim,
114  SdfPath const& cachePath,
115  UsdImagingIndexProxy* index) override;
116 
117  USDIMAGING_API
118  void MarkCollectionsDirty(UsdPrim const& prim,
119  SdfPath const& cachePath,
120  UsdImagingIndexProxy* index) override;
121 
122  // ---------------------------------------------------------------------- //
124  // ---------------------------------------------------------------------- //
127  USDIMAGING_API
128  virtual VtValue GetPoints(UsdPrim const& prim,
129  UsdTimeCode time) const;
130 
136  USDIMAGING_API
137  static bool GetColor(UsdPrim const& prim,
138  UsdTimeCode time,
139  TfToken *interpolation,
140  VtValue *color,
141  VtIntArray *indices);
142 
148  USDIMAGING_API
149  static bool GetOpacity(UsdPrim const& prim,
150  UsdTimeCode time,
151  TfToken *interpolation,
152  VtValue *opacity,
153  VtIntArray *indices);
154 
155  // Helper function: add a given type of rprim, potentially with instancer
156  // name mangling, and add any bound shader.
157  USDIMAGING_API
158  SdfPath _AddRprim(TfToken const& primType,
159  UsdPrim const& usdPrim,
160  UsdImagingIndexProxy* index,
161  SdfPath const& materialUsdPath,
162  UsdImagingInstancerContext const* instancerContext);
163 
166  USDIMAGING_API
167  GfRange3d GetExtent(UsdPrim const& prim,
168  SdfPath const& cachePath,
169  UsdTimeCode time) const override;
170 
172  USDIMAGING_API
173  bool GetDoubleSided(UsdPrim const& prim,
174  SdfPath const& cachePath,
175  UsdTimeCode time) const override;
176 
177  USDIMAGING_API
178  SdfPath GetMaterialId(UsdPrim const& prim,
179  SdfPath const& cachePath,
180  UsdTimeCode time) const override;
185  USDIMAGING_API
186  VtValue Get(UsdPrim const& prim,
187  SdfPath const& cachePath,
188  TfToken const& key,
189  UsdTimeCode time,
190  VtIntArray *outIndices) const override;
191 
192  // For implicit prims such as capsules, cones, cylinders and planes, the
193  // "spine" axis along or about which the surface is aligned may be
194  // specified. This utility method returns a basis matrix that transforms
195  // points generated using "Z" as the spine axis to the desired axis.
196  USDIMAGING_API
197  static GfMatrix4d GetImplicitBasis(TfToken const &spineAxis);
198 
199 protected:
200 
201  USDIMAGING_API
202  void _RemovePrim(SdfPath const& cachePath,
203  UsdImagingIndexProxy* index) override;
204 
205  // Give derived classes an opportunity to block GprimAdapter processing
206  // of certain primvars.
207  USDIMAGING_API
208  virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
209 
210  // Utility for gathering the names of primvars used by the gprim's
211  // materials, used in primvar filtering.
212  USDIMAGING_API
213  virtual TfTokenVector _CollectMaterialPrimvars(
214  SdfPathVector const& materialUsdPaths,
215  UsdTimeCode time) const;
216 
220  USDIMAGING_API
221  virtual TfTokenVector const& _GetRprimPrimvarNames() const;
222 };
223 
224 PXR_NAMESPACE_CLOSE_SCOPE
225 
226 #endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
An abstract adapter class for prims that are instanceable.
Basic type: 3-dimensional floating point range.
Definition: range3d.h:46
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:30
Delegate support for UsdGeomGrims.
Definition: gprimAdapter.h:31
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
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:70
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:73
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:116
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:489
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
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,...
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 ...
Base class for all geometric primitives.
Definition: gprim.h:49
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.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:89