HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_SKEL_UTILS_H
8 #define PXR_USD_USD_SKEL_UTILS_H
9 
10 /// \file usdSkel/utils.h
11 ///
12 /// Collection of utility methods.
13 ///
14 
15 #include "pxr/pxr.h"
16 #include "pxr/usd/usdSkel/api.h"
17 
18 #include "pxr/base/gf/quatf.h"
19 #include "pxr/base/gf/matrix3d.h"
20 #include "pxr/base/gf/matrix3f.h"
21 #include "pxr/base/gf/matrix4d.h"
22 #include "pxr/base/gf/matrix4f.h"
23 #include "pxr/base/gf/vec3h.h"
24 #include "pxr/base/gf/vec3h.h"
25 #include "pxr/base/tf/span.h"
26 #include "pxr/base/vt/array.h"
27 #include "pxr/base/vt/types.h"
28 
29 #include "pxr/usd/sdf/path.h"
30 
31 #include <cstddef>
32 
33 // XXX: Included for backwards compatibility.
35 
36 
38 
39 
40 class GfMatrix3f;
41 class GfRange3f;
42 class GfRotation;
43 class UsdPrim;
44 class UsdPrimRange;
45 class UsdRelationship;
46 class UsdSkelRoot;
47 class UsdSkelTopology;
48 
49 
50 /// \defgroup UsdSkel_Utils UsdSkel Utilities
51 /// @{
52 
53 
54 /// Returns true if \p prim is a valid skel animation source.
56 bool
58 
59 
60 /// Returns true if \p prim is considered to be a skinnable primitive.
61 /// Whether or not the prim is actually skinned additionally depends on whether
62 /// or not the prim has a bound skeleton, and prop joint influences.
64 bool
65 UsdSkelIsSkinnablePrim(const UsdPrim& prim);
66 
67 
68 /// \defgroup UsdSkel_JointTransformUtils Joint Transform Utilities
69 /// Utilities for working with vectorized joint transforms.
70 /// @{
71 
72 
73 /// Compute joint transforms in joint-local space.
74 /// Transforms are computed from \p xforms, holding concatenated
75 /// joint transforms, and \p inverseXforms, providing the inverse
76 /// of each of those transforms. The resulting local space transforms
77 /// are written to \p jointLocalXforms, which must be the same size
78 /// as \p topology.
79 /// If the root joints include an additional, external transformation
80 /// -- eg., such as the skel local-to-world transformation -- then the
81 /// inverse of that transform should be passed as \p rootInverseXform.
82 /// If no \p rootInverseXform is provided, then \p xform and \p inverseXforms
83 /// should be based on joint transforms computed in skeleton space.
84 /// Each transform array must be sized to the number of joints from \p topology.
86 bool
89  TfSpan<const GfMatrix4d> inverseXforms,
90  TfSpan<GfMatrix4d> jointLocalXforms,
91  const GfMatrix4d* rootInverseXform=nullptr);
92 
93 /// \overload
95 bool
98  TfSpan<const GfMatrix4f> inverseXforms,
99  TfSpan<GfMatrix4f> jointLocalXforms,
100  const GfMatrix4f* rootInverseXform=nullptr);
101 
102 /// Compute joint transforms in joint-local space.
103 /// This is a convenience overload, which computes the required inverse
104 /// transforms internally.
106 bool
109  TfSpan<GfMatrix4d> jointLocalXforms,
110  const GfMatrix4d* rootInverseXform=nullptr);
111 
113 bool
116  TfSpan<GfMatrix4f> jointLocalXforms,
117  const GfMatrix4f* rootInverseXform=nullptr);
118 
119 
120 /// \overload
121 /// \deprecated Use form that takes TfSpan arguments.
123 bool
125  const VtMatrix4dArray& xforms,
126  const VtMatrix4dArray& inverseXforms,
127  VtMatrix4dArray* jointLocalXforms,
128  const GfMatrix4d* rootInverseXform=nullptr);
129 
130 
131 
132 
133 /// \overload
134 /// \deprecated Use form that takes TfSpan arguments.
136 bool
138  const VtMatrix4dArray& xforms,
139  VtMatrix4dArray* jointLocalXforms,
140  const GfMatrix4d* rootInverseXform=nullptr);
141 
142 
143 /// \overload
144 /// \deprecated Use form that takes TfSpan arguments.
146 bool
148  const GfMatrix4d* xforms,
149  const GfMatrix4d* inverseXforms,
150  GfMatrix4d* jointLocalXforms,
151  const GfMatrix4d* rootInverseXform=nullptr);
152 
153 
154 
155 /// Compute concatenated joint transforms.
156 /// This concatenates transforms from \p jointLocalXforms, providing joint
157 /// transforms in joint-local space. The resulting transforms are written to
158 /// \p jointLocalXforms, which must be the same size as \p topology.
159 /// If \p rootXform is not provided, or is the identity, the resulting joint
160 /// transforms will be given in skeleton space. Any additional transformations
161 /// may be provided on \p rootXform if an additional level of transformation
162 /// -- such as the skel local to world transform -- are desired.
163 /// Each transform array must be sized to the number of joints from \p topology.
165 bool
167  TfSpan<const GfMatrix4d> jointLocalXforms,
168  TfSpan<GfMatrix4d> xforms,
169  const GfMatrix4d* rootXform=nullptr);
170 
171 
172 /// \overload
174 bool
176  TfSpan<const GfMatrix4f> jointLocalXforms,
177  TfSpan<GfMatrix4f> xforms,
178  const GfMatrix4f* rootXform=nullptr);
179 
180 
181 
182 /// \overload
183 /// \deprecated Use the function form that takes TfSpan arguments.
185 bool
187  const VtMatrix4dArray& jointLocalXforms,
188  VtMatrix4dArray* xforms,
189  const GfMatrix4d* rootXform=nullptr);
190 
191 
192 /// \overload
193 /// \deprecated Use the form that takes a TfSpan argument.
195 bool
197  const GfMatrix4d* jointLocalXforms,
198  GfMatrix4d* xforms,
199  const GfMatrix4d* rootXform=nullptr);
200 
201 
202 /// Compute an extent from a set of skel-space joint transform.
203 /// The \p rootXform may also be set to provide an additional root
204 /// transformation on top of all joints, which is useful for computing
205 /// extent relative to a different space.
206 template <typename Matrix4>
208 bool
210  GfRange3f* extent,
211  float pad=0.0f,
212  const Matrix4* rootXform=nullptr);
213 
214 
215 
216 /// \overload
217 /// \deprecated Use form that takes a TfSpan.
219 bool
220 UsdSkelComputeJointsExtent(const VtMatrix4dArray& joints,
221  VtVec3fArray* extent,
222  float pad=0.0f,
223  const GfMatrix4d* rootXform=nullptr);
224 
225 
226 /// \overload
227 /// \deprecated Use form that takes a TfSpan.
229 bool
231  size_t numXforms,
232  VtVec3fArray* extent,
233  float pad=0.0f,
234  const GfMatrix4d* rootXform=nullptr);
235 
236 
237 /// @}
238 
239 
240 /// \defgroup UsdSkel_TransformCompositionUtils Transform Composition Utils
241 /// Utiltiies for converting transforms to and from component (translate,
242 /// rotate, scale) form.
243 /// @{
244 
245 
246 /// Decompose a transform into translate/rotate/scale components.
247 /// The transform order for decomposition is scale, rotate, translate.
248 template <typename Matrix4>
250 bool
252  GfVec3f* translate,
254  GfVec3h* scale);
255 
256 /// \overload
257 template <typename Matrix4>
259 bool
261  GfVec3f* translate,
262  GfQuatf* rotate,
263  GfVec3h* scale);
264 
265 
266 /// Decompose an array of transforms into translate/rotate/scale components.
267 /// All spans must be the same size.
269 bool
271  TfSpan<GfVec3f> translations,
272  TfSpan<GfQuatf> rotations,
273  TfSpan<GfVec3h> scales);
274 
275 /// \overload
277 bool
279  TfSpan<GfVec3f> translations,
280  TfSpan<GfQuatf> rotations,
281  TfSpan<GfVec3h> scales);
282 
283 
284 /// \overload
285 /// \deprecated Use form that takes TfSpan arguments.
287 bool
288 UsdSkelDecomposeTransforms(const VtMatrix4dArray& xforms,
289  VtVec3fArray* translations,
290  VtQuatfArray* rotations,
291  VtVec3hArray* scales);
292 
293 
294 /// \overload
295 /// \deprecated Use form that takes TfSpan arguments.
297 bool
299  GfVec3f* translations,
300  GfQuatf* rotations,
301  GfVec3h* scales,
302  size_t count);
303 
304 
305 /// Create a transform from translate/rotate/scale components.
306 /// This performs the inverse of UsdSkelDecomposeTransform.
307 template <typename Matrix4>
309 void
311  const GfMatrix3f& rotate,
312  const GfVec3h& scale,
313  Matrix4* xform);
314 
315 /// \overload
316 template <typename Matrix4>
318 void
320  const GfQuatf& rotate,
321  const GfVec3h& scale,
322  Matrix4* xform);
323 
324 /// Create transforms from arrays of components.
325 /// All spans must be the same size.
327 bool
329  TfSpan<const GfQuatf> rotations,
330  TfSpan<const GfVec3h> scales,
331  TfSpan<GfMatrix4d> xforms);
332 
333 
334 /// \overload
336 bool
338  TfSpan<const GfQuatf> rotations,
339  TfSpan<const GfVec3h> scales,
340  TfSpan<GfMatrix4f> xforms);
341 
342 
343 /// \overload
344 /// \deprecated Use form that takes TfSpan arguments.
346 bool
347 UsdSkelMakeTransforms(const VtVec3fArray& translations,
348  const VtQuatfArray& rotations,
349  const VtVec3hArray& scales,
350  VtMatrix4dArray* xforms);
351 
352 /// \overload
353 /// \deprecated Use form that takes TfSpan arguments.
355 bool
356 UsdSkelMakeTransforms(const GfVec3f* translations,
357  const GfQuatf* rotations,
358  const GfVec3h* scales,
359  GfMatrix4d* xforms,
360  size_t count);
361 
362 
363 /// @}
364 
365 
366 /// \defgroup UsdSkel_JointInfluenceUtils Joint Influence Utils
367 /// Collection of methods for working \ref UsdSkel_Terminology_JointInfluences
368 /// "joint influences", as stored through UsdSkelBindingAPI.`
369 /// @{
370 
371 
372 /// Helper method to normalize weight values across each consecutive run of
373 /// \p numInfluencesPerComponent elements.
374 /// If the total weight for a run of elements is smaller than \p eps, the
375 /// elements' weights are set to zero.
377 bool
378 UsdSkelNormalizeWeights(TfSpan<float> weights, int numInfluencesPerComponent,
379  float eps = std::numeric_limits<float>::epsilon());
380 
381 
382 /// \overload
383 /// \deprecated Use form that takes a TfSpan.
385 bool
386 UsdSkelNormalizeWeights(VtFloatArray* weights, int numInfluencesPerComponent);
387 
388 
389 /// Sort joint influences such that highest weight values come first.
391 bool
393  int numInfluencesPerComponent);
394 
395 /// \overload
396 /// \deprecated Use form that takes TfSpan arguments.
398 bool
399 UsdSkelSortInfluences(VtIntArray* indices, VtFloatArray* weights,
400  int numInfluencesPerComponent);
401 
402 
403 /// Convert an array of constant influences (joint weights or indices)
404 /// to an array of varying influences.
405 /// The \p size should match the size of required for 'vertex' interpolation
406 /// on the type geometry primitive. Typically, this is the number of points.
407 /// This is a convenience function for clients that don't understand
408 /// constant (rigid) weighting.
410 bool
412 
413 /// \overload
415 bool
416 UsdSkelExpandConstantInfluencesToVarying(VtFloatArray* weights, size_t size);
417 
418 /// Resize the number of influences per component in a weight or indices array,
419 /// which initially has \p srcNumInfluencesPerComponent influences to have
420 /// no more than \p newNumInfluencesPerComponent influences per component.
421 /// If the size decreases, influences are additionally re-normalized.
422 /// This is a convenience method for clients that require a fixed number of
423 /// of influences.
425 bool
426 UsdSkelResizeInfluences(VtIntArray* indices,
427  int srcNumInfluencesPerComponent,
428  int newNumInfluencesPerComponent);
429 
430 /// \overload
432 bool
433 UsdSkelResizeInfluences(VtFloatArray* weights,
434  int srcNumInfluencesPerComponent,
435  int newNumInfluencesPerComponent);
436 
437 /// Combine arrays of joint indices and weights into interleaved
438 /// (index,weight) vectors.
440 bool
442  const TfSpan<const float>& weights,
443  TfSpan<GfVec2f> interleavedInfluences);
444 
445 
446 /// @}
447 
448 
449 /// \defgroup UsdSkel_SkinningUtils Skinning Implementations
450 /// Reference skinning implementations for skinning points and transforms.
451 /// @{
452 
453 
454 /// Skin points using linear blend skinning (LBS) or dual quaternion skinning (DQS).
455 /// The \p jointXforms are \ref UsdSkel_Term_SkinningTransforms
456 /// "skinning transforms", given in _skeleton space_, while the
457 /// \p geomBindTransform provides the transform that transforms the initial
458 /// \p points into the same _skeleton space_ that the skinning transforms
459 /// were computed in.
461 bool
462 UsdSkelSkinPoints(const TfToken& skinningMethod,
463  const GfMatrix4d& geomBindTransform,
464  TfSpan<const GfMatrix4d> jointXforms,
465  TfSpan<const int> jointIndices,
466  TfSpan<const float> jointWeights,
467  int numInfluencesPerPoint,
469  bool inSerial=false);
470 
471 
472 /// \overload
474 bool
475 UsdSkelSkinPoints(const TfToken& skinningMethod,
476  const GfMatrix4f& geomBindTransform,
477  TfSpan<const GfMatrix4f> jointXforms,
478  TfSpan<const int> jointIndices,
479  TfSpan<const float> jointWeights,
480  int numInfluencesPerPoint,
482  bool inSerial=false);
483 
484 
485 /// Skin points using linear blend skinning, with interleaved influences.
487 bool
488 UsdSkelSkinPoints(const TfToken& skinningMethod,
489  const GfMatrix4d& geomBindTransform,
490  TfSpan<const GfMatrix4d> jointXforms,
491  TfSpan<const GfVec2f> influences,
492  int numInfluencesPerPoint,
494  bool inSerial=false);
495 
496 
497 /// \overload
499 bool
500 UsdSkelSkinPoints(const TfToken& skinningMethod,
501  const GfMatrix4f& geomBindTransform,
502  TfSpan<const GfMatrix4f> jointXforms,
503  TfSpan<const GfVec2f> influences,
504  int numInfluencesPerPoint,
506  bool inSerial=false);
507 
508 
509 /// \overload
510 /// \deprecated Use form that takes TfSpan arguments.
512 bool
513 UsdSkelSkinPoints(const TfToken& skinningMethod,
514  const GfMatrix4d& geomBindTransform,
515  const VtMatrix4dArray& jointXforms,
516  const VtIntArray& jointIndices,
517  const VtFloatArray& jointWeights,
518  int numInfluencesPerPoint,
519  VtVec3fArray* points);
520 
521 
522 /// \overload
523 /// \deprecated Use form that takes TfSpan arguments.
525 bool
526 UsdSkelSkinPoints(const TfToken& skinningMethod,
527  const GfMatrix4d& geomBindTransform,
528  const GfMatrix4d* jointXforms,
529  size_t numJoints,
530  const int* jointIndices,
531  const float* jointWeights,
532  size_t numInfluences,
533  int numInfluencesPerPoint,
534  GfVec3f* points,
535  size_t numPoints,
536  bool inSerial=false);
537 
538 
540 bool
541 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
542  TfSpan<const GfMatrix4d> jointXforms,
543  TfSpan<const int> jointIndices,
544  TfSpan<const float> jointWeights,
545  int numInfluencesPerPoint,
547  bool inSerial=false);
548 
549 /// \overload
551 bool
552 UsdSkelSkinPointsLBS(const GfMatrix4f& geomBindTransform,
553  TfSpan<const GfMatrix4f> jointXforms,
554  TfSpan<const int> jointIndices,
555  TfSpan<const float> jointWeights,
556  int numInfluencesPerPoint,
558  bool inSerial=false);
559 
560 
561 /// Skin points using linear blend skinning, with interleaved influences.
563 bool
564 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
565  TfSpan<const GfMatrix4d> jointXforms,
566  TfSpan<const GfVec2f> influences,
567  int numInfluencesPerPoint,
569  bool inSerial=false);
570 
571 /// \overload
573 bool
574 UsdSkelSkinPointsLBS(const GfMatrix4f& geomBindTransform,
575  TfSpan<const GfMatrix4f> jointXforms,
576  TfSpan<const GfVec2f> influences,
577  int numInfluencesPerPoint,
579  bool inSerial=false);
580 
581 
582 /// \overload
583 /// \deprecated Use form that takes TfSpan arguments.
585 bool
586 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
587  const VtMatrix4dArray& jointXforms,
588  const VtIntArray& jointIndices,
589  const VtFloatArray& jointWeights,
590  int numInfluencesPerPoint,
591  VtVec3fArray* points);
592 
593 
594 /// \overload
595 /// \deprecated Use form that takes TfSpan arguments.
597 bool
598 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
599  const GfMatrix4d* jointXforms,
600  size_t numJoints,
601  const int* jointIndices,
602  const float* jointWeights,
603  size_t numInfluences,
604  int numInfluencesPerPoint,
605  GfVec3f* points,
606  size_t numPoints,
607  bool inSerial=false);
608 
609 
610 /// Skin normals using linear blend skinning (LBS) or dual quaternion skinning (DQS),
611 /// for normals with _vertex_ or _varying_ interpolation.
612 /// Use UsdSkelSkinFaceVaryingNormals() for normals with _faceVarying__
613 /// interpolation.
614 /// The \p jointXforms are the *inverse transposes* of the 3x3 component
615 /// of the \ref UsdSkel_Term_SkinningTransforms" "skinning transforms",
616 /// given in _skeleton space_. The \p geomBindTransform is the
617 /// *inverse transpose* of the matrix that transforms points from a
618 /// bind pose ino the same _skeleton space_ that the skinning tranforms
619 /// were computed in.
621 bool
622 UsdSkelSkinNormals(const TfToken& skinningMethod,
623  const GfMatrix3d& geomBindTransform,
624  TfSpan<const GfMatrix3d> jointXforms,
625  TfSpan<const int> jointIndices,
626  TfSpan<const float> jointWeights,
627  int numInfluencesPerPoint,
628  TfSpan<GfVec3f> normals,
629  bool inSerial=false);
630 
631 
632 /// \overload
634 bool
635 UsdSkelSkinNormals(const TfToken& skinningMethod,
636  const GfMatrix3f& geomBindTransform,
637  TfSpan<const GfMatrix3f> jointXforms,
638  TfSpan<const int> jointIndices,
639  TfSpan<const float> jointWeights,
640  int numInfluencesPerPoint,
641  TfSpan<GfVec3f> normals,
642  bool inSerial=false);
643 
644 
645 /// \overload
647 bool
648 UsdSkelSkinNormals(const TfToken& skinningMethod,
649  const GfMatrix3d& geomBindTransform,
650  TfSpan<const GfMatrix3d> jointXforms,
651  TfSpan<const GfVec2f> influences,
652  int numInfluencesPerPoint,
653  TfSpan<GfVec3f> normals,
654  bool inSerial=false);
655 
656 
657 /// \overload
659 bool
660 UsdSkelSkinNormals(const TfToken& skinningMethod,
661  const GfMatrix3f& geomBindTransform,
662  TfSpan<const GfMatrix3f> jointXforms,
663  TfSpan<const GfVec2f> influences,
664  int numInfluencesPerPoint,
665  TfSpan<GfVec3f> normals,
666  bool inSerial=false);
667 
668 
669 /// Skin normals with _faceVarying_ interpolation using LBS or DQS
671 bool
672 UsdSkelSkinFaceVaryingNormals(const TfToken& skinningMethod,
673  const GfMatrix3d& geomBindTransform,
674  TfSpan<const GfMatrix3d> jointXforms,
675  TfSpan<const int> jointIndices,
676  TfSpan<const float> jointWeights,
677  int numInfluencesPerPoint,
678  TfSpan<const int> faceVertexIndices,
679  TfSpan<GfVec3f> normals,
680  bool inSerial=false);
681 
682 /// \overload
684 bool
685 UsdSkelSkinFaceVaryingNormals(const TfToken& skinningMethod,
686  const GfMatrix3f& geomBindTransform,
687  TfSpan<const GfMatrix3f> jointXforms,
688  TfSpan<const int> jointIndices,
689  TfSpan<const float> jointWeights,
690  int numInfluencesPerPoint,
691  TfSpan<const int> faceVertexIndices,
692  TfSpan<GfVec3f> normals,
693  bool inSerial=false);
694 
695 
697 bool
698 UsdSkelSkinNormalsLBS(const GfMatrix3d& geomBindTransform,
699  TfSpan<const GfMatrix3d> jointXforms,
700  TfSpan<const int> jointIndices,
701  TfSpan<const float> jointWeights,
702  int numInfluencesPerPoint,
703  TfSpan<GfVec3f> normals,
704  bool inSerial=false);
705 
706 
707 /// \overload
709 bool
710 UsdSkelSkinNormalsLBS(const GfMatrix3f& geomBindTransform,
711  TfSpan<const GfMatrix3f> jointXforms,
712  TfSpan<const int> jointIndices,
713  TfSpan<const float> jointWeights,
714  int numInfluencesPerPoint,
715  TfSpan<GfVec3f> normals,
716  bool inSerial=false);
717 
718 
719 /// \overload
721 bool
722 UsdSkelSkinNormalsLBS(const GfMatrix3d& geomBindTransform,
723  TfSpan<const GfMatrix3d> jointXforms,
724  TfSpan<const GfVec2f> influences,
725  int numInfluencesPerPoint,
726  TfSpan<GfVec3f> normals,
727  bool inSerial=false);
728 
729 
730 /// \overload
732 bool
733 UsdSkelSkinNormalsLBS(const GfMatrix3f& geomBindTransform,
734  TfSpan<const GfMatrix3f> jointXforms,
735  TfSpan<const GfVec2f> influences,
736  int numInfluencesPerPoint,
737  TfSpan<GfVec3f> normals,
738  bool inSerial=false);
739 
740 /// Skin normals with _faceVarying_ interpolation using linear blend skinning.
742 bool
743 UsdSkelSkinFaceVaryingNormalsLBS(const GfMatrix3d& geomBindTransform,
744  TfSpan<const GfMatrix3d> jointXforms,
745  TfSpan<const int> jointIndices,
746  TfSpan<const float> jointWeights,
747  int numInfluencesPerPoint,
748  TfSpan<const int> faceVertexIndices,
749  TfSpan<GfVec3f> normals,
750  bool inSerial=false);
751 
752 /// \overload
754 bool
755 UsdSkelSkinFaceVaryingNormalsLBS(const GfMatrix3f& geomBindTransform,
756  TfSpan<const GfMatrix3f> jointXforms,
757  TfSpan<const int> jointIndices,
758  TfSpan<const float> jointWeights,
759  int numInfluencesPerPoint,
760  TfSpan<const int> faceVertexIndices,
761  TfSpan<GfVec3f> normals,
762  bool inSerial=false);
763 
764 
765 /// Skin a transform using linear blend skinning (LBS) or dual quaternion skinning (DQS).
766 /// The \p jointXforms are \ref UsdSkel_Term_SkinningTransforms
767 /// "skinning transforms", given in _skeleton space_, while the
768 /// \p geomBindTransform provides the transform that initially places
769 /// a primitive in that same _skeleton space_.
771 bool
772 UsdSkelSkinTransform(const TfToken& skinningMethod,
773  const GfMatrix4d& geomBindTransform,
774  TfSpan<const GfMatrix4d> jointXforms,
775  TfSpan<const int> jointIndices,
776  TfSpan<const float> jointWeights,
777  GfMatrix4d* xform);
778 
779 /// \overload
781 bool
782 UsdSkelSkinTransform(const TfToken& skinningMethod,
783  const GfMatrix4f& geomBindTransform,
784  TfSpan<const GfMatrix4f> jointXforms,
785  TfSpan<const int> jointIndices,
786  TfSpan<const float> jointWeights,
787  GfMatrix4f* xform);
788 
789 /// Overload taking interleaved joint influences.
790 /// \overload
792 bool
793 UsdSkelSkinTransform(const TfToken& skinningMethod,
794  const GfMatrix4d& geomBindTransform,
795  TfSpan<const GfMatrix4d> jointXforms,
796  TfSpan<const GfVec2f> influences,
797  GfMatrix4d* xform);
798 
799 /// \overload
801 bool
802 UsdSkelSkinTransform(const TfToken& skinningMethod,
803  const GfMatrix4f& geomBindTransform,
804  TfSpan<const GfMatrix4f> jointXforms,
805  TfSpan<const GfVec2f> influences,
806  GfMatrix4f* xform);
807 
808 /// \overload
809 /// \deprecated Use form that takes TfSpan arguments.
811 bool
812 UsdSkelSkinTransform(const TfToken& skinningMethod,
813  const GfMatrix4d& geomBindTransform,
814  const GfMatrix4d* jointXforms,
815  size_t numJoints,
816  const int* jointIndices,
817  const float* jointWeights,
818  size_t numInfluences,
819  GfMatrix4d* xform);
820 
821 
823 bool
824 UsdSkelSkinTransformLBS(const GfMatrix4d& geomBindTransform,
825  TfSpan<const GfMatrix4d> jointXforms,
826  TfSpan<const int> jointIndices,
827  TfSpan<const float> jointWeights,
828  GfMatrix4d* xform);
829 
830 /// \overload
832 bool
833 UsdSkelSkinTransformLBS(const GfMatrix4f& geomBindTransform,
834  TfSpan<const GfMatrix4f> jointXforms,
835  TfSpan<const int> jointIndices,
836  TfSpan<const float> jointWeights,
837  GfMatrix4f* xform);
838 
839 /// Overload taking interleaved joint influences.
840 /// \overload
842 bool
843 UsdSkelSkinTransformLBS(const GfMatrix4d& geomBindTransform,
844  TfSpan<const GfMatrix4d> jointXforms,
845  TfSpan<const GfVec2f> influences,
846  GfMatrix4d* xform);
847 
848 /// \overload
850 bool
851 UsdSkelSkinTransformLBS(const GfMatrix4f& geomBindTransform,
852  TfSpan<const GfMatrix4f> jointXforms,
853  TfSpan<const GfVec2f> influences,
854  GfMatrix4f* xform);
855 
856 /// \overload
857 /// \deprecated Use form that takes TfSpan arguments.
859 bool
860 UsdSkelSkinTransformLBS(const GfMatrix4d& geomBindTransform,
861  const GfMatrix4d* jointXforms,
862  size_t numJoints,
863  const int* jointIndices,
864  const float* jointWeights,
865  size_t numInfluences,
866  GfMatrix4d* xform);
867 
868 
869 /// Apply a single blend shape to \p points.
870 /// The shape is given as a span of \p offsets. If the \p indices span is not
871 /// empty, it provides the index into the \p points span at which each offset
872 /// should be mapped. Otherwise, the \p offsets span must be the same size as
873 /// the \p points span.
875 bool
876 UsdSkelApplyBlendShape(const float weight,
880 
881 /// @}
882 
883 /// @}
884 
886 
887 
888 #endif // PXR_USD_USD_SKEL_UTILS_H
USDSKEL_API bool UsdSkelSkinPoints(const TfToken &skinningMethod, const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > points, bool inSerial=false)
USDSKEL_API bool UsdSkelComputeJointLocalTransforms(const UsdSkelTopology &topology, TfSpan< const GfMatrix4d > xforms, TfSpan< const GfMatrix4d > inverseXforms, TfSpan< GfMatrix4d > jointLocalXforms, const GfMatrix4d *rootInverseXform=nullptr)
USDSKEL_API bool UsdSkelInterleaveInfluences(const TfSpan< const int > &indices, const TfSpan< const float > &weights, TfSpan< GfVec2f > interleavedInfluences)
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
USDSKEL_API bool UsdSkelDecomposeTransforms(TfSpan< const GfMatrix4d > xforms, TfSpan< GfVec3f > translations, TfSpan< GfQuatf > rotations, TfSpan< GfVec3h > scales)
Definition: vec3f.h:45
USDSKEL_API bool UsdSkelConcatJointTransforms(const UsdSkelTopology &topology, TfSpan< const GfMatrix4d > jointLocalXforms, TfSpan< GfMatrix4d > xforms, const GfMatrix4d *rootXform=nullptr)
USDSKEL_API bool UsdSkelIsSkinnablePrim(const UsdPrim &prim)
Definition: quatf.h:42
USDSKEL_API bool UsdSkelSkinFaceVaryingNormalsLBS(const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< const int > faceVertexIndices, TfSpan< GfVec3f > normals, bool inSerial=false)
Skin normals with faceVarying interpolation using linear blend skinning.
USDSKEL_API bool UsdSkelExpandConstantInfluencesToVarying(VtIntArray *indices, size_t size)
void pad(T &out, int n)
Definition: ImfXdr.h:407
USDSKEL_API bool UsdSkelResizeInfluences(VtIntArray *indices, int srcNumInfluencesPerComponent, int newNumInfluencesPerComponent)
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
GA_API const UT_StringHolder scale
GLfloat f
Definition: glcorearb.h:1926
Definition: token.h:70
USDSKEL_API void UsdSkelMakeTransform(const GfVec3f &translate, const GfMatrix3f &rotate, const GfVec3h &scale, Matrix4 *xform)
Definition: span.h:70
GT_API const UT_StringHolder topology
UT_Matrix4T< Float > Matrix4
Definition: APEX_Include.h:68
Definition: prim.h:116
USDSKEL_API bool UsdSkelSortInfluences(TfSpan< int > indices, TfSpan< float > weights, int numInfluencesPerComponent)
Sort joint influences such that highest weight values come first.
USDSKEL_API bool UsdSkelDecomposeTransform(const Matrix4 &xform, GfVec3f *translate, GfRotation *rotate, GfVec3h *scale)
#define USDSKEL_API
Definition: api.h:23
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
USDSKEL_API bool UsdSkelComputeJointsExtent(TfSpan< const Matrix4 > joints, GfRange3f *extent, float pad=0.0f, const Matrix4 *rootXform=nullptr)
USDSKEL_API bool UsdSkelApplyBlendShape(const float weight, const TfSpan< const GfVec3f > offsets, const TfSpan< const int > indices, TfSpan< GfVec3f > points)
GLsizeiptr size
Definition: glcorearb.h:664
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDSKEL_API bool UsdSkelSkinFaceVaryingNormals(const TfToken &skinningMethod, const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< const int > faceVertexIndices, TfSpan< GfVec3f > normals, bool inSerial=false)
Skin normals with faceVarying interpolation using LBS or DQS.
USDSKEL_API bool UsdSkelSkinTransformLBS(const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, GfMatrix4d *xform)
USDSKEL_API bool UsdSkelMakeTransforms(TfSpan< const GfVec3f > translations, TfSpan< const GfQuatf > rotations, TfSpan< const GfVec3h > scales, TfSpan< GfMatrix4d > xforms)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDSKEL_API bool UsdSkelSkinPointsLBS(const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > points, bool inSerial=false)
USDSKEL_API bool UsdSkelSkinTransform(const TfToken &skinningMethod, const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, GfMatrix4d *xform)
USDSKEL_API bool UsdSkelSkinNormals(const TfToken &skinningMethod, const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > normals, bool inSerial=false)
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8574
USDSKEL_API bool UsdSkelSkinNormalsLBS(const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > normals, bool inSerial=false)
USDSKEL_API bool UsdSkelIsSkelAnimationPrim(const UsdPrim &prim)
Returns true if prim is a valid skel animation source.
Definition: vec3h.h:46
USDSKEL_API bool UsdSkelNormalizeWeights(TfSpan< float > weights, int numInfluencesPerComponent, float eps=std::numeric_limits< float >::epsilon())
GLint GLsizei count
Definition: glcorearb.h:405