From 7712d86512530e6f7716530b7bbb17658f45affa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Apr 2014 06:05:54 +1000 Subject: Error in last commit, need to take duration into account --- source/blender/blenlib/intern/easing.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/blenlib/intern/easing.c') diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c index 90bdd3a5cc3..1f39c2f57b5 100644 --- a/source/blender/blenlib/intern/easing.c +++ b/source/blender/blenlib/intern/easing.c @@ -148,12 +148,12 @@ float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float * When the amplitude is less then the change, we need to blend * \a f when we're close to the crossing point (int time), else we get an ugly sharp falloff. */ -static float elastic_blend(float time, float change, float amplitude, float period, float f) +static float elastic_blend(float time, float change, float duration, float amplitude, float s, float f) { if (change) { /* Looks like a magic number, * but this is a part of the sine curve we need to blend from */ - const float t = fabsf(period) / (64 * (float)M_PI); + const float t = fabsf(s); if (amplitude) { f *= amplitude / fabsf(change); } @@ -161,8 +161,8 @@ static float elastic_blend(float time, float change, float amplitude, float peri f = 0.0f; } - if (fabsf(time) < t) { - float l = fabsf(time) / t; + if (fabsf(time * duration) < t) { + float l = fabsf(time * duration) / t; f = (f * l) + (1.0f - l); } } @@ -185,11 +185,11 @@ float BLI_easing_elastic_ease_in(float time, float begin, float change, float du if (!period) period = duration * 0.3f; if (!amplitude || amplitude < fabsf(change)) { + s = period / 4; #ifdef USE_ELASTIC_BLEND - f = elastic_blend(time, change, amplitude, period, f); + f = elastic_blend(time, change, duration, amplitude, s, f); #endif amplitude = change; - s = period / 4; } else s = period / (2 * (float)M_PI) * asinf(change / amplitude); @@ -210,11 +210,11 @@ float BLI_easing_elastic_ease_out(float time, float begin, float change, float d if (!period) period = duration * 0.3f; if (!amplitude || amplitude < fabsf(change)) { + s = period / 4; #ifdef USE_ELASTIC_BLEND - f = elastic_blend(time, change, amplitude, period, f); + f = elastic_blend(time, change, duration, amplitude, s, f); #endif amplitude = change; - s = period / 4; } else s = period / (2 * (float)M_PI) * asinf(change / amplitude); @@ -235,11 +235,11 @@ float BLI_easing_elastic_ease_in_out(float time, float begin, float change, floa if (!period) period = duration * (0.3f * 1.5f); if (!amplitude || amplitude < fabsf(change)) { + s = period / 4; #ifdef USE_ELASTIC_BLEND - f = elastic_blend(time, change, amplitude, period, f); + f = elastic_blend(time, change, duration, amplitude, s, f); #endif amplitude = change; - s = period / 4; } else s = period / (2 * (float)M_PI) * asinf(change / amplitude); -- cgit v1.2.3