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 
16 
18 
21 
22 /// \class UsdSkelImagingDataSourceResolvedSkeletonPrim
23 ///
24 /// A data source providing data for the UsdSkelImagingResolvedSkeletonSchema
25 /// and for drawing the guide as a mesh.
26 ///
27 /// Used by skeleton resolving scene index.
28 ///
30  : public HdContainerDataSource
31  , public std::enable_shared_from_this<
32  UsdSkelImagingDataSourceResolvedSkeletonPrim>
33 {
34 public:
36 
39 
41  TfTokenVector GetNames() override;
42 
44  HdDataSourceBaseHandle Get(const TfToken &name) override;
45 
46  /// skelAnimation targeted by the skeleton. Used to track dependency
47  /// of this prim on the skelAnimation.
48  const SdfPath &GetAnimationSource() const {
49  return _animationSource;
50  }
51 
52  /// Schema from skelAnimation at GetAnimationSource().
54  return _animationSchema;
55  }
56 
57  /// Inverse transform matrix of this skeleton prim.
59 
60  /// Skinning transforms.
62 
63  /// (Non-animated) skel data computed from this skeleton and the parts of
64  /// skelAnimation relating to the topology/remapping.
65  std::shared_ptr<UsdSkelImagingSkelData> GetSkelData() {
66  return _skelDataCache.Get();
67  }
68 
69  /// Some of the (non-animated) data to compute the points and topology
70  /// for the mesh guide.
71  std::shared_ptr<UsdSkelImagingSkelGuideData> GetSkelGuideData() {
72  return _skelGuideDataCache.Get();
73  }
74 
75  /// Data source locators (on this prim) that this prim depends on.
76  ///
77  /// That is, if the input scene sends a dirty entry for this prim path
78  /// with dirty locators intersecting these data source locators, we need
79  /// to call ProcessDirtyLocators.
80  ///
81  /// (Similar to dependendedOnDataSourceLocator in HdDependencySchema).
82  ///
83  static const HdDataSourceLocatorSet &
85 
86  /// Dirty internal structures in response to dirty locators for
87  /// skeleton prim (dirtiedPrimType = "skeleton") or the targeted
88  /// skelAnimaton prim (dirtiedPrimType = "skelAnimation").
89  /// Fills dirtied prim entries with affected locators for this prim
90  /// or returns true to indicate that we could not dirty this data
91  /// source and need to refetch it.
92  ///
95  const TfToken &dirtiedPrimType,
96  const HdDataSourceLocatorSet &dirtyLocators,
98 
99 private:
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 
161 
163 
164 #endif
std::shared_ptr< UsdSkelImagingSkelGuideData > GetSkelGuideData()
std::shared_ptr< UsdSkelImagingSkelData > GetSkelData()
HD_DECLARE_DATASOURCE(UsdSkelImagingDataSourceResolvedSkeletonPrim)
USDSKELIMAGING_API ~UsdSkelImagingDataSourceResolvedSkeletonPrim()
HdMatrix4fArrayDataSource::Handle HdMatrix4fArrayDataSourceHandle
USDSKELIMAGING_API bool ProcessDirtyLocators(const TfToken &dirtiedPrimType, const HdDataSourceLocatorSet &dirtyLocators, HdSceneIndexObserver::DirtiedPrimEntries *entries)
const UsdSkelImagingAnimationSchema & GetAnimationSchema() const
Schema from skelAnimation at GetAnimationSource().
USDSKELIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
USDSKELIMAGING_API TfTokenVector GetNames() override
HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedSkeletonPrim)
Definition: token.h:70
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:273
HdMatrixDataSource::Handle HdMatrixDataSourceHandle
#define USDSKELIMAGING_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdMatrix4fArrayDataSourceHandle GetSkinningTransforms()
Skinning transforms.
HdMatrixDataSourceHandle GetSkelLocalToWorld() const
Inverse transform matrix of this skeleton prim.
void * Handle
Definition: plugin.h:27