summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2021-11-25 15:52:09 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-26 13:51:22 +0000
commit7f912255f25cf5d7afffef6f2e4d6d81663ef649 (patch)
tree02fc629073784935a4dc6df127cf469fc4420906
parent736ebd791623484468aa7bb2d5d54c08c968c4cf (diff)
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 <paul.lemire@kdab.com> (cherry picked from commit 98599ddee4761cf1970a97737293f5f627f3f61a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/animation/backend/animationclip.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/animation/backend/animationclip.cpp b/src/animation/backend/animationclip.cpp
index 24b41a50f..d4a1f133a 100644
--- a/src/animation/backend/animationclip.cpp
+++ b/src/animation/backend/animationclip.cpp
@@ -358,17 +358,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()