ecore/animator: fix the wrong computation of bezier cubic.

Previous beizer cubic finds t value approximately.
In this sequence, there were 2 problems.

1. Previous guess_t value should be passed to differential equation to get the more accurate t value.
2. Guessing time count is not enough. I found 6 is enough time to get the t value experimentally. Previously it just tried 4 times on the other hand.

@fix
This commit is contained in:
ChunEon Park 2014-12-09 16:27:29 +09:00
parent 4e1c0c54ec
commit 3b6a5956f9
1 changed files with 17 additions and 8 deletions

View File

@ -350,15 +350,24 @@ _cubic_bezier_t_get(double a,
double x1,
double x2)
{
#define APPROXIMATE_RANGE(val) \
((((val) < 0.01) && ((val) > -0.01)) ? EINA_TRUE : EINA_FALSE)
const int LIMIT = 100;
double current_slope;
double tmp;
double current_x;
double guess_t = a;
for (int i = 0; i < 4; ++i)
{
double current_slope = _cubic_bezier_slope_get(a, x1, x2);
if (current_slope == 0.0)
return guess_t;
double current_x = _cubic_bezier_calc(guess_t, x1, x2) - a;
guess_t -= current_x / current_slope;
}
for (int i = 0; i < LIMIT; i++)
{
current_slope = _cubic_bezier_slope_get(guess_t, x1, x2);
if (current_slope == 0.0) return guess_t;
current_x = _cubic_bezier_calc(guess_t, x1, x2) - a;
tmp = current_x / current_slope;
guess_t -= current_x / current_slope;
if (APPROXIMATE_RANGE(tmp)) break;
}
return guess_t;
}