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 _ComputeHasNormalsExtComputations() const;
211 
212  bool
213  _ProcessDirtyLocators(
214  const HdDataSourceLocatorSet &dirtyLocators,
215  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
216  HdDataSourceLocatorSet * dirtyLocatorsForComputation,
217  TfTokenVector * dirtyPrimvars);
218 
219  bool
220  _ProcessDirtySkeletonLocators(
221  const HdDataSourceLocatorSet &dirtyLocators,
222  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
223  HdDataSourceLocatorSet * dirtyLocatorsForComputation,
224  TfTokenVector * dirtyPrimvars);
225 
226  bool
227  _ProcessDirtySkelBlendShapeLocators(
228  const HdDataSourceLocatorSet &dirtyLocators,
229  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
230  HdDataSourceLocatorSet * dirtyLocatorsForComputation,
231  TfTokenVector * dirtyPrimvars);
232 
233  bool
234  _ProcessDirtyInstancerLocators(
235  const HdDataSourceLocatorSet &dirtyLocators,
236  HdDataSourceLocatorSet * dirtyLocatorsForAggregatorComputation,
237  HdDataSourceLocatorSet * dirtyLocatorsForComputation);
238 
239  // Input scene.
240  HdSceneIndexBaseRefPtr const _sceneIndex;
241  // Path of prim in the input scene.
242  const SdfPath _primPath;
243  // Data source for _primPath from input scene _sceneIndex.
244  HdContainerDataSourceHandle const _primSource;
245  const bool _hasSkelRoot;
246  // From prim at _primPath in input scene _sceneIndex.
247  HdPrimvarsSchema const _primvars;
248  HdMeshSchema const _mesh;
249  const TfToken _skinningMethod;
250  VtArray<SdfPath> _blendShapeTargetPaths;
251  const SdfPath _skeletonPath;
252  HdContainerDataSourceHandle const _skeletonPrimSource;
253  const UsdSkelImagingResolvedSkeletonSchema _resolvedSkeletonSchema;
254  bool _hasNormalsExtComputations = false;
255 
256  class _BlendShapeDataCache
257  : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingBlendShapeData>
258  {
259  public:
260  _BlendShapeDataCache(
261  HdSceneIndexBaseRefPtr const &sceneIndex,
262  const SdfPath &primPath);
263  protected:
264  Handle _Compute() override;
265  private:
266  HdSceneIndexBaseRefPtr const _sceneIndex;
267  const SdfPath _primPath;
268  };
269  _BlendShapeDataCache _blendShapeDataCache;
270 
271  class _JointInfluencesDataCache
272  : public UsdSkelImagingSharedPtrThunk<UsdSkelImagingJointInfluencesData>
273  {
274  public:
275  _JointInfluencesDataCache(
276  HdContainerDataSourceHandle const &primSource,
277  HdContainerDataSourceHandle const &skeletonPrimSource);
278  protected:
279  Handle _Compute() override;
280  private:
281  HdContainerDataSourceHandle const _primSource;
282  HdContainerDataSourceHandle const _skeletonPrimSource;
283  };
284  _JointInfluencesDataCache _jointInfluencesDataCache;
285 
286  // Serves GetPrimWorldToLocal - taking instancing into account.
288 };
289 
291 
293 
294 #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