Animation playback: now all windows are update during playback, rather than

just the active window.
This commit is contained in:
Brecht Van Lommel
2012-05-25 12:37:11 +00:00
parent 942fcf4415
commit ad65b7b86b
11 changed files with 72 additions and 44 deletions

View File

@@ -113,10 +113,11 @@ void ED_screen_full_restore(struct bContext *C, ScrArea *sa);
struct ScrArea *ED_screen_full_toggle(struct bContext *C, struct wmWindow *win, struct ScrArea *sa);
/* anim */
void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, struct bScreen *screen, int mute);
void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, int mute);
void ED_refresh_viewport_fps(struct bContext *C);
int ED_screen_animation_play(struct bContext *C, int sync, int mode);
int ED_screen_animation_play(struct bContext *C, int sync, int mode);
bScreen *ED_screen_animation_playing(const struct bContext *C);
/* screen keymaps */
void ED_operatortypes_screen(void);

View File

@@ -2023,7 +2023,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
* this part of the process before a threaded job is created */
//scene->r.cfra = f;
//ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1);
//ED_update_for_newframe(CTX_data_main(C), scene, 1);
/* ok, this doesn't work with drivers, but is way faster.
* let's use this for now and hope nobody wants to drive the time value... */

View File

@@ -285,7 +285,7 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf
/* Set frame to start point (also inits modifier data) */
frame = surface->start_frame;
scene->r.cfra = (int)frame;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
ED_update_for_newframe(CTX_data_main(C), scene, 1);
/* Init surface */
if (!dynamicPaint_createUVSurface(surface)) return 0;
@@ -303,7 +303,7 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf
/* calculate a frame */
scene->r.cfra = (int)frame;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
ED_update_for_newframe(CTX_data_main(C), scene, 1);
if (!dynamicPaint_calculateFrame(surface, scene, cObject, frame)) return 0;
/*

View File

@@ -419,7 +419,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* Modifying the global scene isn't nice, but we can do it in
* this part of the process before a threaded job is created */
scene->r.cfra = (int)eval_time;
ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1);
ED_update_for_newframe(CTX_data_main(C), scene, 1);
/* now scene data should be current according to animation system, so we fill the channels */
@@ -967,7 +967,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
/* reset to original current frame */
scene->r.cfra = origFrame;
ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1);
ED_update_for_newframe(CTX_data_main(C), scene, 1);
/* ******** init domain object's matrix ******** */
copy_m4_m4(domainMat, fsDomain->obmat);

View File

@@ -236,7 +236,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
RE_SetReports(re, NULL);
// no redraw needed, we leave state as we entered it
ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1);
ED_update_for_newframe(mainp, scene, 1);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
@@ -408,7 +408,7 @@ static void render_endjob(void *rjv)
/* else the frame will not update for the original value */
if (!(rj->scene->r.scemode & R_NO_FRAME_UPDATE))
ED_update_for_newframe(G.main, rj->scene, rj->win->screen, 1);
ED_update_for_newframe(G.main, rj->scene, 1);
/* XXX above function sets all tags in nodes */
ntreeCompositClearTags(rj->scene->nodetree);
@@ -470,7 +470,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
Main *mainp;
Scene *scene = CTX_data_scene(C);
SceneRenderLayer *srl = NULL;
bScreen *screen = CTX_wm_screen(C);
View3D *v3d = CTX_wm_view3d(C);
Render *re;
wmJob *steve;
@@ -507,7 +506,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
mainp = CTX_data_main(C);
/* cancel animation playback */
if (screen->animtimer)
if (ED_screen_animation_playing(C))
ED_screen_animation_play(C, 0, 0);
/* handle UI stuff */

View File

