hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3b6a5956f9dba282720fb779ed01800305eb5674

commit 3b6a5956f9dba282720fb779ed01800305eb5674
Author: ChunEon Park <her...@hermet.pe.kr>
Date:   Tue Dec 9 16:27:29 2014 +0900

    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
---
 src/lib/ecore/ecore_anim.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c
index e248f05..a59320a 100644
--- a/src/lib/ecore/ecore_anim.c
+++ b/src/lib/ecore/ecore_anim.c
@@ -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;
 }
 

-- 


Reply via email to