== Render ==
authorDiego Borghetti <bdiego@gmail.com>
Fri, 19 Sep 2008 21:57:15 +0000 (21:57 +0000)
committerDiego Borghetti <bdiego@gmail.com>
Fri, 19 Sep 2008 21:57:15 +0000 (21:57 +0000)
Commit patch #7788, allow to set the render step, so it's
possible make render every N frames only.

The step is change in Scene buttons (F10), below start and
end frame buttons.

Also add a command line options (-j), so it's possible to
overwrite the file step (useful for renderfarm).

[ Brecht, this work with OpenGL renders and simulated
  the skipped frames, please double check ]

source/blender/blenkernel/BKE_blender.h
source/blender/blenloader/intern/readfile.c
source/blender/include/blendef.h
source/blender/makesdna/DNA_scene_types.h
source/blender/python/api2_2x/sceneRender.c
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/pipeline.c
source/blender/src/buttons_scene.c
source/blender/src/renderwin.c
source/creator/creator.c

index 5af8fde99c9c2defe640726017a9af132b184bb9..8dbb90372f0478e7d3b7cae4727ad6aadaadf247 100644 (file)
@@ -41,7 +41,7 @@ struct ListBase;
 struct MemFile;
 
 #define BLENDER_VERSION                        247
-#define BLENDER_SUBVERSION             3
+#define BLENDER_SUBVERSION             4
 
 #define BLENDER_MINVERSION             245
 #define BLENDER_MINSUBVERSION  15
index 0df965b2cc1151f0219df4a7815e12cc8852ebfa..80defdbbf9c6de11b5c927f276425772012e1a01 100644 (file)
@@ -7808,6 +7808,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
                }
        }
+
+       if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 4)){
+               Scene *sce= main->scene.first;
+               while(sce) {
+                       if(sce->frame_step==0)
+                               sce->frame_step= 1;
+                       sce= sce->id.next;
+               }
+       }
+
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 
index a7f7bc2e4b86e48fcd93cae0635fae87ceaa4a8f..7fd607f6feb9bb898dc880d9a117b1c0de924e96 100644 (file)
 #define        F_CFRA                  ((float)(G.scene->r.cfra))
 #define        SFRA                    (G.scene->r.sfra)
 #define        EFRA                    (G.scene->r.efra)
+#define STFRA                  (G.scene->frame_step)
 #define PSFRA                  ((G.scene->r.psfra != 0)? (G.scene->r.psfra): (G.scene->r.sfra))
 #define PEFRA                  ((G.scene->r.psfra != 0)? (G.scene->r.pefra): (G.scene->r.efra))
 #define FRA2TIME(a)           ((((double) G.scene->r.frs_sec_base) * (a)) / G.scene->r.frs_sec)
index 32522d1e866adc69a77945236c3eabf1c7add6a6..3888cb48520f798853d2a8bc830add990dd6efe0 100644 (file)
@@ -553,6 +553,10 @@ typedef struct Scene {
 
        /* Sculptmode data */
        struct SculptData sculptdata;
+
+       /* frame step. */
+       int frame_step;
+       int pad;
 } Scene;
 
 
index 7958e66b44fbf434778c23a7c9ddc485737160f9..7f88acd3a87e50c969fed4a37fdabf8808fc1dd6 100644 (file)
@@ -496,7 +496,7 @@ PyObject *RenderData_Render( BPy_RenderData * self )
 
                tstate = PyEval_SaveThread();
 
-               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
+               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
 
                BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
 
@@ -599,7 +599,7 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
                        BPY_do_all_scripts(SCRIPT_RENDER, 1);
 
                tstate = PyEval_SaveThread();
-               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
+               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
 
                if (G.f & G_DOSCRIPTLINKS)
                        BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
index 64cf7fcb37b0f8e5f8c1482c5de928525ff2c6d6..60557403143e3354e3a2cd981f80ca4a83668762 100644 (file)
@@ -185,7 +185,7 @@ void RE_TileProcessor(struct Render *re, int firsttile, int threaded);
 
 /* only RE_NewRender() needed, main Blender render calls */
 void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame);
-void RE_BlenderAnim(struct Render *re, struct Scene *scene, int sfra, int efra);
+void RE_BlenderAnim(struct Render *re, struct Scene *scene, int sfra, int efra, int tfra);
 
 void RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode);
 void RE_WriteRenderResult(RenderResult *rr, char *filename, int compress);
index bf2a72b4f9b764b94dd91c802319479462ee3437..9d272d045065dc83aea52d15c97cfa9c54503389 100644 (file)
@@ -2559,10 +2559,12 @@ static void do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh)
 }
 
 /* saves images to disk */
-void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra)
+void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra)
 {
        bMovieHandle *mh= BKE_get_movie_handle(scene->r.imtype);
+       unsigned int lay;
        int cfrao= scene->r.cfra;
+       int nfra;
        
        /* do not fully call for each frame, it initializes & pops output window */
        if(!render_initialize_from_scene(re, scene, 0))
@@ -2591,12 +2593,27 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra)
                        }
                }
        } else {
-               for(scene->r.cfra= sfra; scene->r.cfra<=efra; scene->r.cfra++) {
+               for(nfra= sfra, scene->r.cfra= sfra; scene->r.cfra<=efra; scene->r.cfra++) {
                        char name[FILE_MAX];
                        
                        /* only border now, todo: camera lens. (ton) */
                        render_initialize_from_scene(re, scene, 1);
-                       
+
+                       if(nfra!=scene->r.cfra) {
+                               /*
+                                * Skip this frame, but update for physics and particles system.
+                                * From convertblender.c:
+                                * in localview, lamps are using normal layers, objects only local bits.
+                                */
+                               if(scene->lay & 0xFF000000)
+                                       lay= scene->lay & 0xFF000000;
+                               else
+                                       lay= scene->lay;
+
+                               scene_update_for_newframe(scene, lay);
+                               continue;
+                       }
+
                        if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH) ) {
                                BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype);
                        }
