Loading...
Searching...
No Matches
dataSourceResolvedPointsBasedPrim.h
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_IMAGING_USD_SKEL_IMAGING_DATA_SOURCE_RESOLVED_POINTS_BASED_PRIM_H
9#define PXR_USD_IMAGING_USD_SKEL_IMAGING_DATA_SOURCE_RESOLVED_POINTS_BASED_PRIM_H
10
11#include "pxr/usdImaging/usdSkelImaging/api.h"
12#include "pxr/usdImaging/usdSkelImaging/dataSourceUtils.h"
14#include "pxr/usdImaging/usdSkelImaging/xformResolver.h"
15
17#include "pxr/imaging/hd/sceneIndexObserver.h"
18
20
21PXR_NAMESPACE_OPEN_SCOPE
22
26
39 , public std::enable_shared_from_this<
40 UsdSkelImagingDataSourceResolvedPointsBasedPrim>
41{
42public:
44
53 USDSKELIMAGING_API
54 static
55 Handle New(
56 HdSceneIndexBaseRefPtr const &sceneIndex,
57 SdfPath primPath,
58 HdContainerDataSourceHandle primSource);
59
60 USDSKELIMAGING_API
62
63 USDSKELIMAGING_API
65
66 USDSKELIMAGING_API
67 HdDataSourceBaseHandle Get(const TfToken &name) override;
68
70 const SdfPath &GetPrimPath() const { return _primPath; }
71
73 const SdfPath &GetSkeletonPath() const { return _skeletonPath; }
74
77 return _blendShapeTargetPaths;
78 }
79
86 return _xformResolver.GetInstancerPaths();
87 }
88
90 const HdPrimvarsSchema &GetPrimvars() const { return _primvars; }
91
94 return _resolvedSkeletonSchema;
95 }
96
100 USDSKELIMAGING_API
101 HdMatrixDataSourceHandle GetCommonSpaceToPrimLocal() const;
102
104 USDSKELIMAGING_API
105 std::shared_ptr<UsdSkelImagingBlendShapeData> GetBlendShapeData();
106
108 USDSKELIMAGING_API
109 std::shared_ptr<UsdSkelImagingJointInfluencesData> GetJointInfluencesData();
110
112 const TfToken &GetSkinningMethod() const {
113 return _skinningMethod;
114 }
115
118 bool HasExtComputations() const {
119 return
120 // Points are only posed if we bind a Skeleton prim (and the
121 // UsdSkelImagingSkeletonResolvingSceneIndex has populated the
122 // resolved skeleton schema).
123 _resolvedSkeletonSchema &&
124 // Do not use ext computation if this prim was the Skeleton itself.
125 // For the Skeleton prim itself, the
126 // UsdSkelImagingSkeletonResolvingSceneIndex has populated the
127 // points primvar already (with the points for the mesh guide)
128 // and changed the prim type to mesh.
129 _primPath != _skeletonPath &&
130 // We only skin prims if they are under a SkelRoot.
131 //
132 // Note that when we bake the points of a skinned prim, we also
133 // change the SkelRoot to a different prim type (such as Scope
134 // or Xform) so that the baked points are not skinned again.
135 _hasSkelRoot;
136 }
137
146 USDSKELIMAGING_API
147 static const HdDataSourceLocatorSet &
149
158 USDSKELIMAGING_API
160 const TfToken &dirtiedPrimType,
161 const HdDataSourceLocatorSet &dirtyLocators,
163
164private:
165 USDSKELIMAGING_API
167 HdSceneIndexBaseRefPtr const &sceneIndex,
168 SdfPath primPath,
169 HdContainerDataSourceHandle primSource,
170 bool hasSkelRoot,
171 VtArray<SdfPath> blendShapeTargetPaths,
172 SdfPath skelPath,
173 HdContainerDataSourceHandle skeletonPrimSource,
174 UsdSkelImagingResolvedSkeletonSchema resolvedSkeletonSchema);
175
176 bool
177 _ProcessDirtyLocators(
178 const HdDataSourceLocatorSet &dirtyLocators,
179 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
180 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
181
182 bool
183 _ProcessDirtySkeletonLocators(
184 const HdDataSourceLocatorSet &dirtyLocators,
185 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
186 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
187
188 bool
189 _ProcessDirtySkelBlendShapeLocators(
190 const HdDataSourceLocatorSet &dirtyLocators,
191 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
192 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
193
194 bool
195 _ProcessDirtyInstancerLocators(
196 const HdDataSourceLocatorSet &dirtyLocators,
197 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
198 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
199
200 // Input scene.
201 HdSceneIndexBaseRefPtr const _sceneIndex;
202 // Path of prim in the input scene.
203 const SdfPath _primPath;
204 // Data source for _primPath from input scene _sceneIndex.
205 HdContainerDataSourceHandle const _primSource;
206 const bool _hasSkelRoot;
207 // From prim at _primPath in input scene _sceneIndex.
208 HdPrimvarsSchema const _primvars;
209 const TfToken _skinningMethod;
210 VtArray<SdfPath> _blendShapeTargetPaths;
211 const SdfPath _skeletonPath;
212 HdContainerDataSourceHandle const _skeletonPrimSource;
213 const UsdSkelImagingResolvedSkeletonSchema _resolvedSkeletonSchema;
214
215 class _BlendShapeDataCache
216 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingBlendShapeData>
217 {
218 public:
219 _BlendShapeDataCache(
220 HdSceneIndexBaseRefPtr const &sceneIndex,
221 const SdfPath &primPath);
222 protected:
223 Handle _Compute() override;
224 private:
225 HdSceneIndexBaseRefPtr const _sceneIndex;
226 const SdfPath _primPath;
227 };
228 _BlendShapeDataCache _blendShapeDataCache;
229
230 class _JointInfluencesDataCache
231 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingJointInfluencesData>
232 {
233 public:
234 _JointInfluencesDataCache(
235 HdContainerDataSourceHandle const &primSource,
236 HdContainerDataSourceHandle const &skeletonPrimSource);
237 protected:
238 Handle _Compute() override;
239 private:
240 HdContainerDataSourceHandle const _primSource;
241 HdContainerDataSourceHandle const _skeletonPrimSource;
242 };
243 _JointInfluencesDataCache _jointInfluencesDataCache;
244
245 // Serves GetPrimWorldToLocal - taking instancing into account.
247};
248
249HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedPointsBasedPrim);
250
251PXR_NAMESPACE_CLOSE_SCOPE
252
253#endif
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
Definition: dataSource.h:99
Represents a set of data source locators closed under descendancy.
Abstract interface to scene data.
Definition: sceneIndex.h:54
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A prim data source providing resolved data for a points based prim (mesh, basisCurves,...
USDSKELIMAGING_API std::shared_ptr< UsdSkelImagingBlendShapeData > GetBlendShapeData()
Blend shape data computed from primvars, skel bindings and skeleton.
bool HasExtComputations() const
Should the points for this primvar be given by an ext computation or from the primvars schema.
USDSKELIMAGING_API std::shared_ptr< UsdSkelImagingJointInfluencesData > GetJointInfluencesData()
Joint influences data computed from primvars.
const UsdSkelImagingResolvedSkeletonSchema & GetResolvedSkeletonSchema()
Resolved skeleton of prim in the input scene.
static USDSKELIMAGING_API Handle New(HdSceneIndexBaseRefPtr const &sceneIndex, SdfPath primPath, HdContainerDataSourceHandle primSource)
C'tor.
USDSKELIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
const HdPrimvarsSchema & GetPrimvars() const
Primvars of prim in the input scene.
static USDSKELIMAGING_API const HdDataSourceLocatorSet & GetDependendendOnDataSourceLocators()
Data source locators (on this prim) that this prim depends on.
USDSKELIMAGING_API HdMatrixDataSourceHandle GetCommonSpaceToPrimLocal() const
Transfrom to go from common space (as defined by UsdSkelImagingDataSourceXformResolver) to the local ...
USDSKELIMAGING_API bool ProcessDirtyLocators(const TfToken &dirtiedPrimType, const HdDataSourceLocatorSet &dirtyLocators, HdSceneIndexObserver::DirtiedPrimEntries *entries)
Dirty internal structures in response to dirty locators for the target (resolved) skeleton prim (dirt...
const VtArray< SdfPath > & GetBlendShapeTargetPaths() const
Paths to BlendShape prims.
const SdfPath & GetPrimPath() const
Path of prim in input scene (and for prim this data source is for).
USDSKELIMAGING_API TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
const SdfPath & GetSkeletonPath() const
Path of bound skeleton.
const VtArray< SdfPath > & GetInstancerPaths() const
Paths to instancers instancing this prim - not including ones outside the skel root.
const TfToken & GetSkinningMethod() const
Skinning method computed from corresponding primvar.
Given a prim, computes transform from prim local space to a space common to all descendants of a skel...
Definition: xformResolver.h:43
const VtArray< SdfPath > & GetInstancerPaths() const
Paths of instancer contributing to the transform.
Definition: xformResolver.h:55
Resolved data for a skeleton and the targeted skelAnim.
A thunk for shared pointers computing the result only once and using atomic operations to store the c...
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:213
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
Data for skinned prim to compute the skel ext computation inputs related to blend shapes.
Some of the data feeding into the ext computations to skin a prim.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440