diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-16 17:40:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-16 17:40:46 +0300 |
commit | 1e245cc58928ad40c9e665f3aede685a9485ea21 (patch) | |
tree | f64cfe137212f0bb93aeb6a545c14c49e6c9b338 /source/blender/editors/render | |
parent | 2153c663be809eca6b30fa042c88751692175dc7 (diff) |
option to write images to a files on single frame renders, this isn't accessed by the UI at the moment, but could eventually be used for saving test-renders.
The main reason to have this is so renders can be scripted to write to a specific file without having to do annoying tricks like set a dummy start/end frame range, render an animation and work out the current frame image will be written to, then rename after rendering.
Also made some 'char *' args into 'const char *'
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r-- | source/blender/editors/render/render_internal.c | 30 | ||||
-rw-r--r-- | source/blender/editors/render/render_opengl.c | 2 |
2 files changed, 24 insertions, 8 deletions
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 2bb76a8d173..1c8c111437d 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -402,6 +402,13 @@ static int screen_render_exec(bContext *C, wmOperator *op) View3D *v3d= CTX_wm_view3d(C); Main *mainp= CTX_data_main(C); unsigned int lay= (v3d)? v3d->lay: scene->lay; + const short is_animation= RNA_boolean_get(op->ptr, "animation"); + const short is_write_still= RNA_boolean_get(op->ptr, "write_still"); + + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected."); + return OPERATOR_CANCELLED; + } if(re==NULL) { re= RE_NewRender(scene->id.name); @@ -421,10 +428,10 @@ static int screen_render_exec(bContext *C, wmOperator *op) since sequence rendering can call that recursively... (peter) */ seq_stripelem_cache_cleanup(); - if(RNA_boolean_get(op->ptr, "animation")) + if(is_animation) RE_BlenderAnim(re, mainp, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); else - RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra); + RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra, is_write_still); // no redraw needed, we leave state as we entered it ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1); @@ -441,7 +448,7 @@ typedef struct RenderJob { wmWindow *win; SceneRenderLayer *srl; int lay; - int anim; + short anim, write_still; Image *image; ImageUser iuser; short *stop; @@ -568,7 +575,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro if(rj->anim) RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); else - RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra); + RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra, rj->write_still); } static void render_endjob(void *rjv) @@ -632,7 +639,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) wmJob *steve; RenderJob *rj; Image *ima; - + const short is_animation= RNA_boolean_get(op->ptr, "animation"); + const short is_write_still= RNA_boolean_get(op->ptr, "write_still"); + /* only one render job at a time */ if(WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; @@ -641,6 +650,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected."); + return OPERATOR_CANCELLED; + } + /* stop all running jobs, currently previews frustrate Render */ WM_jobs_stop_all(CTX_wm_manager(C)); @@ -703,7 +717,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) rj->win= CTX_wm_window(C); rj->srl = srl; rj->lay = (v3d)? v3d->lay: scene->lay; - rj->anim= RNA_boolean_get(op->ptr, "animation"); + rj->anim= is_animation; + rj->write_still= is_write_still; rj->iuser.scene= scene; rj->iuser.ok= 1; rj->reports= op->reports; @@ -764,7 +779,8 @@ void RENDER_OT_render(wmOperatorType *ot) ot->poll= ED_operator_screenactive; - RNA_def_boolean(ot->srna, "animation", 0, "Animation", ""); + RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene"); + RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)"); RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render"); RNA_def_string(ot->srna, "scene", "", 19, "Scene", "Re-render single layer in this scene"); } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 3dfd7e52c30..71354ad6d07 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -389,7 +389,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION); + BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); if(ok==0) { |