Loading...
Searching...
No Matches
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"
31#include "pxr/usdImaging/usdImaging/instanceablePrimAdapter.h"
32
33#include "pxr/usd/usdGeom/xformCache.h"
34
35PXR_NAMESPACE_OPEN_SCOPE
36
37
38class UsdGeomGprim;
39
49{
50public:
52
53 // ---------------------------------------------------------------------- //
55 // ---------------------------------------------------------------------- //
56
57 USDIMAGING_API
58 HdDataSourceLocatorSet InvalidateImagingSubprim(
59 UsdPrim const& prim,
60 TfToken const& subprim,
61 TfTokenVector const& properties,
62 UsdImagingPropertyInvalidationType invalidationType) override;
63 // ---------------------------------------------------------------------- //
65 // ---------------------------------------------------------------------- //
66
68 USDIMAGING_API
69 void TrackVariability(UsdPrim const& prim,
70 SdfPath const& cachePath,
71 HdDirtyBits* timeVaryingBits,
73 instancerContext = nullptr) const override;
74
76 USDIMAGING_API
77 void UpdateForTime(UsdPrim const& prim,
78 SdfPath const& cachePath,
79 UsdTimeCode time,
80 HdDirtyBits requestedBits,
82 instancerContext = nullptr) const override;
83
84 // ---------------------------------------------------------------------- //
86 // ---------------------------------------------------------------------- //
87
88 USDIMAGING_API
89 HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
90 SdfPath const& cachePath,
91 TfToken const& property) override;
92
93 USDIMAGING_API
94 void MarkDirty(UsdPrim const& prim,
95 SdfPath const& cachePath,
96 HdDirtyBits dirty,
97 UsdImagingIndexProxy* index) override;
98
99 USDIMAGING_API
100 void MarkRefineLevelDirty(UsdPrim const& prim,
101 SdfPath const& cachePath,
102 UsdImagingIndexProxy* index) override;
103
104 USDIMAGING_API
105 void MarkReprDirty(UsdPrim const& prim,
106 SdfPath const& cachePath,
107 UsdImagingIndexProxy* index) override;
108
109 USDIMAGING_API
110 void MarkCullStyleDirty(UsdPrim const& prim,
111 SdfPath const& cachePath,
112 UsdImagingIndexProxy* index) override;
113
114 USDIMAGING_API
115 void MarkRenderTagDirty(UsdPrim const& prim,
116 SdfPath const& cachePath,
117 UsdImagingIndexProxy* index) override;
118
119 USDIMAGING_API
120 void MarkTransformDirty(UsdPrim const& prim,
121 SdfPath const& cachePath,
122 UsdImagingIndexProxy* index) override;
123
124 USDIMAGING_API
125 void MarkVisibilityDirty(UsdPrim const& prim,
126 SdfPath const& cachePath,
127 UsdImagingIndexProxy* index) override;
128
129 USDIMAGING_API
130 void MarkMaterialDirty(UsdPrim const& prim,
131 SdfPath const& cachePath,
132 UsdImagingIndexProxy* index) override;
133
134 USDIMAGING_API
135 void MarkCollectionsDirty(UsdPrim const& prim,
136 SdfPath const& cachePath,
137 UsdImagingIndexProxy* index) override;
138
139 // ---------------------------------------------------------------------- //
141 // ---------------------------------------------------------------------- //
144 USDIMAGING_API
145 virtual VtValue GetPoints(UsdPrim const& prim,
146 UsdTimeCode time) const;
147
153 USDIMAGING_API
154 static bool GetColor(UsdPrim const& prim,
155 UsdTimeCode time,
156 TfToken *interpolation,
157 VtValue *color,
158 VtIntArray *indices);
159
165 USDIMAGING_API
166 static bool GetOpacity(UsdPrim const& prim,
167 UsdTimeCode time,
168 TfToken *interpolation,
169 VtValue *opacity,
170 VtIntArray *indices);
171
172 // Helper function: add a given type of rprim, potentially with instancer
173 // name mangling, and add any bound shader.
174 USDIMAGING_API
175 SdfPath _AddRprim(TfToken const& primType,
176 UsdPrim const& usdPrim,
178 SdfPath const& materialUsdPath,
179 UsdImagingInstancerContext const* instancerContext);
180
183 USDIMAGING_API
185 SdfPath const& cachePath,
186 UsdTimeCode time) const override;
187
189 USDIMAGING_API
190 bool GetDoubleSided(UsdPrim const& prim,
191 SdfPath const& cachePath,
192 UsdTimeCode time) const override;
193
194 USDIMAGING_API
195 SdfPath GetMaterialId(UsdPrim const& prim,
196 SdfPath const& cachePath,
197 UsdTimeCode time) const override;
202 USDIMAGING_API
203 VtValue Get(UsdPrim const& prim,
204 SdfPath const& cachePath,
205 TfToken const& key,
206 UsdTimeCode time,
207 VtIntArray *outIndices) const override;
208
209 // For implicit prims such as capsules, cones, cylinders and planes, the
210 // "spine" axis along or about which the surface is aligned may be
211 // specified. This utility method returns a basis matrix that transforms
212 // points generated using "Z" as the spine axis to the desired axis.
213 USDIMAGING_API
214 static GfMatrix4d GetImplicitBasis(TfToken const &spineAxis);
215
216protected:
217
218 USDIMAGING_API
219 void _RemovePrim(SdfPath const& cachePath,
220 UsdImagingIndexProxy* index) override;
221
222 // Give derived classes an opportunity to block GprimAdapter processing
223 // of certain primvars.
224 USDIMAGING_API
225 virtual bool _IsBuiltinPrimvar(TfToken const& primvarName) const;
226
227 // Utility for gathering the names of primvars used by the gprim's
228 // materials, used in primvar filtering.
229 USDIMAGING_API
230 virtual TfTokenVector _CollectMaterialPrimvars(
231 SdfPathVector const& materialUsdPaths,
232 UsdTimeCode time) const;
233
237 USDIMAGING_API
238 virtual TfTokenVector const& _GetRprimPrimvarNames() const;
239};
240
241PXR_NAMESPACE_CLOSE_SCOPE
242
243#endif //PXR_USD_IMAGING_USD_IMAGING_GPRIM_ADAPTER_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
Represents a set of data source locators closed under descendancy.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Base class for all geometric primitives.
Definition: gprim.h:67
Delegate support for UsdGeomGrims.
Definition: gprimAdapter.h:49
USDIMAGING_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=nullptr) const override
Thread Safe.
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,...
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 GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads the extent from the given prim.
USDIMAGING_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=nullptr) const override
Thread Safe.
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 ...
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.
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.
virtual USDIMAGING_API TfTokenVector const & _GetRprimPrimvarNames() const
Returns the primvar names known to be supported for the rprims this adapter produces.
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...
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
An abstract adapter class for prims that are instanceable.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:84
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457