From f7e46e5e574ef93eafe4d3674413d251a8dc5f65 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Thu, 25 Nov 2021 15:52:09 +0100 Subject: Revert "AnimationClip: fix the way we compute the duration" Turns out we want the global clip duration and not the relative clip duration. Therefore global clip duration is always computed from 0. If the first keyframe is offset, then this means animation does nothing until t=offset. This reverts commit 7b23cb1ca5b32fcf24f889e79cec756786f86233. Change-Id: Ic045a3cdea5eac4b8e35b75737e3ae6f00b9fa20 Reviewed-by: Paul Lemire (cherry picked from commit 98599ddee4761cf1970a97737293f5f627f3f61a) Reviewed-by: Qt Cherry-pick Bot --- src/animation/backend/animationclip.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/animation/backend/animationclip.cpp b/src/animation/backend/animationclip.cpp index f051d68d9..4e11c7968 100644 --- a/src/animation/backend/animationclip.cpp +++ b/src/animation/backend/animationclip.cpp @@ -355,17 +355,14 @@ float AnimationClip::findDuration() { // Iterate over the contained fcurves and find the longest one float tMax = 0.f; - float tMin = 1.0f; for (const Channel &channel : qAsConst(m_channels)) { for (const ChannelComponent &channelComponent : qAsConst(channel.channelComponents)) { - const float tStart = channelComponent.fcurve.startTime(); - const float tEnd = channelComponent.fcurve.endTime(); - tMax = std::max(tEnd, tMax); - tMin = std::min(tStart, tMin); + const float t = channelComponent.fcurve.endTime(); + if (t > tMax) + tMax = t; } } - // We can't have a negative duration - return std::max(tMax - tMin, 0.0f); + return tMax; } int AnimationClip::findChannelComponentCount() -- cgit v1.2.3