Fix #32187: OpenGL preview does not take into account overwrite option
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Jul 2012 08:58:34 +0000 (08:58 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Jul 2012 08:58:34 +0000 (08:58 +0000)
source/blender/editors/render/render_opengl.c

index 538b4b3884acc892240381a28335e233eb63e377..12f1e09f5bef86ce49ab7f46b882ce80dccad5b8 100644 (file)
@@ -476,6 +476,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
        int ok = 0;
        const short view_context = (oglrender->v3d != NULL);
        Object *camera = NULL;
+       int is_movie;
 
        /* go to next frame */
        if (CFRA < oglrender->nfra)
@@ -490,6 +491,21 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                CFRA++;
        }
 
+       is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype);
+
+       if (!is_movie) {
+               BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
+
+               if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) {
+                       printf("skipping existing frame \"%s\"\n", name);
+
+                       /* go to next frame */
+                       oglrender->nfra += scene->r.frame_step;
+
+                       return 1;
+               }
+       }
+
        /* update animated image textures for gpu, etc,
         * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */
        ED_image_update_frame(bmain, CFRA);
@@ -538,7 +554,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                        ibuf = ibuf_cpy;
                }
 
-               if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
+               if (is_movie) {
                        ok = oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int *)ibuf->rect,
                                                         oglrender->sizex, oglrender->sizey, oglrender->reports);
                        if (ok) {
@@ -547,7 +563,6 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                        }
                }
                else {
-                       BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
                        ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format);
 
                        if (ok == 0) {