GP: New Fade no active layer overlay option

This option allows to fade all layers except active one. This can help in very crowded scenes with a lot of layers, to verify you are working in the right one.
This commit is contained in:
Antonioya
2018-10-30 17:53:30 +01:00
parent e7811ce0c4
commit 6f311ef57e
6 changed files with 58 additions and 10 deletions

View File

@@ -2205,5 +2205,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
/* grease pencil fade layer opacity */
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_fade_layer = 0.5f;
}
}
}
}
}
}
}

View File

@@ -1262,6 +1262,7 @@ void DRW_gpencil_populate_datablock(
float opacity;
bGPDframe *p = NULL;
bGPDframe *gpf = NULL;
bGPDlayer *gpl_active = BKE_gpencil_layer_getactive(gpd);
/* check if playing animation */
bool playing = stl->storage->is_playing;
@@ -1301,14 +1302,20 @@ void DRW_gpencil_populate_datablock(
if (gpf == NULL)
continue;
opacity = gpl->opacity;
/* if pose mode, maybe the overlay to fade geometry is enabled */
if ((draw_ctx->obact) && (draw_ctx->object_mode == OB_MODE_POSE) &&
(v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT))
{
opacity = gpl->opacity * v3d->overlay.bone_select_alpha;
opacity = opacity * v3d->overlay.bone_select_alpha;
}
else {
opacity = gpl->opacity;
/* fade no active layers */
if ((overlay) && (draw_ctx->object_mode == OB_MODE_GPENCIL_PAINT) &&
(v3d->gp_flag & V3D_GP_FADE_NOACTIVE_LAYERS) &&
(draw_ctx->obact) && (draw_ctx->obact == ob) &&
(gpl != gpl_active))
{
opacity = opacity * v3d->overlay.gpencil_fade_layer;
}
/* create derived array data or expand */

View File

@@ -196,7 +196,7 @@ typedef struct View3DOverlay {
/* grease pencil settings */
float gpencil_paper_opacity;
float gpencil_grid_opacity;
char _pad1[4];
float gpencil_fade_layer;
} View3DOverlay;
@@ -370,6 +370,7 @@ typedef struct View3D {
#define V3D_GP_SHOW_EDIT_LINES (1 << 2)
#define V3D_GP_SHOW_MULTIEDIT_LINES (1 << 3)
#define V3D_GP_SHOW_ONION_SKIN (1 << 4) /* main switch at view level */
#define V3D_GP_FADE_NOACTIVE_LAYERS (1 << 5) /* fade layers not active */
/* View3DShading->light */
enum {

View File

@@ -340,6 +340,10 @@ static void rna_GPencil_active_layer_index_set(PointerRNA *ptr, int value)
bGPDlayer *gpl = BLI_findlink(&gpd->layers, value);
BKE_gpencil_layer_setactive(gpd, gpl);
/* Now do standard updates... */
DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
static void rna_GPencil_active_layer_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)

View File

@@ -2959,6 +2959,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
"Display a grid over grease pencil paper");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "use_gpencil_fade_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_FADE_NOACTIVE_LAYERS);
RNA_def_property_ui_text(prop, "Fade Layers",
"Toggle fading of Grease Pencil layers except the active one");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
prop = RNA_def_property(srna, "gpencil_grid_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_grid_opacity");
RNA_def_property_range(prop, 0.1f, 1.0f);
@@ -2974,6 +2980,15 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Opacity", "Paper opacity");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
/* Paper opacity factor */
prop = RNA_def_property(srna, "gpencil_fade_layer", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_fade_layer");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_ui_text(prop, "Opacity",
"Fade layer opacity for Grease Pencil layers except the active one");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
/* show edit lines */
prop = RNA_def_property(srna, "use_gpencil_edit_lines", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_EDIT_LINES);