@@ -2626,6 +2643,7 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra)
                                
                                break;
                        }
+                       nfra+= tfra;
                }
        }
        
index f2e20356f210ba7e2e8c1f683bf131b03c16d9b4..8ea71ce38dcb19338d65d5c9246d523e20d7fb1b 100644 (file)
@@ -2315,12 +2315,13 @@ static void render_panel_anim(void)
        uiBlockEndAlign(block);
 
        uiBlockSetCol(block, TH_AUTO);
-       uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,40,94,33, 0, 0, 0, 0, 0, "Play rendered images/avi animation (Ctrl+F11), (Play Hotkeys: A-Noskip, P-PingPong)");
-       uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,40,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
+       uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,50,94,33, 0, 0, 0, 0, 0, "Play rendered images/avi animation (Ctrl+F11), (Play Hotkeys: A-Noskip, P-PingPong)");
+       uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,50,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
 
        uiBlockBeginAlign(block);
-       uiDefButI(block, NUM,REDRAWSEQ,"Sta:",692,10,94,24, &G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "The start frame of the animation (inclusive)");
-       uiDefButI(block, NUM,REDRAWSEQ,"End:",789,10,95,24, &G.scene->r.efra,SFRA,MAXFRAMEF, 0, 0, "The end  frame of the animation  (inclusive)");
+       uiDefButI(block, NUM,REDRAWSEQ,"Sta:",692,20,94,24, &G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "The start frame of the animation (inclusive)");
+       uiDefButI(block, NUM,REDRAWSEQ,"End:",789,20,95,24, &G.scene->r.efra,SFRA,MAXFRAMEF, 0, 0, "The end  frame of the animation  (inclusive)");
+       uiDefButI(block, NUM,REDRAWSEQ,"Step:",692,0,192,18, &G.scene->frame_step, 1.0, MAXFRAMEF, 0, 0, "Frame Step");
        uiBlockEndAlign(block);
 }
 
index c26eedd26fd53217698486c7db19202cfe1da582..598b71930ed63bcf4f5df9c6a1144cf3912eeb96 100644 (file)
@@ -1132,7 +1132,7 @@ static void do_render(int anim)
        }
        
        if(anim)
-               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
+               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
        else
                RE_BlenderFrame(re, G.scene, G.scene->r.cfra);
 
@@ -1338,16 +1338,28 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
 
        if(anim) {
                bMovieHandle *mh= BKE_get_movie_handle(G.scene->r.imtype);
+               unsigned int lay;
                int cfrao= CFRA;
+               int nfra;
                
                if(BKE_imtype_is_movie(G.scene->r.imtype))
                        mh->start_movie(&G.scene->r, winx, winy);
                
-               for(CFRA= SFRA; CFRA<=EFRA; CFRA++) {
+               for(nfra= SFRA, CFRA= SFRA; CFRA<=EFRA; CFRA++) {
                        /* user event can close window */
                        if(render_win==NULL)
                                break;
 
+                       if(nfra!=CFRA) {
+                               if(G.scene->lay & 0xFF000000)
+                                       lay= G.scene->lay & 0xFF000000;
+                               else
+                                       lay= G.scene->lay;
+
+                               scene_update_for_newframe(G.scene, lay);
+                               continue;
+                       }
+
                        do_ogl_view3d_render(re, v3d, winx, winy);
                        glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
                        if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
@@ -1382,6 +1394,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
                        printf("\n");
                        
                        if(test_break()) break;
+                       nfra+= STFRA;
                }
                
                if(BKE_imtype_is_movie(G.scene->r.imtype))
index ac81557110f7ef4a45d298c49bda313b04e3aa0d..dffa755b2648bf5e4e78cc4862b272c8b948f6db 100644 (file)
@@ -202,6 +202,7 @@ static void print_help(void)
        printf ("    -p <sx> <sy>\tOpen with lower left corner at <sx>, <sy>\n");
        printf ("    -m\t\tRead from disk (Don't buffer)\n");
        printf ("    -f <fps> <fps-base>\t\tSpecify FPS to start with\n");
+       printf ("    -j <frame>\tSet frame step to <frame>\n");
                                
        printf ("\nWindow options:\n");
        printf ("  -w\t\tForce opening with borders (default)\n");
@@ -623,7 +624,7 @@ int main(int argc, char **argv)
                                                if (G.f & G_DOSCRIPTLINKS)
                                                        BPY_do_all_scripts(SCRIPT_RENDER, 0);
 
-                                               RE_BlenderAnim(re, G.scene, frame, frame);
+                                               RE_BlenderAnim(re, G.scene, frame, frame, G.scene->frame_step);
 
                                                BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
                                        }
@@ -638,7 +639,7 @@ int main(int argc, char **argv)
                                        if (G.f & G_DOSCRIPTLINKS)
                                                BPY_do_all_scripts(SCRIPT_RENDER, 1);
 
-                                       RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
+                                       RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
 
                                        if (G.f & G_DOSCRIPTLINKS)
                                                BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
@@ -669,6 +670,15 @@ int main(int argc, char **argv)
                                        printf("\nError: no blend loaded. cannot use '-e'.\n");
                                }
                                break;
+                       case 'j':
+                               a++;
+                               if(G.scene) {
+                                       int fstep= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
+                                       if (a < argc) (G.scene->frame_step) = fstep;
+                               } else {
+                                       printf("\nError: no blend loaded. cannot use '-j'.\n");
+                               }
+                               break;
                        case 'P':
                                a++;
                                if (a < argc) {