HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataSourceResolvedSkeletonPrim.h
Go to the documentation of this file.
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 
12 
17 
19 
22 
23 /// \class UsdSkelImagingDataSourceResolvedSkeletonPrim
24 ///
25 /// A data source providing data for the UsdSkelImagingResolvedSkeletonSchema
26 /// and for drawing the guide as a mesh.
27 ///
28 /// Used by skeleton resolving scene index.
29 ///
31  : public HdContainerDataSource
32  , public std::enable_shared_from_this<
33  UsdSkelImagingDataSourceResolvedSkeletonPrim>
34 {
35 public:
37 
40 
42  TfTokenVector GetNames() override;
43 
45  HdDataSourceBaseHandle Get(const TfToken &name) override;
46 
47  /// skelAnimation targeted by the skeleton. Used to track dependency
48  /// of this prim on the skelAnimation.
49  /// When skinning is deferred, return the animationSource overrides on the
50  /// instancer instead if it exists.
52 
53  /// Schema(s) from skelAnimation at GetAnimationSource().
55 
56  /// Paths to instancers instancing this prim - not including ones
57  /// outside the skel root.
58  ///
59  /// See UsdSkelImagingDataSourceXformResolver for details.
60  ///
62  return _xformResolver.GetInstancerPaths();
63  }
64 
65  /// Transfrom to go from local space of skeleton prim to common
66  /// space (as defined by UsdSkelImagingDataSourceXformResolver).
68 
69  /// Skinning transforms.
70  /// If UsdImagingIsUsdSkelGLInstancingEnabled() is true, this will
71  /// concatinate all the instanceAnimationSource if there is no bound
72  /// AnimationSource.
74 
75  /// BlendShapes.
76  /// Same logic as skinning transforms
78 
79  /// BlendShape weights.
80  /// Same logic as skinning transforms
82 
83  /// BlendShape ranges.
84  /// If UsdImagingIsUsdSkelGLInstancingEnabled() is true,
85  /// We will concatenate all the blendShapes and blendShapeWeights from
86  /// instance animation sources and they might be of different sizes so we
87  /// need to provide ranges in order to restore them downstream.
89 
90  /// (Non-animated) skel data computed from this skeleton and the parts of
91  /// skelAnimation relating to the topology/remapping.
92  std::shared_ptr<UsdSkelImagingSkelData> GetSkelData() {
93  return _skelDataCache.Get();
94  }
95 
96  /// Some of the (non-animated) data to compute the points and topology
97  /// for the mesh guide.
98  std::shared_ptr<UsdSkelImagingSkelGuideData> GetSkelGuideData() {
99  return _skelGuideDataCache.Get();
100  }
101 
102  /// Data source locators (on this prim) that this prim depends on.
103  ///
104  /// That is, if the input scene sends a dirty entry for this prim path
105  /// with dirty locators intersecting these data source locators, we need
106  /// to call ProcessDirtyLocators.
107  ///
108  /// (Similar to dependendedOnDataSourceLocator in HdDependencySchema).
109  ///
110  static const HdDataSourceLocatorSet &
112 
113  /// Dirty internal structures in response to dirty locators for
114  /// skeleton prim (dirtiedPrimType = "skeleton") or the targeted
115  /// skelAnimaton prim (dirtiedPrimType = "skelAnimation").
116  /// Fills dirtied prim entries with affected locators for this prim
117  /// or returns true to indicate that we could not dirty this data
118  /// source and need to refetch it.
119  ///
122  const TfToken &dirtiedPrimType,
123  const HdDataSourceLocatorSet &dirtyLocators,
125 
126 private:
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 
203 
205 
206 #endif
std::shared_ptr< UsdSkelImagingSkelGuideData > GetSkelGuideData()
std::shared_ptr< UsdSkelImagingSkelData > GetSkelData()
HD_DECLARE_DATASOURCE(UsdSkelImagingDataSourceResolvedSkeletonPrim)
USDSKELIMAGING_API ~UsdSkelImagingDataSourceResolvedSkeletonPrim()
HdFloatArrayDataSourceHandle GetBlendShapeWeights() const
HdVec2iArrayDataSourceHandle GetBlendShapeRanges() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
HdVec2iArrayDataSource::Handle HdVec2iArrayDataSourceHandle
HdMatrix4fArrayDataSource::Handle HdMatrix4fArrayDataSourceHandle
USDSKELIMAGING_API bool ProcessDirtyLocators(const TfToken &dirtiedPrimType, const HdDataSourceLocatorSet &dirtyLocators, HdSceneIndexObserver::DirtiedPrimEntries *entries)
USDSKELIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
const VtArray< SdfPath > & GetInstancerPaths() const
Definition: xformResolver.h:58
HdTokenArrayDataSource::Handle HdTokenArrayDataSourceHandle
USDSKELIMAGING_API TfTokenVector GetNames() override
HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedSkeletonPrim)
Definition: token.h:70
VtArray< UsdSkelImagingAnimationSchema > GetAnimationSchema() const
Schema(s) from skelAnimation at GetAnimationSource().
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
static const HdDataSourceLocatorSet & GetDependendendOnDataSourceLocators()
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:280
HdMatrixDataSource::Handle HdMatrixDataSourceHandle
HdFloatArrayDataSource::Handle HdFloatArrayDataSourceHandle
HdTokenArrayDataSourceHandle GetBlendShapes() const
#define USDSKELIMAGING_API
Definition: api.h:23
VtArray< SdfPath > GetAnimationSource() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdMatrix4fArrayDataSourceHandle GetSkinningTransforms()
HdMatrixDataSourceHandle GetSkelLocalToCommonSpace() const
void * Handle
Definition: plugin.h:27