diff --git a/libs/gltfio/include/gltfio/Animator.h b/libs/gltfio/include/gltfio/Animator.h index 199555a40d3..25416a13a10 100644 --- a/libs/gltfio/include/gltfio/Animator.h +++ b/libs/gltfio/include/gltfio/Animator.h @@ -56,6 +56,18 @@ class UTILS_PUBLIC Animator { */ void updateBoneMatrices(); + /** + * Updates the bone matrices of the specified instance using the state of this animatior. + * This is useful if you have another instance that has the same skeleton as the asset of this animator, + * and you wish to apply the same animation to those instances (e.g. clothing). + * + * NOTE: In most cases, you only need to use the updateBoneMatrices() method. This method is necessary + * only when you need to synchronize animations across multiple instances with the same skeleton. + * + * @param instance The instance to update. + */ + void updateBoneMatricesForInstance(FilamentInstance* instance); + /** * Applies a blended transform to the union of nodes affected by two animations. * Used for cross-fading from a previous skinning-based animation or rigid body animation. diff --git a/libs/gltfio/src/Animator.cpp b/libs/gltfio/src/Animator.cpp index 6e53b705c60..ff41bdf599c 100644 --- a/libs/gltfio/src/Animator.cpp +++ b/libs/gltfio/src/Animator.cpp @@ -336,6 +336,10 @@ void Animator::updateBoneMatrices() { } } +void Animator::updateBoneMatricesForInstance(FilamentInstance* instance) { + mImpl->updateBoneMatrices(downcast(instance)); +} + float Animator::getAnimationDuration(size_t animationIndex) const { return mImpl->animations[animationIndex].duration; }