diff options
author | Christian Strømme <christian.stromme@qt.io> | 2018-03-02 16:11:20 +0100 |
---|---|---|
committer | Christian Stromme <christian.stromme@qt.io> | 2018-03-07 10:32:13 +0000 |
commit | ebe9e782b18b57cc5282deb01044390c2b080283 (patch) | |
tree | ee1dc17ed5826ddf378c890ed090094c6bdc19b1 /src/runtime/q3dsanimationmanager.cpp | |
parent | 25bec131b2650023f9dcc662ca2a455a42bc8dea (diff) |
Adjust calculation of the control points for the easing values
This is a follow up change to 4166e5e2e052313e to get closer to the
smooth easing curves in Studio 1.0
Change-Id: Ibcf664cc90184cd5eb6f2fa4237b33bb2dcf14b3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/runtime/q3dsanimationmanager.cpp')
-rw-r--r-- | src/runtime/q3dsanimationmanager.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/runtime/q3dsanimationmanager.cpp b/src/runtime/q3dsanimationmanager.cpp index 0e32e6f..1324864 100644 --- a/src/runtime/q3dsanimationmanager.cpp +++ b/src/runtime/q3dsanimationmanager.cpp @@ -333,25 +333,29 @@ void Q3DSAnimationManager::updateAnimationHelper(const AnimationTrackListMap<T * // option we support at the moment. // Get normalized value [0..1] - const float easeIn = qBound(0.0f, (it->easeIn / 100.0f) / 2.0f, 1.0f); - const float easeOut = qBound(0.0f, (it->easeOut / 100.0f) / 2.0f, 1.0f); + const float easeIn = qBound(0.0f, (it->easeIn / 100.0f), 1.0f); + const float easeOut = qBound(0.0f, (it->easeOut / 100.0f), 1.0f); // Next and previous keyframes, if any. const auto next = ((it + 1) != end) ? (it + 1) : it; const auto previous = (it != begin) ? (it - 1) : it; + // Adjustment to the easing values, to limit the range of the control points, + // so we get the same "smooth" easing curves as in Studio 1.0 + static const float adjustment = 0.3333334f; + // p0 const QVector2D coordinates(it->time, it->value); // c1 float dt = (next->time - it->time); - const float p1t = qBound(it->time, it->time + (dt * easeIn), next->time); + const float p1t = qBound(it->time, it->time + (dt * easeIn * adjustment), next->time); const float p1v = it->value; const QVector2D rightControlPoint(p1t, p1v); // c2 dt = (it->time - previous->time); - const float p2t = qBound(previous->time, it->time - (dt * easeOut), it->time); + const float p2t = qBound(previous->time, it->time - (dt * easeOut * adjustment), it->time); const float p2v = it->value; const QVector2D leftControlPoint(p2t, p2v); |