From 4168ed09de75d4bea08e206103e4eac3e1047d1c Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 18 Dec 2008 12:20:46 +0000 Subject: [PATCH] Fix calculation in clutter_cubic_bezier The calculation for cubic bezier curves had an extra multiplication by 3 which was causing the curve to go over 1.0 very quickly. This had the affect of making test-animation appear to complete much before the completed signal is emitted. --- clutter/clutter-alpha.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c index aee22a09c..2114fe38e 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -1282,7 +1282,7 @@ clutter_cubic_bezier (ClutterAlpha *alpha, * B(t) = (1 - t)^3 * P_0 * + 3t * (1 - t)^2 * P_1 * + 3t^2 * (1 - t) * P_2 - * + 3t^3 * P_3 (with t included in [0, 1]) + * + t^3 * P_3 (with t included in [0, 1]) * * the P_0 and P_3 points are set to (0, 0) and (1, 1) respectively, * and the curve never passes through P_1 and P_2 - with these two @@ -1294,14 +1294,14 @@ clutter_cubic_bezier (ClutterAlpha *alpha, * * B(t) = 3t * (1 - t)^2 * P_1 * + 3t^2 * (1 - t) * P_2 - * + 3t^3 * P_3 (with t included in [0, 1]) + * + t^3 * P_3 (with t included in [0, 1]) * * and, similarly, since the final point is (1, 1) we can simplify * it further to: * * B(t) = 3t * (1 - t)^2 * P_1 * + 3t^2 * (1 - t) * P_2 - * + 3t^3 (with t included in [0, 1]) + * + t^3 (with t included in [0, 1]) * * since an alpha function has only a time parameter and we have two * coordinates for each point, we pass the time as the first @@ -1314,11 +1314,11 @@ clutter_cubic_bezier (ClutterAlpha *alpha, b_t = 3 * t * pow (1 - t, 2) * x_1 + 3 * pow (t, 2) * (1 - t) * x_2 - + 3 * pow (t, 3); + + pow (t, 3); res = 3 * b_t * pow (1 - b_t, 2) * y_1 + 3 * pow (b_t, 2) * (1 - b_t) * y_2 - + 3 * pow (b_t, 3); + + pow (b_t, 3); return res; }