diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-22 16:44:18 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-22 16:44:18 +0300 |
commit | 0cc514ec845e3170a63ad837360842219e951e85 (patch) | |
tree | 424b44fa76dea4cb387d56a50a31696121454343 /source | |
parent | 120492ace9150913f106f329942684c583a6f697 (diff) |
Make Shift-Z in viewprot a toggle between current shading mode and rendered one
This way it is now possible to toggle between material and rendered shading
while previously rendered viewport will always go back to solid shading.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 29 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 9 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 7 |
5 files changed, 42 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d6e2f237be9..464fc0a2d49 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6935,6 +6935,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc) /* render can be quite heavy, set to solid on load */ if (v3d->drawtype == OB_RENDER) v3d->drawtype = OB_SOLID; + v3d->prev_drawtype = OB_SOLID; if (v3d->fx_settings.dof) v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index c7a10d65071..155c7503acf 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4848,6 +4848,35 @@ void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } +/* ************************* Toggle rendered shading *********************** */ + +static int toggle_render_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + if (v3d->drawtype == OB_RENDER) { + v3d->drawtype = v3d->prev_drawtype; + } + else { + v3d->prev_drawtype = v3d->drawtype; + v3d->drawtype = OB_RENDER; + } + ED_view3d_shade_update(CTX_data_main(C), CTX_data_scene(C), v3d, CTX_wm_area(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_toggle_render(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Toggle Rendered Shading"; + ot->description = "Toggle rendered shading mode of the viewport"; + ot->idname = "VIEW3D_OT_toggle_render"; + + /* api callbacks */ + ot->exec = toggle_render_exec; + ot->poll = ED_operator_view3d_active; +} + /* ************************* below the line! *********************** */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 901c5c8d4c2..45918ed8bed 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -103,6 +103,7 @@ void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot); void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); +void VIEW3D_OT_toggle_render(struct wmOperatorType *ot); void view3d_boxview_copy(ScrArea *sa, ARegion *ar); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index c30e688f1e7..1c84ce3c985 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -218,7 +218,9 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active); - + + WM_operatortype_append(VIEW3D_OT_toggle_render); + transform_operatortypes(); } @@ -417,10 +419,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "value_1", "SOLID"); RNA_string_set(kmi->ptr, "value_2", "TEXTURED"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shade"); - RNA_string_set(kmi->ptr, "value_1", "SOLID"); - RNA_string_set(kmi->ptr, "value_2", "RENDERED"); + WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_render", ZKEY, KM_PRESS, KM_SHIFT, 0); /* selection*/ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 0ef8f2616c4..321ff26f68f 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -237,6 +237,13 @@ typedef struct View3D { float stereo3d_convergence_factor; float stereo3d_volume_alpha; float stereo3d_convergence_alpha; + + /* Previous viewport draw type. + * Runtime-only, set in the rendered viewport otggle operator. + */ + short prev_drawtype; + short pad1; + float pad2; } View3D; |