Commit 226c24bf authored by Christian Hergert's avatar Christian Hergert

animation: handle 0 length animations gracefully

If end_time == begin_time, then we'd continually return 0.0 as our offset
which means we never advance and spin the animation loop.

Fixes #14 and #20
parent dec004fb
......@@ -325,10 +325,11 @@ dzl_animation_get_offset (DzlAnimation *animation,
frame_time = CLAMP (frame_time, animation->begin_time, animation->end_time);
if (frame_time == animation->begin_time)
return 0.0;
else if (frame_time == animation->end_time)
/* Check end_time first in case end_time == begin_time */
if (frame_time == animation->end_time)
return 1.0;
else if (frame_time == animation->begin_time)
return 0.0;
return (frame_time - animation->begin_time) / (gdouble)(animation->duration_msec * 1000L);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment