mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
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.
This commit is contained in:
parent
2bf815131a
commit
4168ed09de
@ -1282,7 +1282,7 @@ clutter_cubic_bezier (ClutterAlpha *alpha,
|
|||||||
* B(t) = (1 - t)^3 * P_0
|
* B(t) = (1 - t)^3 * P_0
|
||||||
* + 3t * (1 - t)^2 * P_1
|
* + 3t * (1 - t)^2 * P_1
|
||||||
* + 3t^2 * (1 - t) * P_2
|
* + 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,
|
* 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
|
* 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
|
* B(t) = 3t * (1 - t)^2 * P_1
|
||||||
* + 3t^2 * (1 - t) * P_2
|
* + 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
|
* and, similarly, since the final point is (1, 1) we can simplify
|
||||||
* it further to:
|
* it further to:
|
||||||
*
|
*
|
||||||
* B(t) = 3t * (1 - t)^2 * P_1
|
* B(t) = 3t * (1 - t)^2 * P_1
|
||||||
* + 3t^2 * (1 - t) * P_2
|
* + 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
|
* since an alpha function has only a time parameter and we have two
|
||||||
* coordinates for each point, we pass the time as the first
|
* 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
|
b_t = 3 * t * pow (1 - t, 2) * x_1
|
||||||
+ 3 * pow (t, 2) * (1 - t) * x_2
|
+ 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
|
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, 2) * (1 - b_t) * y_2
|
||||||
+ 3 * pow (b_t, 3);
|
+ pow (b_t, 3);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user