From c1814d593d1dcb3d683ef7be8e7e1b1d253bc614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 25 Jan 2019 21:03:50 +0100 Subject: Workbench: Depth Of Field: Add toggle option in shading popover Pretty straight forward. Just an option to turn the DoF per viewport. Default is off as in 2.79. --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++++ source/blender/draw/engines/workbench/workbench_effect_dof.c | 4 +++- source/blender/makesdna/DNA_view3d_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 6 ++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 5e42e0b655b..cca13d6d766 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4593,6 +4593,10 @@ class VIEW3D_PT_shading_options(Panel): sub.prop(shading, "curvature_ridge_factor", text="Ridge") sub.prop(shading, "curvature_valley_factor", text="Valley") + row = col.row() + row.active = not shading.show_xray + row.prop(shading, "use_dof", text="Depth Of Field") + if shading.type in {'WIREFRAME', 'SOLID'}: row = layout.split() row.prop(shading, "show_object_outline") diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index b74a77bf891..ec8c184eac5 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -134,7 +134,9 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera) WORKBENCH_PrivateData *wpd = stl->g_data; WORKBENCH_FramebufferList *fbl = vedata->fbl; - if (camera == NULL) { + if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || + (camera == NULL)) + { wpd->dof_enabled = false; return; } diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index b4395d4566f..780383e399d 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -439,6 +439,7 @@ enum { V3D_SHADING_XRAY_BONE = (1 << 8), V3D_SHADING_WORLD_ORIENTATION = (1 << 9), V3D_SHADING_BACKFACE_CULLING = (1 << 10), + V3D_SHADING_DEPTH_OF_FIELD = (1 << 11), }; /* View3DShading->color_type */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6fa13cadbd6..d72c20bb057 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2594,6 +2594,12 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_DEPTH_OF_FIELD); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Depth Of Field", "Use depth of field on viewport using the values from the active camera"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); -- cgit v1.2.3