diff options
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/util/qdeclarativesmoothedanimation.cpp | 31 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativesmoothedanimation_p_p.h | 2 |
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 |