diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-09-06 18:20:54 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-09-06 18:23:00 +0300 |
commit | a5a003ed5589657cc53f41ba6042b28a4631cfed (patch) | |
tree | 65e79c4bf58e8a6e76d1d16edc8596ac22056c6b /source/blender/draw/engines/gpencil/gpencil_draw_utils.c | |
parent | 6d8a86c07d5f5c290a9e606a7e03dccac9ddcf43 (diff) |
GPencil: New option to fade not selected objects
Before, it was only possible to fade the active object. The new option allows to fade all non gpencil selected object. This is a common request by artists.
{F7719513}
Reviewers: mendio, pepeland
Reviewed By: mendio
Differential Revision: https://developer.blender.org/D5704
Diffstat (limited to 'source/blender/draw/engines/gpencil/gpencil_draw_utils.c')
-rw-r--r-- | source/blender/draw/engines/gpencil/gpencil_draw_utils.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 01c3c10eb9e..e3c3f0b5d12 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -61,6 +61,38 @@ #define TEXTURE 4 #define PATTERN 5 +/* Verify if must fade object or not. */ +static bool gpencil_fade_object_check(GPENCIL_StorageList *stl, Object *ob) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + View3D *v3d = draw_ctx->v3d; + const bool is_overlay = (bool)((v3d) && ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && + (v3d->gp_flag & V3D_GP_SHOW_PAPER)); + + if ((!is_overlay) || (ob == draw_ctx->obact) || + ((v3d->gp_flag & V3D_GP_FADE_NOACTIVE_GPENCIL) == 0) || + (v3d->overlay.gpencil_paper_opacity == 1.0f)) { + return false; + } + + const bool playing = stl->storage->is_playing; + const bool is_render = (bool)stl->storage->is_render; + const bool is_mat_preview = (bool)stl->storage->is_mat_preview; + const bool is_select = (bool)(DRW_state_is_select() || DRW_state_is_depth()); + + return (bool)((!is_render) && (!playing) && (!is_mat_preview) && (!is_select)); +} + +/* Define Fade object uniforms. */ +static void gpencil_set_fade_uniforms(View3D *v3d, DRWShadingGroup *grp, bool status) +{ + DRW_shgroup_uniform_bool_copy(grp, "fade_on", status); + if (v3d) { + DRW_shgroup_uniform_vec3(grp, "fade_color", v3d->shading.background_color, 1); + DRW_shgroup_uniform_float(grp, "fade_factor", &v3d->overlay.gpencil_paper_opacity, 1); + } +} + /* Get number of vertex for using in GPU VBOs */ static void gpencil_calc_vertex(GPENCIL_StorageList *stl, tGPencilObjectCache *cache_ob, @@ -435,6 +467,9 @@ static DRWShadingGroup *gpencil_shgroup_fill_create(GPENCIL_Data *vedata, DRW_shgroup_uniform_int(grp, "shading_type", &stl->shgroups[id].shading_type[0], 2); + /* Fade object uniforms. */ + gpencil_set_fade_uniforms(v3d, grp, gpencil_fade_object_check(stl, ob)); + /* wire color */ set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, true); DRW_shgroup_uniform_vec4(grp, "wire_color", stl->shgroups[id].wire_color, 1); @@ -557,6 +592,9 @@ DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_Data *vedata, } DRW_shgroup_uniform_int(grp, "shading_type", &stl->shgroups[id].shading_type[0], 2); + /* Fade object uniforms. */ + gpencil_set_fade_uniforms(v3d, grp, gpencil_fade_object_check(stl, ob)); + /* wire color */ set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, false); DRW_shgroup_uniform_vec4(grp, "wire_color", stl->shgroups[id].wire_color, 1); @@ -607,6 +645,9 @@ DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_Data *vedata, DRW_shgroup_uniform_int(grp, "xraymode", &stl->storage->xray, 1); } + /* Fade object uniforms. */ + gpencil_set_fade_uniforms(v3d, grp, false); + /* image texture for pattern */ if ((gp_style) && (gp_style->stroke_style == GP_STYLE_STROKE_STYLE_TEXTURE) && (!onion)) { ImBuf *ibuf; @@ -706,6 +747,9 @@ static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_Data *vedata, } DRW_shgroup_uniform_int(grp, "shading_type", &stl->shgroups[id].shading_type[0], 2); + /* Fade object uniforms. */ + gpencil_set_fade_uniforms(v3d, grp, gpencil_fade_object_check(stl, ob)); + /* wire color */ set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, false); DRW_shgroup_uniform_vec4(grp, "wire_color", stl->shgroups[id].wire_color, 1); @@ -764,6 +808,9 @@ static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_Data *vedata, DRW_shgroup_uniform_int(grp, "xraymode", &stl->storage->xray, 1); } + /* Fade object uniforms. */ + gpencil_set_fade_uniforms(v3d, grp, false); + /* image texture */ if ((gp_style) && (gp_style->stroke_style == GP_STYLE_STROKE_STYLE_TEXTURE) && (!onion)) { ImBuf *ibuf; |