summaryrefslogtreecommitdiffstats
path: root/src/animation
diff options
context:
space:
mode:
authorSvenn-Arne Dragly <s@dragly.com>2018-04-18 09:48:27 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2018-04-24 17:59:07 +0000
commitf3c36a720abefad17d7cf0cb84a9f5a8ab9c2984 (patch)
treefe71c313008e0736f0a3d403de80b2bb35d7265b /src/animation
parent3e82b9bf123f8e2da962b13121391ae2202424c9 (diff)
Animation: Make a fuzzy comparison when verifying cubic roots
Accept cubic roots that are close enough to 0 or 1 that the difference is likely a numerical error. Also add a regression test to catch one of these corner cases. Task-number: QTBUG-67886 Change-Id: Ia05650699638e4bb7d13fa18b31d71071909bd51 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/animation')
-rw-r--r--src/animation/backend/bezierevaluator.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/animation/backend/bezierevaluator.cpp b/src/animation/backend/bezierevaluator.cpp
index 2752904fc..320f8b7ad 100644
--- a/src/animation/backend/bezierevaluator.cpp
+++ b/src/animation/backend/bezierevaluator.cpp
@@ -151,8 +151,8 @@ float BezierEvaluator::parameterForTime(float time) const
float roots[3];
const int numberOfRoots = findCubicRoots(coeffs, roots);
for (int i = 0; i < numberOfRoots; ++i) {
- if (roots[i] >= 0 && roots[i] <= 1)
- return roots[i];
+ if (roots[i] >= -0.01f && roots[i] <= 1.01f)
+ return qMin(qMax(roots[i], 0.0f), 1.0f);
}
qWarning() << "Failed to find root of cubic bezier at time" << time