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
59 return _xformResolver.GetInstancerPaths();
60 }
61
64 return _animationSchema;
65 }
66
69 HdMatrixDataSourceHandle GetSkelLocalToCommonSpace() const;
70
72 HdMatrix4fArrayDataSourceHandle GetSkinningTransforms();
73
76 std::shared_ptr<UsdSkelImagingSkelData> GetSkelData() {
77 return _skelDataCache.Get();
78 }
79
82 std::shared_ptr<UsdSkelImagingSkelGuideData> GetSkelGuideData() {
83 return _skelGuideDataCache.Get();
84 }
85
94 static const HdDataSourceLocatorSet &
96
104 USDSKELIMAGING_API
106 const TfToken &dirtiedPrimType,
107 const HdDataSourceLocatorSet &dirtyLocators,
109
110private:
111 USDSKELIMAGING_API
113 HdSceneIndexBaseRefPtr const &sceneIndex,
114 const SdfPath &primPath,
115 HdContainerDataSourceHandle const &primSource);
116
117 bool _ProcessSkeletonDirtyLocators(
118 const HdDataSourceLocatorSet &dirtyLocators,
119 HdDataSourceLocatorSet * newDirtyLocators);
120
121 bool _ProcessSkelAnimationDirtyLocators(
122 const HdDataSourceLocatorSet &dirtyLocators,
123 HdDataSourceLocatorSet * newDirtyLocators);
124
125 bool _ProcessInstancerDirtyLocators(
126 const HdDataSourceLocatorSet &dirtyLocators,
127 HdDataSourceLocatorSet * newDirtyLocators);
128
129 // Path to this skeleton prim.
130 const SdfPath _primPath;
131 // Input data source for this skeleton prim.
132 HdContainerDataSourceHandle const _primSource;
133 // Path of skel animation prim.
134 const SdfPath _animationSource;
135 // Animation schema from skel animation prim.
136 const UsdSkelImagingAnimationSchema _animationSchema;
137
138 class _SkelDataCache
139 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelData>
140 {
141 public:
142 _SkelDataCache(HdSceneIndexBaseRefPtr const &sceneIndex,
143 const SdfPath &primPath);
144 protected:
145 Handle _Compute() override;
146 private:
147 HdSceneIndexBaseRefPtr const _sceneIndex;
148 const SdfPath _primPath;
149 };
150 _SkelDataCache _skelDataCache;
151
152 class _SkelGuideDataCache
153 : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingSkelGuideData>
154 {
155 public:
156 _SkelGuideDataCache(
158 protected:
159 Handle _Compute() override;
160 private:
161 UsdSkelImagingDataSourceResolvedSkeletonPrim * const _resolvedSkeleton;
162 };
163 _SkelGuideDataCache _skelGuideDataCache;
164
165 // Converts rest transforms to VtArray<GfMatrix4f>.
166 //
167 // Note that rest transforms is only needed if there is no animation or the
168 // animation is not sparse. Thus, this data source lazily reads it from the
169 // skeleton schema.
170 //
171 class _RestTransformsDataSource;
172 std::shared_ptr<_RestTransformsDataSource> const _restTransformsDataSource;
173
174 // Serves GetSkelLocalToWorld - taking instancing into account.
176};
177
178HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedSkeletonPrim);
179
180PXR_NAMESPACE_CLOSE_SCOPE
181
182#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
Corresponds to UsdSkelAnimation.
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 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.
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.
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:43
const VtArray< SdfPath > & GetInstancerPaths() const
Paths of instancer contributing to the transform.
Definition: xformResolver.h:55
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:29
Data to compute the skeleton guide as mesh.
Definition: skelGuideData.h:37
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440