aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-07-27 14:23:49 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-28 10:04:08 +0200
commitc57a9238e94942d883f79de8d1ac277092903790 (patch)
treefbc93c648ffbb600d10cd026f0222b7906d4995f /src
parentdb6c099e42f96710f2ad09f6d3d2c94ffba600d7 (diff)
Don't jump around when maximumEasingTime is specified
Task-number: QTBUG-20436 Change-Id: I477c42d55e712e141403b3a95d1c9b0685df5f0d Reviewed-on: http://codereview.qt.nokia.com/2240 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativesmoothedanimation.cpp31
-rw-r--r--src/declarative/util/qdeclarativesmoothedanimation_p_p.h2
2 files changed, 18 insertions, 15 deletions
diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp
index b77db89043..2200d2c77c 100644
--- a/src/declarative/util/qdeclarativesmoothedanimation.cpp
+++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp
@@ -123,20 +123,23 @@ bool QSmoothedAnimation::recalc()
sd = s;
} else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) {
qreal met = maximumEasingTime / 1000.;
- td = tf - met;
-
- qreal c1 = td;
- qreal c2 = (tf - td) * vi - tf * velocity;
- qreal c3 = -0.5 * (tf - td) * vi * vi;
-
- qreal vp1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
-
- vp = vp1;
- a = vp / met;
- d = a;
- tp = (vp - vi) / a;
- sp = vi * tp + 0.5 * a * tp * tp;
- sd = sp + (td - tp) * vp;
+ // tp| |td
+ // vp_ _______
+ // / \
+ // vi_ / \
+ // \
+ // \ _ 0
+ // |ta| |ta|
+ //
+ qreal ta = met / 2.;
+ a = (s - (vi * tf - 0.5 * vi * ta)) / (tf * ta - ta * ta);
+
+ vp = vi + a * ta;
+ d = vp / ta;
+ tp = ta;
+ sp = vi * ta + 0.5 * a * tp * tp;
+ sd = sp + vp * (tf - 2 * ta);
+ td = tf - ta;
} else {
qreal c1 = 0.25 * tf * tf;
qreal c2 = 0.5 * vi * tf - s;
diff --git a/src/declarative/util/qdeclarativesmoothedanimation_p_p.h b/src/declarative/util/qdeclarativesmoothedanimation_p_p.h
index 0ce2eab254..161fb11491 100644
--- a/src/declarative/util/qdeclarativesmoothedanimation_p_p.h
+++ b/src/declarative/util/qdeclarativesmoothedanimation_p_p.h
@@ -103,7 +103,7 @@ private:
qreal d; // Deceleration
qreal tf; // Total time
qreal tp; // Time at which peak velocity occurs
- qreal td; // Time at which decelleration begins
+ qreal td; // Time at which deceleration begins
qreal vp; // Velocity at tp
qreal sp; // Displacement at tp
qreal sd; // Displacement at td