From 16bab2479a1fa9c35364bdd37eee6d8f57110a2b Mon Sep 17 00:00:00 2001 From: Evan Mezeske Date: Mon, 25 Nov 2024 10:47:28 -0700 Subject: [PATCH] When applying animations, allow the time to be exactly equal to the duration before taking the fmod(), so that it is possible to animate to the exact last keyframe. Without this change, trying to animate to the last keyframe wraps back to the first, which only works for animations that loop. (#8287) --- libs/gltfio/src/Animator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gltfio/src/Animator.cpp b/libs/gltfio/src/Animator.cpp index 6e53b705c606..0d8b667644b1 100644 --- a/libs/gltfio/src/Animator.cpp +++ b/libs/gltfio/src/Animator.cpp @@ -264,7 +264,7 @@ size_t Animator::getAnimationCount() const { void Animator::applyAnimation(size_t animationIndex, float time) const { const Animation& anim = mImpl->animations[animationIndex]; - time = fmod(time, anim.duration); + time = time == anim.duration ? time : fmod(time, anim.duration); TransformManager& transformManager = *mImpl->transformManager; transformManager.openLocalTransformTransaction(); for (const auto& channel : anim.channels) {