bugfix [#24455] Scene is left at last rendered frame from rendering an animation
authorCampbell Barton <ideasman42@gmail.com>
Tue, 2 Nov 2010 09:34:32 +0000 (09:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 2 Nov 2010 09:34:32 +0000 (09:34 +0000)
source/blender/editors/include/ED_image.h
source/blender/editors/include/ED_screen.h
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_image/image_ops.c
source/blender/windowmanager/intern/wm_event_system.c

index c5f0983f4949b244ba112401cd02d241da63e10c..7f507eab2767a0d6d2172807e6df1bd471eee0ba 100644 (file)
@@ -29,6 +29,7 @@
 #define ED_IMAGE_H
 
 struct SpaceImage;
+struct Main;
 struct bContext;
 struct Image;
 struct ImageUser;
@@ -61,7 +62,7 @@ int ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
 int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
 
 /* UI level image (texture) updating... render calls own stuff (too) */
-void ED_image_update_frame(const struct bContext *C);
+void ED_image_update_frame(const struct Main *mainp, int cfra);
 
 /* image_render.c, export for screen_ops.c, render operator */
 void ED_space_image_output(struct bContext *C);
index 8b8bb75b8e6aa1d6759cca64b0db86e33af97f92..6904daa98681e858987d9d5efeaa8c0b7f8203bb 100644 (file)
@@ -109,7 +109,8 @@ struct ScrArea *ED_screen_full_toggle(struct bContext *C, struct wmWindow *win,
 void   ED_screen_new_window(struct bContext *C, struct rcti *position, int type);
 
 /* anim */
-void   ED_update_for_newframe(const struct bContext *C, int mute);
+void   ED_update_for_newframe(struct Main *bmain, struct Scene *scene, struct bScreen *screen, int mute);
+
 void   ED_refresh_viewport_fps(struct bContext *C);
 int ED_screen_animation_play(struct bContext *C, int sync, int mode);
 
index b1c373e7a91853697f2c16d0bd0273ed8b0447b3..adf5d00355ec0d64296dee3cb3cb223d4ee1cb71 100644 (file)
@@ -420,7 +420,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(C, 1);
+               ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1);
                
                /* now scene data should be current according to animation system, so we fill the channels */
                
@@ -910,7 +910,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
 
        /* reset to original current frame */
        scene->r.cfra = origFrame;
-       ED_update_for_newframe(C, 1);
+       ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1);
        
        
        /* ---- XXX: No Time animation curve for now, leaving this code here for reference 
index 77fa51aa7b1e0f5853a58f3af7cfc40a7dd3b08d..b875de8f8bc94e850145aab7e6104be193743552 100644 (file)
@@ -427,7 +427,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
                RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra);
 
        // no redraw needed, we leave state as we entered it
-       ED_update_for_newframe(C, 1);
+       ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1);
 
        WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
 
@@ -578,6 +578,9 @@ static void render_endjob(void *rjv)
        if(rj->main != G.main)
                free_main(rj->main);
 
+       /* else the frame will not update for the original value */
+       ED_update_for_newframe(G.main, rj->scene, rj->win->screen, 1);
+       
        /* XXX render stability hack */
        G.rendering = 0;
        WM_main_add_notifier(NC_WINDOW, NULL);
index ef56a596855e64939e70ec3e6a9b33bbf479e34b..eb24919f99b805c88fbfb94157522d73b880df9e 100644 (file)
@@ -347,7 +347,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
 
        /* update animated image textures for gpu, etc,
         * call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */
-       ED_image_update_frame(C);
+       ED_image_update_frame(bmain, scene->r.cfra);
 
        /* go to next frame */
        while(CFRA<oglrender->nfra) {
index 196c8babf377267a0ace7c2d574469e666c59d1f..cd92c48f12a7b4704a1b19739f1b34816384681f 100644 (file)
@@ -1450,7 +1450,7 @@ void ED_screen_set_scene(bContext *C, Scene *scene)
        CTX_data_scene_set(C, scene);
        set_scene_bg(CTX_data_main(C), scene);
        
-       ED_update_for_newframe(C, 1);
+       ED_update_for_newframe(CTX_data_main(C), scene, curscreen, 1);
        
        /* complete redraw */
        WM_event_add_notifier(C, NC_WINDOW, NULL);
@@ -1756,20 +1756,17 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
        }
 }
 
