Spring visualisation (Re: [PATCH weston 4/4 v1] Implement animated zoom transitions.)

Pekka Paalanen ppaalanen at gmail.com
Mon May 21 00:06:22 PDT 2012


On Mon, 21 May 2012 00:33:21 -0600
Scott Moreau <oreaus at gmail.com> wrote:

> This patch introduces animated transitions for zoom. It uses springs to drive
> the animations but there were some problems, so there are a couple of things
> that have to be done to make this happen. First, the spring timestamp is set
> with weston_compositor_get_time() but when the first frame handler is called,
> the msec value is less than the timestamp and this causes an infinite loop
> when calling weston_spring_update(). To solve the problem and make this
> function more robust, a cast was added to ensure a negative value doesn't
> wreak havoc when the resulting value is promoted to unsigned. Second, when
> transitioning from text cursor position to pointer position, the spring would
> not end quickly enough when the pointer was on the move. This caused the
> spring animation to continue until the pointer stopped moving for some time,
> all the while causing undesired behavior. The best solution I found was to
> set the spring's 'done threshold' higher to end the spring early, in addition
> to tweaking the sping current and k values. This patch quietly adds a float
> to the spring struct and initializes it to the original value while allowing
> adjustment of the 'done threshold' as needed. The result is that the spring
> ends quickly and the user doesn't experience buggy behavior in this case.

Hi,

when I was briefly fighting with springs last year, I used the attached
files to visualise the spring behaviour. It runs the spring with
hardcoded values, dumps data into a text file, and renders it with
gnuplot. Usage:

$ sh spring.c

But before using, one should make sure the spring code copied there
is up-to-date with weston.

By tweaking plot.gp to draw a reference curve and current curve, and
copying data.txt to another name, you can compare how changing
parameters affects the behaviour.

Btw. could you do with a single spring instead of x and y springs? I
assume you want to interpolate a straight path? Separate x,y springs
will probably make some curves, don't know if that's intentional.


HTH,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot.gp
Type: application/x-gnuplot
Size: 244 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20120521/9b30a7ef/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spring.c
Type: text/x-csrc
Size: 3659 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20120521/9b30a7ef/attachment.c>


More information about the wayland-devel mailing list