HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataSourceResolvedPointsBasedPrim.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_POINTS_BASED_PRIM_H
9 #define PXR_USD_IMAGING_USD_SKEL_IMAGING_DATA_SOURCE_RESOLVED_POINTS_BASED_PRIM_H
10 
15 
19 
21 
23 
27 
28 /// \class UsdSkelImagingDataSourceResolvedPointsBasedPrim
29 ///
30 /// A prim data source providing resolved data for a points based prim (mesh,
31 /// basisCurves, points) deformed by a skeleton.
32 /// As a data source, it populates the HdExtComputationPrimvarsSchema for points
33 /// and possibly for normals and removes points and normals from the
34 /// HdPrimvarsSchema.
35 ///
36 /// Used by the UsdSkelImagingPointsResolvingSceneIndex in conjunction with the
37 /// UsdSkelImagingDataSourceResolvedExtComputationPrim.
38 ///
40  : public HdContainerDataSource
41  , public std::enable_shared_from_this<
42  UsdSkelImagingDataSourceResolvedPointsBasedPrim>
43 {
44 public:
46 
47  /// C'tor.
48  ///
49  /// Note that it takes the data source for the prim at primPath in the
50  /// given sceneIndex. This is for performance: the client probably already
51  /// retrieved this data source so we want to avoid looking it up again here.
52  ///
53  /// Returns a nullptr if there the prim in the input scene does not bind a
54  /// skeleton.
56  static
57  Handle New(
58  HdSceneIndexBaseRefPtr const &sceneIndex,
59  SdfPath primPath,
60  HdContainerDataSourceHandle primSource);
61 
64 
66  TfTokenVector GetNames() override;
67 
69  HdDataSourceBaseHandle Get(const TfToken &name) override;
70 
71  /// Path of prim in input scene (and for prim this data source is for).
72  const SdfPath &GetPrimPath() const { return _primPath; }
73 
74  /// Path of bound skeleton.
75  const SdfPath &GetSkeletonPath() const { return _skeletonPath; }
76 
77  /// Paths to BlendShape prims.
79  return _blendShapeTargetPaths;
80  }
81 
82  /// Paths to instancers instancing this prim - not including ones
83  /// outside the skel root.
84  ///
85  /// See UsdSkelImagingDataSourceXformResolver for details.
86  ///
88  return _xformResolver.GetInstancerPaths();
89  }
90 
91  /// Primvars of prim in the input scene.
92  const HdPrimvarsSchema &GetPrimvars() const { return _primvars; }
93 
94  /// Resolved skeleton of prim in the input scene.
96  return _resolvedSkeletonSchema;
97  }
98 
101 
102  /// Only valid if GetSkinningMethod() == UsdSkelTokens->dualQuaternion
105 
106  /// Only valid if GetSkinningMethod() == UsdSkelTokens->dualQuaternion
109 
112 
113  /// Transfrom to go from common space (as defined by
114  /// UsdSkelImagingDataSourceXformResolver) to the local space of this
115  /// prim.
118 
120  HdSampledDataSourceHandle GetPoints();
121 
123  HdDataSourceBaseHandle GetGeomBindTransform();
124 
126  HdDataSourceBaseHandle GetHasConstantInfluences();
127 
129  HdDataSourceBaseHandle GetNumInfluencesPerComponent();
130 
132  HdDataSourceBaseHandle GetInfluences();
133 
135  HdDataSourceBaseHandle GetBlendShapeOffsets();
136 
138  HdDataSourceBaseHandle GetBlendShapeOffsetRanges();
139 
141  HdDataSourceBaseHandle GetNumBlendShapeOffsetRanges();
142 
144  HdSampledDataSourceHandle GetNormals() const;
145 
147  HdSampledDataSourceHandle GetFaceVertexIndices();
148 
150  HdDataSourceBaseHandle GetHasFaceVaryingNormals();
151 
152  /// Blend shape data computed from primvars, skel bindings and skeleton.
154  std::shared_ptr<UsdSkelImagingBlendShapeData> GetBlendShapeData();
155 
156  /// Joint influences data computed from primvars.
158  std::shared_ptr<UsdSkelImagingJointInfluencesData> GetJointInfluencesData();
159 
160  /// Skinning method computed from corresponding primvar.
161  const TfToken &GetSkinningMethod() const {
162  return _skinningMethod;
163  }
164 
165  /// Should the points for this primvar be given by an ext computation
166  /// or from the primvars schema.
167  bool HasExtComputations() const;
168 
169  /// Should the normals for this primvar be given by an ext computation.
170  bool HasNormalsExtComputations() const;
171 
172  /// Data source locators (on this prim) that this prim depends on.
173  ///
174  /// That is, if the input scene sends a dirty entry for this prim path
175  /// with dirty locators intersecting these data source locators, we need
176  /// to call ProcessDirtyLocators.
177  ///
178  /// (Similar to dependendedOnDataSourceLocator in HdDependencySchema).
179  ///
181  static const HdDataSourceLocatorSet &
183 
184  /// Dirty internal structures in response to dirty locators for the
185  /// target (resolved) skeleton prim (dirtiedPrimType = "skeleton"), a
186  /// targeted skelBlendShape prim (dirtiedPrimType = "skelBlendShape") or
187  /// the prim in the input scene itself (any other dirtiedPrimType).
188  /// Fills dirtied prim entries with affected locators for this prim
189  /// or returns true to indicate that we could not dirty this data
190  /// source and need to refetch it.
191  ///
194  const TfToken &dirtiedPrimType,
195  const HdDataSourceLocatorSet &dirtyLocators,
197 
198 private:
201  HdSceneIndexBaseRefPtr const &sceneIndex,
202  SdfPath primPath,
203  HdContainerDataSourceHandle primSource,
204  bool hasSkelRoot,
205  VtArray<SdfPath> blendShapeTargetPaths,
206  SdfPath skelPath,
207  HdContainerDataSourceHandle skeletonPrimSource,
208  UsdSkelImagingResolvedSkeletonSchema resolvedSkeletonSchema);
209 
210  bool
211  _ProcessDirtyLocators(
212  const HdDataSourceLocatorSet &dirtyLocators,
213  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
214  HdDataSourceLocatorSet * dirtyLocatorsForComputation,
215  TfTokenVector * dirtyPrimvars);
216 
217  bool
218  _ProcessDirtySkeletonLocators(
219  const HdDataSourceLocatorSet &dirtyLocators,
220  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
221  HdDataSourceLocatorSet * dirtyLocatorsForComputation,
222  TfTokenVector * dirtyPrimvars);
223 
224  bool
225  _ProcessDirtySkelBlendShapeLocators(
226  const HdDataSourceLocatorSet &dirtyLocators,
227  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
228  HdDataSourceLocatorSet * dirtyLocatorsForComputation,
229  TfTokenVector * dirtyPrimvars);
230 
231  bool
232  _ProcessDirtyInstancerLocators(
233  const HdDataSourceLocatorSet &dirtyLocators,
234  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
235  HdDataSourceLocatorSet * dirtyLocatorsForComputation);
236 
237  // Input scene.
238  HdSceneIndexBaseRefPtr const _sceneIndex;
239  // Path of prim in the input scene.
240  const SdfPath _primPath;
241  // Data source for _primPath from input scene _sceneIndex.
242  HdContainerDataSourceHandle const _primSource;
243  const bool _hasSkelRoot;
244  // From prim at _primPath in input scene _sceneIndex.
245  HdPrimvarsSchema const _primvars;
246  HdMeshSchema const _mesh;
247  const TfToken _skinningMethod;
248  VtArray<SdfPath> _blendShapeTargetPaths;
249  const SdfPath _skeletonPath;
250  HdContainerDataSourceHandle const _skeletonPrimSource;
251  const UsdSkelImagingResolvedSkeletonSchema _resolvedSkeletonSchema;
252 
253  class _BlendShapeDataCache
254  : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingBlendShapeData>
255  {
256  public:
257  _BlendShapeDataCache(
258  HdSceneIndexBaseRefPtr const &sceneIndex,
259  const SdfPath &primPath);
260  protected:
261  Handle _Compute() override;
262  private:
263  HdSceneIndexBaseRefPtr const _sceneIndex;
264  const SdfPath _primPath;
265  };
266  _BlendShapeDataCache _blendShapeDataCache;
267 
268  class _JointInfluencesDataCache
269  : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingJointInfluencesData>
270  {
271  public:
272  _JointInfluencesDataCache(
273  HdContainerDataSourceHandle const &primSource,
274  HdContainerDataSourceHandle const &skeletonPrimSource);
275  protected:
276  Handle _Compute() override;
277  private:
278  HdContainerDataSourceHandle const _primSource;
279  HdContainerDataSourceHandle const _skeletonPrimSource;
280  };
281  _JointInfluencesDataCache _jointInfluencesDataCache;
282 
283  // Serves GetPrimWorldToLocal - taking instancing into account.
285 };
286 
288 
290 
291 #endif
HD_DECLARE_DATASOURCE(UsdSkelImagingDataSourceResolvedPointsBasedPrim)
const VtArray< SdfPath > & GetBlendShapeTargetPaths() const
Paths to BlendShape prims.
USDSKELIMAGING_API TfTokenVector GetNames() override
USDSKELIMAGING_API HdDataSourceBaseHandle GetInfluences()
const HdPrimvarsSchema & GetPrimvars() const
Primvars of prim in the input scene.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
USDSKELIMAGING_API HdVec4fArrayDataSourceHandle GetSkinningDualQuats()
Only valid if GetSkinningMethod() == UsdSkelTokens->dualQuaternion.
HdMatrix4fArrayDataSource::Handle HdMatrix4fArrayDataSourceHandle
USDSKELIMAGING_API HdMatrixDataSourceHandle GetCommonSpaceToPrimLocal() const
USDSKELIMAGING_API HdDataSourceBaseHandle GetHasFaceVaryingNormals()
bool HasNormalsExtComputations() const
Should the normals for this primvar be given by an ext computation.
HdMatrix3fArrayDataSource::Handle HdMatrix3fArrayDataSourceHandle
USDSKELIMAGING_API ~UsdSkelImagingDataSourceResolvedPointsBasedPrim()
const VtArray< SdfPath > & GetInstancerPaths() const
Definition: xformResolver.h:58
USDSKELIMAGING_API HdSampledDataSourceHandle GetPoints()
Definition: token.h:70
USDSKELIMAGING_API HdDataSourceBaseHandle GetNumBlendShapeOffsetRanges()
USDSKELIMAGING_API HdDataSourceBaseHandle GetHasConstantInfluences()
USDSKELIMAGING_API HdFloatArrayDataSourceHandle GetBlendShapeWeights()
USDSKELIMAGING_API bool ProcessDirtyLocators(const TfToken &dirtiedPrimType, const HdDataSourceLocatorSet &dirtyLocators, HdSceneIndexObserver::DirtiedPrimEntries *entries)
static USDSKELIMAGING_API Handle New(HdSceneIndexBaseRefPtr const &sceneIndex, SdfPath primPath, HdContainerDataSourceHandle primSource)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDSKELIMAGING_API HdDataSourceBaseHandle GetBlendShapeOffsets()
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:280
HdMatrixDataSource::Handle HdMatrixDataSourceHandle
HdFloatArrayDataSource::Handle HdFloatArrayDataSourceHandle
USDSKELIMAGING_API HdMatrix4fArrayDataSourceHandle GetSkinningTransforms()
USDSKELIMAGING_API HdDataSourceBaseHandle GetNumInfluencesPerComponent()
const UsdSkelImagingResolvedSkeletonSchema & GetResolvedSkeletonSchema()
Resolved skeleton of prim in the input scene.
static USDSKELIMAGING_API const HdDataSourceLocatorSet & GetDependendendOnDataSourceLocators()
const TfToken & GetSkinningMethod() const
Skinning method computed from corresponding primvar.
#define USDSKELIMAGING_API
Definition: api.h:23
USDSKELIMAGING_API HdSampledDataSourceHandle GetNormals() const
USDSKELIMAGING_API HdDataSourceBaseHandle GetGeomBindTransform()
USDSKELIMAGING_API std::shared_ptr< UsdSkelImagingJointInfluencesData > GetJointInfluencesData()
Joint influences data computed from primvars.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDSKELIMAGING_API HdSampledDataSourceHandle GetFaceVertexIndices()
USDSKELIMAGING_API HdMatrix3fArrayDataSourceHandle GetSkinningScaleTransforms()
Only valid if GetSkinningMethod() == UsdSkelTokens->dualQuaternion.
USDSKELIMAGING_API std::shared_ptr< UsdSkelImagingBlendShapeData > GetBlendShapeData()
Blend shape data computed from primvars, skel bindings and skeleton.
const SdfPath & GetPrimPath() const
Path of prim in input scene (and for prim this data source is for).
const SdfPath & GetSkeletonPath() const
Path of bound skeleton.
HdVec4fArrayDataSource::Handle HdVec4fArrayDataSourceHandle
USDSKELIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
USDSKELIMAGING_API HdDataSourceBaseHandle GetBlendShapeOffsetRanges()
HD_DECLARE_DATASOURCE_HANDLES(UsdSkelImagingDataSourceResolvedPointsBasedPrim)
TF_DECLARE_REF_PTRS(HdSceneIndexBase)
void * Handle
Definition: plugin.h:27