Loading...
Searching...
No Matches
dataSourceResolvedSkeletonPrim.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_SKELETON_PRIM_H
9#define PXR_USD_IMAGING_USD_SKEL_IMAGING_DATA_SOURCE_RESOLVED_SKELETON_PRIM_H
10
11#include "pxr/imaging/hd/sceneIndex.h"
12
14#include "pxr/usdImaging/usdSkelImaging/dataSourceUtils.h"
16#include "pxr/usdImaging/usdSkelImaging/xformResolver.h"
17
18PXR_NAMESPACE_OPEN_SCOPE
19
22
32 , public std::enable_shared_from_this<
33 UsdSkelImagingDataSourceResolvedSkeletonPrim>
34{
35public:
37
38 USDSKELIMAGING_API
40
41 USDSKELIMAGING_API
43
44 USDSKELIMAGING_API
45 HdDataSourceBaseHandle Get(const TfToken &name) override;
46
49 const SdfPath &GetAnimationSource() const {
50 return _animationSource;
51 }
52
53 const VtArray<SdfPath> &GetInstanceAnimationSources() const {
54 return _instanceAnimationSources;
55 }
56
63 return _xformResolver.GetInstancerPaths();
64 }
65
68 return _animationSchema;
69 }
70
72 &GetInstanceAnimationSchemas() const {
73 return _instanceAnimationSchemas;
74 }
75
81 // TODO:
82 // Maybe consider removing or making the direct access APIs (
83 // GetAnimationXXX()/GetInstanceAnimationXXX()) private?
86 GetResolvedAnimationSchemas() const;
87
90 HdMatrixDataSourceHandle GetSkelLocalToCommonSpace() const;
91
96 HdMatrix4fArrayDataSourceHandle GetSkinningTransforms();
97
100 HdTokenArrayDataSourceHandle GetBlendShapes() const;
101
104 HdFloatArrayDataSourceHandle GetBlendShapeWeights() const;
105
111 HdVec2iArrayDataSourceHandle GetBlendShapeRanges() const;
112
115 std::shared_ptr<UsdSkelImagingSkelData> GetSkelData() {
116 return _skelDataCache.Get();
117 }
118
121 std::shared_ptr<UsdSkelImagingSkelGuideData> GetSkelGuideData() {
122 return _skelGuideDataCache.Get();
123 }
124
133 static const HdDataSourceLocatorSet &
135
143 USDSKELIMAGING_API
145 const TfToken &dirtiedPrimType,
146 const HdDataSourceLocatorSet &dirtyLocators,
148
149private:
150 USDSKELIMAGING_API
152 HdSceneIndexBaseRefPtr const &sceneIndex,
153 const SdfPath &primPath,
154 HdContainerDataSourceHandle const &primSource);
155
156 bool _ShouldResolveInstanceAnimation() const;
157
158 bool _ProcessSkeletonDirtyLocators(
159 const HdDataSourceLocatorSet &dirtyLocators,
160 HdDataSourceLocatorSet * newDirtyLocators);
161
162 bool _ProcessSkelAnimationDirtyLocators(
163 const HdDataSourceLocatorSet &dirtyLocators,
164 HdDataSourceLocatorSet * newDirtyLocators);
165
166 bool _ProcessInstancerDirtyLocators(
167 const HdDataSourceLocatorSet &dirtyLocators,
168 HdDataSourceLocatorSet * newDirtyLocators);
169
170 // Path to this skeleton prim.
171 const SdfPath _primPath;
172 // Input data source for this skeleton prim.
173 HdContainerDataSourceHandle const _primSource;
174 // Path of skel animation prim.
175 const SdfPath _animationSource;
176 // Animation schema from the above skel animation prim.
177 const UsdSkelImagingAnimationSchema _animationSchema;
178
179 class _SkelDataCache
180 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelData>
181 {
182 public:
183 _SkelDataCache(HdSceneIndexBaseRefPtr const &sceneIndex,
184 const SdfPath &primPath);
185 protected:
186 Handle _Compute() override;
187 private:
188 HdSceneIndexBaseRefPtr const _sceneIndex;
189 const SdfPath _primPath;
190 };
191 _SkelDataCache _skelDataCache;
192
193 class _SkelGuideDataCache
194 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelGuideData>
195 {
196 public:
197 _SkelGuideDataCache(
199 protected:
200 Handle _Compute() override;
201 private:
202 UsdSkelImagingDataSourceResolvedSkeletonPrim * const _resolvedSkeleton;
203 };
204 _SkelGuideDataCache _skelGuideDataCache;
205
206 // Converts rest transforms to VtArray<GfMatrix4f>.
207 //
208 // Note that rest transforms is only needed if there is no animation or the
209 // animation is not sparse. Thus, this data source lazily reads it from the
210 // skeleton schema.
211 //
212 class _RestTransformsDataSource;
213 std::shared_ptr<_RestTransformsDataSource> const _restTransformsDataSource;
214
215 // Serves GetSkelLocalToWorld - taking instancing into account.
217
218 // Paths of skel animation prims bound to the instancer.
219 // They came in as skel:animationSource primvar on the instancer.
220 const VtArray<SdfPath> _instanceAnimationSources;
221 // Animation schema from the above skel animation prims.
222 const VtArray<UsdSkelImagingAnimationSchema> _instanceAnimationSchemas;
223};
224
225HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedSkeletonPrim);
226
227PXR_NAMESPACE_CLOSE_SCOPE
228
229#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.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Corresponds to UsdSkelAnimation.
A data source providing data for the UsdSkelImagingResolvedSkeletonSchema and for drawing the guide a...
HdTokenArrayDataSourceHandle GetBlendShapes() const
BlendShapes.
USDSKELIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
const VtArray< SdfPath > GetResolvedAnimationSources() const
Get the resolved animationSchema(s)/animationSource(s) bound to this skeleton.
const SdfPath & GetAnimationSource() const
skelAnimation targeted by the skeleton.
USDSKELIMAGING_API bool ProcessDirtyLocators(const TfToken &dirtiedPrimType, const HdDataSourceLocatorSet &dirtyLocators, HdSceneIndexObserver::DirtiedPrimEntries *entries)
Dirty internal structures in response to dirty locators for skeleton prim (dirtiedPrimType = "skeleto...
HdMatrix4fArrayDataSourceHandle GetSkinningTransforms()
Skinning transforms.
static const HdDataSourceLocatorSet & GetDependendendOnDataSourceLocators()
Data source locators (on this prim) that this prim depends on.
HdMatrixDataSourceHandle GetSkelLocalToCommonSpace() const
Transfrom to go from local space of skeleton prim to common space (as defined by UsdSkelImagingDataSo...
const UsdSkelImagingAnimationSchema & GetAnimationSchema() const
Schema from skelAnimation at GetAnimationSource().
USDSKELIMAGING_API TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
HdFloatArrayDataSourceHandle GetBlendShapeWeights() const
BlendShape weights.
std::shared_ptr< UsdSkelImagingSkelData > GetSkelData()
(Non-animated) skel data computed from this skeleton and the parts of skelAnimation relating to the t...
const VtArray< SdfPath > & GetInstancerPaths() const
Paths to instancers instancing this prim - not including ones outside the skel root.
HdVec2iArrayDataSourceHandle GetBlendShapeRanges() const
BlendShape ranges.
std::shared_ptr< UsdSkelImagingSkelGuideData > GetSkelGuideData()
Some of the (non-animated) data to compute the points and topology for the mesh guide.
Given a prim, computes transform from prim local space to a space common to all descendants of a skel...
Definition: xformResolver.h:42
const VtArray< SdfPath > & GetInstancerPaths() const
Paths of instancer contributing to the transform.
Definition: xformResolver.h:58
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
Some of the data necessary to compute the skinning transforms of a skeleton.
Definition: skelData.h:33
Data to compute the skeleton guide as mesh.
Definition: skelGuideData.h:37
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440