Anim playback now uses "Sync" option, skipping frames to match
real time (as set by the frames/sec button).

This is a quicky for tests with audio. Note that the real time
in seconds to update sound to in ED_update_for_newframe() would be:

(scene->r.cfra / FPS) + screen->animtimer->duration

Also this can have a slight inaccuracy, the time between the timer
handler and the ED_update_for_newframe() notifier is not known,
but in general nearly zero. A better implementation is possible, but
thats for later. :)
This commit is contained in:
Ton Roosendaal
2009-02-15 13:09:19 +00:00
parent 50f789e9e8
commit 66d3dcf150
2 changed files with 12 additions and 2 deletions

View File

@@ -24,6 +24,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <math.h>
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
@@ -1774,7 +1776,14 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
if(screen->animtimer==event->customdata) {
Scene *scene= CTX_data_scene(C);
scene->r.cfra++;
if(scene->audio.flag & AUDIO_SYNC) {
wmTimer *wt= screen->animtimer;
int step = floor(wt->duration * FPS);
scene->r.cfra += step;
wt->duration -= ((float)step)/FPS;
}
else
scene->r.cfra++;
if (scene->r.psfra) {
if(scene->r.cfra > scene->r.pefra)

View File

@@ -528,7 +528,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
/* This timer system only gives maximum 1 timer event per redraw cycle,
to prevent queues to get overloaded.
Timer handlers should check for delta to decide if they just
update, or follow real time
update, or follow real time.
Timer handlers can also set duration to match frames passed */
*/
static int wm_window_timer(const bContext *C)
{