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
16#include "pxr/imaging/hd/sceneIndexObserver.h"
17
19
20PXR_NAMESPACE_OPEN_SCOPE
21
25
38 , public std::enable_shared_from_this<
39 UsdSkelImagingDataSourceResolvedPointsBasedPrim>
40{
41public:
43
52 USDSKELIMAGING_API
53 static
54 Handle New(
55 HdSceneIndexBaseRefPtr const &sceneIndex,
56 SdfPath primPath,
57 HdContainerDataSourceHandle primSource);
58
59 USDSKELIMAGING_API
61
62 USDSKELIMAGING_API
64
65 USDSKELIMAGING_API
66 HdDataSourceBaseHandle Get(const TfToken &name) override;
67
69 const SdfPath &GetPrimPath() const { return _primPath; }
70
72 const SdfPath &GetSkeletonPath() const { return _skeletonPath; }
73
76 return _blendShapeTargetPaths;
77 }
78
80 const HdPrimvarsSchema &GetPrimvars() const { return _primvars; }
81
83 const UsdSkelImagingResolvedSkeletonSchema &GetResolvedSkeletonSchema() {
84 return _resolvedSkeletonSchema;
85 }
86
89 USDSKELIMAGING_API
90 HdMatrixDataSourceHandle GetPrimWorldToLocal() const;
91
93 USDSKELIMAGING_API
94 std::shared_ptr<UsdSkelImagingBlendShapeData> GetBlendShapeData();
95
97 USDSKELIMAGING_API
98 std::shared_ptr<UsdSkelImagingJointInfluencesData> GetJointInfluencesData();
99
101 const TfToken &GetSkinningMethod() const {
102 return _skinningMethod;
103 }
104
107 bool HasExtComputations() const {
108 return
109 // Points are only posed if we bind a Skeleton prim (and the
110 // UsdSkelImagingSkeletonResolvingSceneIndex has populated the
111 // resolved skeleton schema).
112 _resolvedSkeletonSchema &&
113 // Do not use ext computation if this prim was the Skeleton itself.
114 // For the Skeleton prim itself, the
115 // UsdSkelImagingSkeletonResolvingSceneIndex has populated the
116 // points primvar already (with the points for the mesh guide)
117 // and changed the prim type to mesh.
118 _primPath != _skeletonPath &&
119 // We only skin prims if they are under a SkelRoot.
120 //
121 // Note that when we bake the points of a skinned prim, we also
122 // change the SkelRoot to a different prim type (such as Scope
123 // or Xform) so that the baked points are not skinned again.
124 _hasSkelRoot;
125 }
126
135 USDSKELIMAGING_API
136 static const HdDataSourceLocatorSet &
138
147 USDSKELIMAGING_API
149 const TfToken &dirtiedPrimType,
150 const HdDataSourceLocatorSet &dirtyLocators,
152
153private:
154 USDSKELIMAGING_API
156 HdSceneIndexBaseRefPtr const &sceneIndex,
157 SdfPath primPath,
158 HdContainerDataSourceHandle primSource,
159 bool hasSkelRoot,
160 VtArray<SdfPath> blendShapeTargetPaths,
161 SdfPath skelPath,
162 HdContainerDataSourceHandle skeletonPrimSource,
163 UsdSkelImagingResolvedSkeletonSchema resolvedSkeletonSchema);
164
165 bool
166 _ProcessDirtyLocators(
167 const HdDataSourceLocatorSet &dirtyLocators,
168 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
169 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
170
171 bool
172 _ProcessDirtySkeletonLocators(
173 const HdDataSourceLocatorSet &dirtyLocators,
174 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
175 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
176
177 bool
178 _ProcessDirtySkelBlendShapeLocators(
179 const HdDataSourceLocatorSet &dirtyLocators,
180 HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
181 HdDataSourceLocatorSet * dirtyLocatorsForComputation);
182
183 // Input scene.
184 HdSceneIndexBaseRefPtr const _sceneIndex;
185 // Path of prim in the input scene.
186 const SdfPath _primPath;
187 // Data source for _primPath from input scene _sceneIndex.
188 HdContainerDataSourceHandle const _primSource;
189 const bool _hasSkelRoot;
190 // From prim at _primPath in input scene _sceneIndex.
191 HdPrimvarsSchema const _primvars;
192 const TfToken _skinningMethod;
193 VtArray<SdfPath> _blendShapeTargetPaths;
194 const SdfPath _skeletonPath;
195 HdContainerDataSourceHandle const _skeletonPrimSource;
196 const UsdSkelImagingResolvedSkeletonSchema _resolvedSkeletonSchema;
197
198 class _BlendShapeDataCache
199 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingBlendShapeData>
200 {
201 public:
202 _BlendShapeDataCache(
203 HdSceneIndexBaseRefPtr const &sceneIndex,
204 const SdfPath &primPath);
205 protected:
206 Handle _Compute() override;
207 private:
208 HdSceneIndexBaseRefPtr const _sceneIndex;
209 const SdfPath _primPath;
210 };
211 _BlendShapeDataCache _blendShapeDataCache;
212
213 class _JointInfluencesDataCache
214 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingJointInfluencesData>
215 {
216 public:
217 _JointInfluencesDataCache(
218 HdContainerDataSourceHandle const &primSource,
219 HdContainerDataSourceHandle const &skeletonPrimSource);
220 protected:
221 Handle _Compute() override;
222 private:
223 HdContainerDataSourceHandle const _primSource;
224 HdContainerDataSourceHandle const _skeletonPrimSource;
225 };
226 _JointInfluencesDataCache _jointInfluencesDataCache;
227};
228
229HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedPointsBasedPrim);
230
231PXR_NAMESPACE_CLOSE_SCOPE
232
233#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:48
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 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.
USDSKELIMAGING_API HdMatrixDataSourceHandle GetPrimWorldToLocal() const
Typed sampled data source for the inverse of the xform matrix of the prim in the input scene.
const SdfPath & GetSkeletonPath() const
Path of bound skeleton.
const TfToken & GetSkinningMethod() const
Skinning method computed from corresponding primvar.
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