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-29 08:03:39 +0000
commitf7e46e5e574ef93eafe4d3674413d251a8dc5f65 (patch)
tree5a874b69bc9bca6ea266731d2af062e14542dc0d
parent99241de47266acb50135bb5f20d0875b2adb2600 (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 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()