diff options
author | Christian Strømme <christian.stromme@qt.io> | 2018-04-20 14:50:26 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@qt.io> | 2018-04-23 07:36:23 +0000 |
commit | 4a067500e839a3558dfd3786e943afa69433a0a1 (patch) | |
tree | dff7040a29ad9da2ec0757d89992008c72e57fee | |
parent | d64496616a61c5796dbc6c34a79428b1e6e0d2d9 (diff) |
Force update on the animators when seeking
The tracking on the animators were removed in a previous change, so the
value the fronted node was holding was assumed unchanged, and thus not
causing the position to be updated.
Instead of enabling tracking again, which comes with an overhead, we
instead adjust the value slightly to trigger the update.
Task-number: QT3DS-1312
Change-Id: I629d73a5464ef89d9cee54bf3bb2c3994406cbbf
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r-- | src/runtime/q3dsslideplayer.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp index faec815..33f068a 100644 --- a/src/runtime/q3dsslideplayer.cpp +++ b/src/runtime/q3dsslideplayer.cpp @@ -105,8 +105,10 @@ static void updatePosition(Q3DSSlide *slide, float pos, float duration) if (!animator) return; - const float f = qBound(0.0f, pos / duration, 1.0f); - animator->setNormalizedTime(f); + const float nt = qBound(0.0f, pos / duration, 1.0f); + // NOTE!!!: This is a bit funky, but it means we can avoid tracking the normalized values in the + // frontend node. This of course assumes that the limit in the fuzzy compare doesn't change! + animator->setNormalizedTime(qFuzzyCompare(nt, animator->normalizedTime()) ? (nt + (1.0f / 100000.0f)) : nt); }; const auto updateAnimators = [&updateAnimator](const QVector<Qt3DAnimation::QClipAnimator *> &animators) { for (auto animator : animators) { @@ -140,8 +142,12 @@ static void updateAnimators(Q3DSSlide *slide, bool running, bool restart, float if (!animator) return; - if (restart) - animator->setNormalizedTime(0.0f); + if (restart) { + // NOTE!!!: This is a bit funky, but it means we can avoid tracking the normalized values in the + // frontend node. This of course assumes that the limit in the fuzzy compare doesn't change! + const float nt = qFuzzyCompare(animator->normalizedTime(), 0.0f) ? (0.0f + (1.f / 100000.f)) : 0.0f; + animator->setNormalizedTime(nt); + } animator->clock()->setPlaybackRate(double(rate)); animator->setRunning(running); }; |