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
52
55
62 return _xformResolver.GetInstancerPaths();
63 }
64
67 HdMatrixDataSourceHandle GetSkelLocalToCommonSpace() const;
68
73 HdMatrix4fArrayDataSourceHandle GetSkinningTransforms();
74
77 HdTokenArrayDataSourceHandle GetBlendShapes() const;
78
81 HdFloatArrayDataSourceHandle GetBlendShapeWeights() const;
82
88 HdVec2iArrayDataSourceHandle GetBlendShapeRanges() const;
89
92 std::shared_ptr<UsdSkelImagingSkelData> GetSkelData() {
93 return _skelDataCache.Get();
94 }
95
98 std::shared_ptr<UsdSkelImagingSkelGuideData> GetSkelGuideData() {
99 return _skelGuideDataCache.Get();
100 }
101
110 static const HdDataSourceLocatorSet &
112
120 USDSKELIMAGING_API
122 const TfToken &dirtiedPrimType,
123 const HdDataSourceLocatorSet &dirtyLocators,
125
126private:
127 USDSKELIMAGING_API
129 HdSceneIndexBaseRefPtr const &sceneIndex,
130 const SdfPath &primPath,
131 HdContainerDataSourceHandle const &primSource);
132
133 bool _ShouldResolveInstanceAnimation() const;
134
135 bool _ProcessSkeletonDirtyLocators(
136 const HdDataSourceLocatorSet &dirtyLocators,
137 HdDataSourceLocatorSet * newDirtyLocators);
138
139 bool _ProcessSkelAnimationDirtyLocators(
140 const HdDataSourceLocatorSet &dirtyLocators,
141 HdDataSourceLocatorSet * newDirtyLocators);
142
143 bool _ProcessInstancerDirtyLocators(
144 const HdDataSourceLocatorSet &dirtyLocators,
145 HdDataSourceLocatorSet * newDirtyLocators);
146
147 // Path to this skeleton prim.
148 const SdfPath _primPath;
149 // Input data source for this skeleton prim.
150 HdContainerDataSourceHandle const _primSource;
151 // Path of skel animation prim.
152 const SdfPath _animationSource;
153 // Animation schema from the above skel animation prim.
154 const UsdSkelImagingAnimationSchema _animationSchema;
155
156 class _SkelDataCache
157 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelData>
158 {
159 public:
160 _SkelDataCache(HdSceneIndexBaseRefPtr const &sceneIndex,
161 const SdfPath &primPath);
162 protected:
163 Handle _Compute() override;
164 private:
165 HdSceneIndexBaseRefPtr const _sceneIndex;
166 const SdfPath _primPath;
167 };
168 _SkelDataCache _skelDataCache;
169
170 class _SkelGuideDataCache
171 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelGuideData>
172 {
173 public:
174 _SkelGuideDataCache(
176 protected:
177 Handle _Compute() override;
178 private:
179 UsdSkelImagingDataSourceResolvedSkeletonPrim * const _resolvedSkeleton;
180 };
181 _SkelGuideDataCache _skelGuideDataCache;
182
183 // Converts rest transforms to VtArray<GfMatrix4f>.
184 //
185 // Note that rest transforms is only needed if there is no animation or the
186 // animation is not sparse. Thus, this data source lazily reads it from the
187 // skeleton schema.
188 //
189 class _RestTransformsDataSource;
190 std::shared_ptr<_RestTransformsDataSource> const _restTransformsDataSource;
191
192 // Serves GetSkelLocalToWorld - taking instancing into account.
194
195 // Paths of skel animation prims bound to the instancer.
196 // They came in as skel:animationSource primvar on the instancer.
197 const VtArray<SdfPath> _instanceAnimationSources;
198 // Animation schema from the above skel animation prims.
199 const VtArray<UsdSkelImagingAnimationSchema> _instanceAnimationSchemas;
200};
201
202HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedSkeletonPrim);
203
204PXR_NAMESPACE_CLOSE_SCOPE
205
206#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:281
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.
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...
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.
VtArray< UsdSkelImagingAnimationSchema > GetAnimationSchema() const
Schema(s) from skelAnimation at GetAnimationSource().
VtArray< SdfPath > GetAnimationSource() const
skelAnimation targeted by the skeleton.
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