diff options
author | Juan Jose Casafranca <juan.casafranca@kdab.com> | 2019-05-14 09:57:34 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-05-14 10:23:03 +0000 |
commit | c29f18b052b8a1768f7d3d60ab098b42d67c0d1d (patch) | |
tree | 3f206b156cf3c69451da2ab172435edc200c00ff | |
parent | 2b0f52bd4c2c9035d5ca1672e4ce4229490eb655 (diff) |
Check if animation channel only have one component and shortcircuit
Change-Id: I6f80d3378fe3002142e2d84d410bcbf356cb02ea
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/animation/backend/animationutils.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 01484476d..29de69df6 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -253,10 +253,9 @@ ClipResults evaluateClipAtLocalTime(AnimationClip *clip, float localTime) } } else { // There's only one keyframe. We cant compute omega. Interpolate per component - const int lowerKeyframeBound = channel.channelComponents[0].fcurve.lowerKeyframeBound(localTime); - if (lowerKeyframeBound + 1 >= channel.channelComponents[0].fcurve.keyframeCount()) { + if (channel.channelComponents[0].fcurve.keyframeCount() == 1) { for (const auto &channelComponent : qAsConst(channel.channelComponents)) - channelResults[i++] = channelComponent.fcurve.evaluateAtTime(localTime, lowerKeyframeBound); + channelResults[i++] = channelComponent.fcurve.keyframe(0).value; } else { auto quaternionFromChannel = [channel](const int keyframe) { const float w = channel.channelComponents[0].fcurve.keyframe(keyframe).value; @@ -268,6 +267,7 @@ ClipResults evaluateClipAtLocalTime(AnimationClip *clip, float localTime) return quat; }; + const int lowerKeyframeBound = channel.channelComponents[0].fcurve.lowerKeyframeBound(localTime); const auto lowerQuat = quaternionFromChannel(lowerKeyframeBound); const auto higherQuat = quaternionFromChannel(lowerKeyframeBound + 1); const float omega = std::acos(qBound(-1.0f, QQuaternion::dotProduct(lowerQuat, higherQuat), 1.0f)); |