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
17PXR_NAMESPACE_OPEN_SCOPE
18
21
31 , public std::enable_shared_from_this<
32 UsdSkelImagingDataSourceResolvedSkeletonPrim>
33{
34public:
36
37 USDSKELIMAGING_API
39
40 USDSKELIMAGING_API
42
43 USDSKELIMAGING_API
44 HdDataSourceBaseHandle Get(const TfToken &name) override;
45
48 const SdfPath &GetAnimationSource() const {
49 return _animationSource;
50 }
51
53 const UsdSkelImagingAnimationSchema &GetAnimationSchema() const {
54 return _animationSchema;
55 }
56
58 HdMatrixDataSourceHandle GetSkelLocalToWorld() const;
59
61 HdMatrix4fArrayDataSourceHandle GetSkinningTransforms();
62
65 std::shared_ptr<UsdSkelImagingSkelData> GetSkelData() {
66 return _skelDataCache.Get();
67 }
68
71 std::shared_ptr<UsdSkelImagingSkelGuideData> GetSkelGuideData() {
72 return _skelGuideDataCache.Get();
73 }
74
83 static const HdDataSourceLocatorSet &
85
93 USDSKELIMAGING_API
95 const TfToken &dirtiedPrimType,
96 const HdDataSourceLocatorSet &dirtyLocators,
98
99private:
100 USDSKELIMAGING_API
102 HdSceneIndexBaseRefPtr const &sceneIndex,
103 const SdfPath &primPath,
104 HdContainerDataSourceHandle const &primSource);
105
106 bool _ProcessSkeletonDirtyLocators(
107 const HdDataSourceLocatorSet &dirtyLocators,
108 HdDataSourceLocatorSet * newDirtyLocators);
109
110 bool _ProcessSkelAnimationDirtyLocators(
111 const HdDataSourceLocatorSet &dirtyLocators,
112 HdDataSourceLocatorSet * newDirtyLocators);
113
114 // Path to this skeleton prim.
115 const SdfPath _primPath;
116 // Input data source for this skeleton prim.
117 HdContainerDataSourceHandle const _primSource;
118 // Path of skel animation prim.
119 const SdfPath _animationSource;
120 // Animation schema from skel animation prim.
121 const UsdSkelImagingAnimationSchema _animationSchema;
122
123 class _SkelDataCache
124 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelData>
125 {
126 public:
127 _SkelDataCache(HdSceneIndexBaseRefPtr const &sceneIndex,
128 const SdfPath &primPath);
129 protected:
130 Handle _Compute() override;
131 private:
132 HdSceneIndexBaseRefPtr const _sceneIndex;
133 const SdfPath _primPath;
134 };
135 _SkelDataCache _skelDataCache;
136
137 class _SkelGuideDataCache
138 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelGuideData>
139 {
140 public:
141 _SkelGuideDataCache(
143 protected:
144 Handle _Compute() override;
145 private:
146 UsdSkelImagingDataSourceResolvedSkeletonPrim * const _resolvedSkeleton;
147 };
148 _SkelGuideDataCache _skelGuideDataCache;
149
150 // Converts rest transforms to VtArray<GfMatrix4f>.
151 //
152 // Note that rest transforms is only needed if there is no animation or the
153 // animation is not sparse. Thus, this data source lazily reads it from the
154 // skeleton schema.
155 //
156 class _RestTransformsDataSource;
157 std::shared_ptr<_RestTransformsDataSource> const _restTransformsDataSource;
158};
159
160HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedSkeletonPrim);
161
162PXR_NAMESPACE_CLOSE_SCOPE
163
164#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:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A data source providing data for the UsdSkelImagingResolvedSkeletonSchema and for drawing the guide a...
USDSKELIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
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 GetSkelLocalToWorld() const
Inverse transform matrix of this skeleton prim.
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.
std::shared_ptr< UsdSkelImagingSkelData > GetSkelData()
(Non-animated) skel data computed from this skeleton and the parts of skelAnimation relating to the t...
std::shared_ptr< UsdSkelImagingSkelGuideData > GetSkelGuideData()
Some of the (non-animated) data to compute the points and topology for the mesh guide.
A thunk for shared pointers computing the result only once and using atomic operations to store the c...
Some of the data necessary to compute the skinning transforms of a skeleton.
Definition: skelData.h:29
Data to compute the skeleton guide as mesh.
Definition: skelGuideData.h:37
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440