Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606>2020-09-18 20:20:22 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-09-18 20:24:58 +0300
commitea6cd1c8f05b27a81e835251e779f047a3488203 (patch)
treef474690da2ddba60ca0feb2664141f65cde38a5d /source
parent5855f317a7070d69dbb94761c5a2c2f53b058a6e (diff)
Overlay: Fade Inactive Geometry
This implements a new overlay that blends the bakground color over the objects that are not in the same mode as the active object, making them fade with the background. This is especially needed for sculpt mode as there is no other overlay or indication in the viewport to display which object is active. This is intended to be used with D7510 in order to have a faster workflow when sculpting models with multiple objects. Reviewed By: fclem Differential Revision: https://developer.blender.org/D8679
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c15
-rw-r--r--source/blender/draw/CMakeLists.txt1
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.c29
-rw-r--r--source/blender/draw/engines/overlay/overlay_fade.c99
-rw-r--r--source/blender/draw/engines/overlay/overlay_private.h8
-rw-r--r--source/blender/makesdna/DNA_view3d_defaults.h1
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_space.c14
m---------source/tools0
9 files changed, 172 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 022a720b2ef..1d4912db330 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -735,5 +735,20 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+
+ /* Darken Inactive Overlay. */
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "fade_alpha")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.fade_alpha = 0.40f;
+ v3d->overlay.flag |= V3D_OVERLAY_FADE_INACTIVE;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 089b656d76c..11aea544c65 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -134,6 +134,7 @@ set(SRC
engines/overlay/overlay_engine.c
engines/overlay/overlay_extra.c
engines/overlay/overlay_facing.c
+ engines/overlay/overlay_fade.c
engines/overlay/overlay_gpencil.c
engines/overlay/overlay_grid.c
engines/overlay/overlay_image.c
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c
index 9cdd371ec4e..e93b505e8b7 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -196,6 +196,7 @@ static void OVERLAY_cache_init(void *vedata)
OVERLAY_antialiasing_cache_init(vedata);
OVERLAY_armature_cache_init(vedata);
OVERLAY_background_cache_init(vedata);
+ OVERLAY_fade_cache_init(vedata);
OVERLAY_extra_cache_init(vedata);
OVERLAY_facing_cache_init(vedata);
OVERLAY_gpencil_cache_init(vedata);
@@ -259,6 +260,27 @@ static bool overlay_object_is_edit_mode(const OVERLAY_PrivateData *pd, const Obj
return false;
}
+static bool overlay_should_fade_object(Object *ob, Object *active_object)
+{
+ if (!active_object || !ob) {
+ return false;
+ }
+
+ if (ELEM(active_object->mode, OB_MODE_OBJECT, OB_MODE_POSE)) {
+ return false;
+ }
+
+ if ((active_object->mode & ob->mode) != 0) {
+ return false;
+ }
+
+ if (ob->base_flag & BASE_FROM_DUPLI) {
+ return false;
+ }
+
+ return true;
+}
+
static void OVERLAY_cache_populate(void *vedata, Object *ob)
{
OVERLAY_Data *data = vedata;
@@ -295,6 +317,8 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
const bool draw_surface = (ob->dt >= OB_WIRE) && (renderable || (ob->dt == OB_WIRE));
const bool draw_facing = draw_surface && (pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) &&
!is_select;
+ const bool draw_fade = draw_surface && (pd->overlay.flag & V3D_OVERLAY_FADE_INACTIVE) &&
+ overlay_should_fade_object(ob, draw_ctx->obact);
const bool draw_bones = (pd->overlay.flag & V3D_OVERLAY_HIDE_BONES) == 0;
const bool draw_wires = draw_surface && has_surface &&
(pd->wireframe_mode || !pd->hide_overlays);
@@ -315,6 +339,9 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
bool do_init;
OVERLAY_DupliData *dupli = OVERLAY_duplidata_get(ob, vedata, &do_init);
+ if (draw_fade) {
+ OVERLAY_fade_cache_populate(vedata, ob);
+ }
if (draw_facing) {
OVERLAY_facing_cache_populate(vedata, ob);
}
@@ -511,6 +538,7 @@ static void OVERLAY_draw_scene(void *vedata)
}
OVERLAY_image_draw(vedata);
+ OVERLAY_fade_draw(vedata);
OVERLAY_facing_draw(vedata);
OVERLAY_extra_blend_draw(vedata);
@@ -538,6 +566,7 @@ static void OVERLAY_draw_scene(void *vedata)
GPU_framebuffer_bind(fbl->overlay_in_front_fb);
}
+ OVERLAY_fade_infront_draw(vedata);
OVERLAY_facing_infront_draw(vedata);
if (DRW_state_is_fbo()) {
diff --git a/source/blender/draw/engines/overlay/overlay_fade.c b/source/blender/draw/engines/overlay/overlay_fade.c
new file mode 100644
index 00000000000..0971021f1c0
--- /dev/null
+++ b/source/blender/draw/engines/overlay/overlay_fade.c
@@ -0,0 +1,99 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+/** \file
+ * \ingroup draw_engine
+ */
+
+#include "BKE_paint.h"
+#include "DRW_render.h"
+
+#include "ED_view3d.h"
+
+#include "overlay_private.h"
+
+void OVERLAY_fade_init(OVERLAY_Data *UNUSED(vedata))
+{
+}
+
+void OVERLAY_fade_cache_init(OVERLAY_Data *vedata)
+{
+ OVERLAY_PassList *psl = vedata->psl;
+ OVERLAY_PrivateData *pd = vedata->stl->pd;
+
+ for (int i = 0; i < 2; i++) {
+ /* Non Meshes Pass (Camera, empties, lights ...) */
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA;
+ DRW_PASS_CREATE(psl->fade_ps[i], state | pd->clipping_state);
+
+ GPUShader *sh = OVERLAY_shader_uniform_color();
+ pd->fade_grp[i] = DRW_shgroup_create(sh, psl->fade_ps[i]);
+ DRW_shgroup_uniform_block(pd->fade_grp[i], "globalsBlock", G_draw.block_ubo);
+
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ float color[4];
+ ED_view3d_background_color_get(draw_ctx->scene, draw_ctx->v3d, color);
+ color[3] = pd->overlay.fade_alpha;
+ if (draw_ctx->v3d->shading.background_type == V3D_SHADING_BACKGROUND_THEME) {
+ srgb_to_linearrgb_v4(color, color);
+ }
+ DRW_shgroup_uniform_vec4_copy(pd->fade_grp[i], "color", color);
+ }
+
+ if (!pd->use_in_front) {
+ pd->fade_grp[IN_FRONT] = pd->fade_grp[NOT_IN_FRONT];
+ }
+}
+
+void OVERLAY_fade_cache_populate(OVERLAY_Data *vedata, Object *ob)
+{
+ OVERLAY_PrivateData *pd = vedata->stl->pd;
+
+ if (pd->xray_enabled) {
+ return;
+ }
+
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) &&
+ !DRW_state_is_image_render();
+ const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
+
+ if (use_sculpt_pbvh) {
+ DRW_shgroup_call_sculpt(pd->fade_grp[is_xray], ob, false, false);
+ }
+ else {
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ if (geom) {
+ DRW_shgroup_call(pd->fade_grp[is_xray], geom, ob);
+ }
+ }
+}
+
+void OVERLAY_fade_draw(OVERLAY_Data *vedata)
+{
+ OVERLAY_PassList *psl = vedata->psl;
+
+ DRW_draw_pass(psl->fade_ps[NOT_IN_FRONT]);
+}
+
+void OVERLAY_fade_infront_draw(OVERLAY_Data *vedata)
+{
+ OVERLAY_PassList *psl = vedata->psl;
+
+ DRW_draw_pass(psl->fade_ps[IN_FRONT]);
+}
diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h
index b84b66ca83d..2cf2ca34801 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -100,6 +100,7 @@ typedef struct OVERLAY_PassList {
DRWPass *extra_grid_ps;
DRWPass *gpencil_canvas_ps;
DRWPass *facing_ps[2];
+ DRWPass *fade_ps[2];
DRWPass *grid_ps;
DRWPass *image_background_ps;
DRWPass *image_empties_ps;
@@ -268,6 +269,7 @@ typedef struct OVERLAY_PrivateData {
DRWShadingGroup *edit_uv_stretching_grp;
DRWShadingGroup *extra_grid_grp;
DRWShadingGroup *facing_grp[2];
+ DRWShadingGroup *fade_grp[2];
DRWShadingGroup *motion_path_lines_grp;
DRWShadingGroup *motion_path_points_grp;
DRWShadingGroup *outlines_grp;
@@ -566,6 +568,12 @@ void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob);
void OVERLAY_facing_draw(OVERLAY_Data *vedata);
void OVERLAY_facing_infront_draw(OVERLAY_Data *vedata);
+void OVERLAY_fade_init(OVERLAY_Data *vedata);
+void OVERLAY_fade_cache_init(OVERLAY_Data *vedata);
+void OVERLAY_fade_cache_populate(OVERLAY_Data *vedata, Object *ob);
+void OVERLAY_fade_draw(OVERLAY_Data *vedata);
+void OVERLAY_fade_infront_draw(OVERLAY_Data *vedata);
+
void OVERLAY_grid_init(OVERLAY_Data *vedata);
void OVERLAY_grid_cache_init(OVERLAY_Data *vedata);
void OVERLAY_grid_draw(OVERLAY_Data *vedata);
diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h
index 62e3d14bd0c..68f23b33d07 100644
--- a/source/blender/makesdna/DNA_view3d_defaults.h
+++ b/source/blender/makesdna/DNA_view3d_defaults.h
@@ -52,6 +52,7 @@
{ \
.wireframe_threshold = 1.0f, \
.xray_alpha_bone = 0.5f, \
+ .fade_alpha = 0.40f, \
.texture_paint_mode_opacity = 1.0f, \
.weight_paint_mode_opacity = 1.0f, \
.vertex_paint_mode_opacity = 1.0f, \
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 64f26a756db..3fc8b05c8b4 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -218,6 +218,9 @@ typedef struct View3DOverlay {
/** Armature edit/pose mode settings. */
float xray_alpha_bone;
+ /** Darken Inactive. */
+ float fade_alpha;
+
/** Other settings. */
float wireframe_threshold;
@@ -230,6 +233,7 @@ typedef struct View3DOverlay {
float gpencil_vertex_paint_opacity;
/** Handles display type for curves. */
int handle_display;
+ char _pad[4];
} View3DOverlay;
/* View3DOverlay->handle_display */
@@ -503,6 +507,7 @@ enum {
V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9),
V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
V3D_OVERLAY_STATS = (1 << 11),
+ V3D_OVERLAY_FADE_INACTIVE = (1 << 12),
};
/** #View3DOverlay.edit_flag */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 213326eff8c..18c80006496 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3615,6 +3615,20 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Face Orientation", "Show the Face Orientation Overlay");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "show_fade_inactive", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_FADE_INACTIVE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Fade Inactive Objects", "Fade inactive geometry using the viewport background color");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "fade_inactive_alpha", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "overlay.fade_alpha");
+ RNA_def_property_ui_text(prop, "Opacity", "Strength of the fade effect");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
+
prop = RNA_def_property(srna, "show_xray_bone", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECT);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
diff --git a/source/tools b/source/tools
-Subproject 896c5f78952adb2d091d28c65086d46992dabda
+Subproject 4b309364f65fee1ffafc5a4062125b8b728837a