-/* results in fully updated anim system */
-void ED_update_for_newframe(const bContext *C, int UNUSED(mute))
-{
-       Main *bmain= CTX_data_main(C);
-       bScreen *screen= CTX_wm_screen(C);
-       Scene *scene= CTX_data_scene(C);
-       
+/* results in fully updated anim system
+ * screen can be NULL */
+void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUSED(mute))
+{      
 #ifdef DURIAN_CAMERA_SWITCH
        void *camera= scene_camera_switch_find(scene);
        if(camera && scene->camera != camera) {
                bScreen *sc;
                scene->camera= camera;
                /* are there cameras in the views that are not in the scene? */
-               for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
+               for(sc= bmain->screen.first; sc; sc= sc->id.next) {
                        BKE_screen_view3d_scene_sync(sc);
                }
        }
@@ -1779,7 +1776,7 @@ void ED_update_for_newframe(const bContext *C, int UNUSED(mute))
        
        /* update animated image textures for gpu, etc,
         * call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */
-       ED_image_update_frame(C);
+       ED_image_update_frame(bmain, scene->r.cfra);
 
        /* this function applies the changes too */
        /* XXX future: do all windows */
@@ -1801,7 +1798,7 @@ void ED_update_for_newframe(const bContext *C, int UNUSED(mute))
        /* update animated texture nodes */
        {
                Tex *tex;
-               for(tex= CTX_data_main(C)->tex.first; tex; tex= tex->id.next)
+               for(tex= bmain->tex.first; tex; tex= tex->id.next)
                        if( tex->use_nodes && tex->nodetree ) {
                                ntreeTexTagAnimated( tex->nodetree );
                        }
index 5a6acd24c5f7233956f75d6df86ec09abec1307c..845ef2bae4d4ac8185a3fc354e7c22fd695f9714 100644 (file)
@@ -2547,7 +2547,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
                        sound_seek_scene(C);
                
                /* since we follow drawflags, we can't send notifier but tag regions ourselves */
-               ED_update_for_newframe(C, 1);
+               ED_update_for_newframe(CTX_data_main(C), scene, screen, 1);
                
                for (sa= screen->areabase.first; sa; sa= sa->next) {
                        ARegion *ar;
index 429ba64ed0fe05222395c05997766ed7fe777eaf..19af0b3f79e04b1907de05381364d5776573dfc6 100644 (file)
@@ -2098,11 +2098,9 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
 
 /* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
 
-void ED_image_update_frame(const bContext *C)
+void ED_image_update_frame(const Main *mainp, int cfra)
 {
-       Main *mainp= CTX_data_main(C);
-       Scene *scene= CTX_data_scene(C);
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm;
        wmWindow *win;
        Tex *tex;
        
@@ -2111,13 +2109,13 @@ void ED_image_update_frame(const bContext *C)
                if(tex->type==TEX_IMAGE && tex->ima) {
                        if(ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
                                if(tex->iuser.flag & IMA_ANIM_ALWAYS)
-                                       BKE_image_user_calc_frame(&tex->iuser, scene->r.cfra, 0);
+                                       BKE_image_user_calc_frame(&tex->iuser, cfra, 0);
                        }
                }
        }
        
        /* image window, compo node users */
-       if(wm) {
+       for(wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */
                for(win= wm->windows.first; win; win= win->next) {
                        ScrArea *sa;
                        for(sa= win->screen->areabase.first; sa; sa= sa->next) {
@@ -2126,12 +2124,12 @@ void ED_image_update_frame(const bContext *C)
                                        BGpic *bgpic;
                                        for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next)
                                                if(bgpic->iuser.flag & IMA_ANIM_ALWAYS)
-                                                       BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0);
+                                                       BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0);
                                }
                                else if(sa->spacetype==SPACE_IMAGE) {
                                        SpaceImage *sima= sa->spacedata.first;
                                        if(sima->iuser.flag & IMA_ANIM_ALWAYS)
-                                               BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0);
+                                               BKE_image_user_calc_frame(&sima->iuser, cfra, 0);
                                }
                                else if(sa->spacetype==SPACE_NODE) {
                                        SpaceNode *snode= sa->spacedata.first;
@@ -2143,7 +2141,7 @@ void ED_image_update_frame(const bContext *C)
                                                                ImageUser *iuser= node->storage;
                                                                if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
                                                                        if(iuser->flag & IMA_ANIM_ALWAYS)
-                                                                               BKE_image_user_calc_frame(iuser, scene->r.cfra, 0);
+                                                                               BKE_image_user_calc_frame(iuser, cfra, 0);
                                                        }
                                                }
                                        }
index 4eba45c61b9fccbd16e429e0e9845ae6cb139ca3..ed1caa5fafe10c163324294a023fc168b8be37b4 100644 (file)
@@ -241,7 +241,7 @@ void wm_event_do_notifiers(bContext *C)
                        if(!G.rendering) {
 
                                /* depsgraph gets called, might send more notifiers */
-                               ED_update_for_newframe(C, 1);
+                               ED_update_for_newframe(CTX_data_main(C), win->screen->scene, win->screen, 1);
                        }
                }
        }
@@ -1636,7 +1636,7 @@ void wm_event_do_handlers(bContext *C)
                                                int ncfra = sound_sync_scene(scene) * FPS + 0.5;
                                                if(ncfra != scene->r.cfra)      {
                                                        scene->r.cfra = ncfra;
-                                                       ED_update_for_newframe(C, 1);
+                                                       ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
                                                        WM_event_add_notifier(C, NC_WINDOW, NULL);
                                                }
                                        }