From 4a9be13d2aed3fc90230cff34fff57fa70cf574c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 2 May 2011 13:38:03 -0400 Subject: [PATCH] Tweak tweener constants and add friction parameter --- compositor/compositor.c | 13 ++++++++++--- compositor/compositor.h | 1 + compositor/meego-tablet-shell.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compositor/compositor.c b/compositor/compositor.c index 6288337..5df67d1 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -116,6 +116,7 @@ wlsc_tweener_init(struct wlsc_tweener *tweener, double k, double current, double target) { tweener->k = k; + tweener->friction = 100.0; tweener->current = current; tweener->previous = current; tweener->target = target; @@ -124,22 +125,28 @@ wlsc_tweener_init(struct wlsc_tweener *tweener, WL_EXPORT void wlsc_tweener_update(struct wlsc_tweener *tweener, uint32_t msec) { - double force, current, step; + double force, v, current, step; - step = (msec - tweener->timestamp) / 100.0; + step = (msec - tweener->timestamp) / 500.0; tweener->timestamp = msec; current = tweener->current; + v = current - tweener->previous; force = tweener->k * (tweener->target - current) / 10.0 + - (tweener->previous - current); + (tweener->previous - current) - v * tweener->friction; tweener->current = current + (current - tweener->previous) + force * step * step; tweener->previous = current; if (tweener->current >= 1.0) { +#ifdef TWEENER_BOUNCE + tweener->current = 2.0 - tweener->current; + tweener->previous = 2.0 - tweener->previous; +#else tweener->current = 1.0; tweener->previous = 1.0; +#endif } if (tweener->current <= 0.0) { diff --git a/compositor/compositor.h b/compositor/compositor.h index 2db98a1..48e2ebe 100644 --- a/compositor/compositor.h +++ b/compositor/compositor.h @@ -106,6 +106,7 @@ struct wlsc_animation { struct wlsc_tweener { double k; + double friction; double current; double target; double previous; diff --git a/compositor/meego-tablet-shell.c b/compositor/meego-tablet-shell.c index 44480b2..6dbb0b9 100644 --- a/compositor/meego-tablet-shell.c +++ b/compositor/meego-tablet-shell.c @@ -525,6 +525,6 @@ shell_init(struct wlsc_compositor *compositor) launch_switcher(shell); - wlsc_tweener_init(&compositor->fade.tweener, 0.8, 1.0, 1.0); + wlsc_tweener_init(&compositor->fade.tweener, 40.0, 1.0, 1.0); shell->starting = 1; } -- 2.7.4