Related to #36710: add a "use_viewport" option to the render operator, to specify

if the layers and camera of the 3d viewport should be used. Python scripts don't
always want this behavior.
This commit is contained in:
Brecht Van Lommel 2013-09-13 13:34:12 +00:00
parent b938293576
commit ed2343270c
2 changed files with 8 additions and 4 deletions

@ -571,14 +571,15 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
Main *mainp; Main *mainp;
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
SceneRenderLayer *srl = NULL; SceneRenderLayer *srl = NULL;
View3D *v3d = CTX_wm_view3d(C);
Render *re; Render *re;
wmJob *wm_job; wmJob *wm_job;
RenderJob *rj; RenderJob *rj;
Image *ima; Image *ima;
int jobflag; int jobflag;
const short is_animation = RNA_boolean_get(op->ptr, "animation"); const bool is_animation = RNA_boolean_get(op->ptr, "animation");
const short is_write_still = RNA_boolean_get(op->ptr, "write_still"); const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
const bool use_viewport = RNA_boolean_get(op->ptr, "use_viewport");
View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL;
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
const char *name; const char *name;
Object *active_object = CTX_data_active_object(C); Object *active_object = CTX_data_active_object(C);
@ -737,6 +738,7 @@ void RENDER_OT_render(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene"); 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_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)");
RNA_def_boolean(ot->srna, "use_viewport", 0, "Use 3D Viewport", "When inside a 3D viewport, use layers and camera of the viewport");
prop = RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render (used only when animation is disabled)"); prop = RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render (used only when animation is disabled)");
RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME - 2, "Scene", "Scene to render, current scene if not specified"); prop = RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME - 2, "Scene", "Scene to render, current scene if not specified");

@ -3940,9 +3940,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
/* render */ /* render */
WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "use_viewport", TRUE);
kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "animation", TRUE); RNA_boolean_set(kmi->ptr, "animation", TRUE);
RNA_boolean_set(kmi->ptr, "use_viewport", TRUE);
WM_keymap_add_item(keymap, "RENDER_OT_view_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "RENDER_OT_view_cancel", ESCKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "RENDER_OT_view_show", F11KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "RENDER_OT_view_show", F11KEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "RENDER_OT_play_rendered_anim", F11KEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "RENDER_OT_play_rendered_anim", F11KEY, KM_PRESS, KM_CTRL, 0);