@@ -1506,7 +1506,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene)
BKE_scene_set_background(bmain, scene);
ED_render_engine_changed(bmain);
ED_update_for_newframe(bmain, scene, screen, 1);
ED_update_for_newframe(bmain, scene, 1);
/* complete redraw */
WM_event_add_notifier(C, NC_WINDOW, NULL);
@@ -1750,10 +1750,12 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
bScreen *stopscreen = ED_screen_animation_playing(C);
if (screen->animtimer)
WM_event_remove_timer(wm, win, screen->animtimer);
screen->animtimer = NULL;
if (stopscreen) {
WM_event_remove_timer(wm, win, stopscreen->animtimer);
stopscreen->animtimer = NULL;
}
if (enable) {
ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData");
@@ -1777,8 +1779,9 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
screen->animtimer->customdata = sad;
}
/* notifier catched by top header, for button */
WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, screen);
WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, NULL);
}
/* helper for screen_animation_play() - only to be used for TimeLine */
@@ -1821,8 +1824,12 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
/* results in fully updated anim system
* screen can be NULL */
void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUSED(mute))
{
void ED_update_for_newframe(Main *bmain, Scene *scene, int UNUSED(mute))
{
wmWindowManager *wm = bmain->wm.first;
wmWindow *window;
int layers = 0;
#ifdef DURIAN_CAMERA_SWITCH
void *camera = BKE_scene_camera_switch_find(scene);
if (camera && scene->camera != camera) {
@@ -1843,9 +1850,12 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS
ED_clip_update_frame(bmain, scene->r.cfra);
/* get layers from all windows */
for (window = wm->windows.first; window; window = window->next)
layers |= BKE_screen_visible_layers(window->screen, scene);
/* this function applies the changes too */
/* XXX future: do all windows */
BKE_scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */
BKE_scene_update_for_newframe(bmain, scene, layers); /* BKE_scene.h */
//if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB))
// audiostream_scrub( CFRA );

View File

@@ -2905,6 +2905,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
Scene *scene = CTX_data_scene(C);
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *window;
ScrArea *sa;
int sync;
float time;
@@ -2985,22 +2987,24 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
sound_seek_scene(bmain, scene);
/* since we follow drawflags, we can't send notifier but tag regions ourselves */
ED_update_for_newframe(CTX_data_main(C), scene, screen, 1);
for (sa = screen->areabase.first; sa; sa = sa->next) {
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == sad->ar)
ED_region_tag_redraw(ar);
else
if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws))
ED_region_tag_redraw(ar);
ED_update_for_newframe(CTX_data_main(C), scene, 1);
for (window = wm->windows.first; window; window = window->next) {
for (sa = window->screen->areabase.first; sa; sa = sa->next) {
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == sad->ar)
ED_region_tag_redraw(ar);
else
if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws))
ED_region_tag_redraw(ar);
}
if (match_area_with_refresh(sa->spacetype, sad->refresh))
ED_area_tag_refresh(sa);
}
if (match_area_with_refresh(sa->spacetype, sad->refresh))
ED_area_tag_refresh(sa);
}
/* update frame rate info too
* NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
* have been calculated instead of just before updates have been done?
@@ -3034,13 +3038,26 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
/* ****************** anim player, starts or ends timer ***************** */
/* find window that owns the animation timer */
bScreen *ED_screen_animation_playing(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *window;
for (window = wm->windows.first; window; window = window->next)
if (window->screen->animtimer)
return window->screen;
return NULL;
}
/* toggle operator */
int ED_screen_animation_play(bContext *C, int sync, int mode)
{
bScreen *screen = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
if (screen->animtimer) {
if (ED_screen_animation_playing(C)) {
/* stop playback now */
ED_screen_animation_timer(C, 0, 0, 0, 0);
sound_stop_scene(scene);
@@ -3097,9 +3114,9 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot)
static int screen_animation_cancel_exec(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
bScreen *screen = ED_screen_animation_playing(C);
if (screen->animtimer) {
if (screen) {
if (RNA_boolean_get(op->ptr, "restore_frame")) {
ScreenAnimData *sad = screen->animtimer->customdata;
Scene *scene = CTX_data_scene(C);

View File

@@ -1528,7 +1528,7 @@ static void track_markers_freejob(void *tmv)
tmj->clip->tracking_context = NULL;
tmj->scene->r.cfra = tmj->lastfra;
ED_update_for_newframe(tmj->main, tmj->scene, tmj->screen, 0);
ED_update_for_newframe(tmj->main, tmj->scene, 0);
BKE_tracking_sync(tmj->context);
BKE_tracking_context_free(tmj->context);

View File

@@ -2997,7 +2997,6 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
bScreen *screen = CTX_wm_screen(C);
Object *ob;
@@ -3026,7 +3025,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
return;
}
if ((U.uiflag & USER_SHOW_FPS) && screen->animtimer) {
if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(C)) {
draw_viewport_fps(scene, ar);
}
else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {

View File

@@ -93,6 +93,7 @@
#include "ED_view3d.h"
#include "ED_curve.h" /* for curve_editnurbs */
#include "ED_clip.h"
#include "ED_screen.h"
//#include "BDR_unwrapper.h"
@@ -1038,9 +1039,10 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
bScreen *animscreen = ED_screen_animation_playing(C);
t->view = v3d;
t->animtimer= CTX_wm_screen(C)->animtimer;
t->animtimer= (animscreen)? animscreen->animtimer: NULL;
/* turn manipulator off during transform */
// FIXME: but don't do this when USING the manipulator...

View File

@@ -245,7 +245,7 @@ void wm_event_do_notifiers(bContext *C)
if (!G.rendering) {
/* depsgraph gets called, might send more notifiers */
ED_update_for_newframe(CTX_data_main(C), win->screen->scene, win->screen, 1);
ED_update_for_newframe(CTX_data_main(C), win->screen->scene, 1);
}
}
}
@@ -1961,7 +1961,7 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_screen_set(C, win->screen);
CTX_data_scene_set(C, scene);
if (((playing == 1) && (!win->screen->animtimer)) || ((playing == 0) && (win->screen->animtimer))) {
if (((playing == 1) && (!ED_screen_animation_playing(C))) || ((playing == 0) && (ED_screen_animation_playing(C)))) {
ED_screen_animation_play(C, -1, 1);
}
@@ -1971,7 +1971,7 @@ void wm_event_do_handlers(bContext *C)
int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f;
if (ncfra != scene->r.cfra) {
scene->r.cfra = ncfra;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
ED_update_for_newframe(CTX_data_main(C), scene, 1);
WM_event_add_notifier(C, NC_WINDOW, NULL);
}
}