GPencil: Add new X-Ray option for Canvas Grid

In some situations is good to have a grid visible anot beeing occulde by meshes.

By default is OFF.

Differential Revision: https://developer.blender.org/D7721
This commit is contained in:
Antonio Vazquez 2020-05-13 17:07:32 +02:00
parent 891b91928a
commit b369d46eb7
4 changed files with 12 additions and 2 deletions

View File

@ -6726,9 +6726,10 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
col = layout.column()
row = col.row()
row.prop(overlay, "use_gpencil_grid", text="")
sub = row.row()
sub = row.row(align=True)
sub.active = overlay.use_gpencil_grid
sub.prop(overlay, "gpencil_grid_opacity", text="Canvas", slider=True)
sub.prop(overlay, "use_gpencil_canvas_xray", text="", icon='XRAY')
row = col.row()
row.prop(overlay, "use_gpencil_fade_layers", text="")

View File

@ -204,6 +204,7 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
const bool show_grid = (v3d->gp_flag & V3D_GP_SHOW_GRID) != 0 &&
((ts->gpencil_v3d_align &
(GP_PROJECT_DEPTH_VIEW | GP_PROJECT_DEPTH_STROKE)) == 0);
const bool grid_xray = (v3d->gp_flag & V3D_GP_SHOW_GRID_XRAY);
if (show_grid && show_overlays) {
const char *grid_unit = NULL;
@ -256,7 +257,9 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
const int gridlines = (gpd->grid.lines <= 0) ? 1 : gpd->grid.lines;
int line_ct = gridlines * 4 + 2;
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA;
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA;
state |= (grid_xray) ? DRW_STATE_DEPTH_ALWAYS : DRW_STATE_DEPTH_LESS_EQUAL;
DRW_PASS_CREATE(psl->gpencil_canvas_ps, state);
sh = OVERLAY_shader_gpencil_canvas();

View File

@ -450,6 +450,7 @@ enum {
#define V3D_GP_FADE_NOACTIVE_GPENCIL (1 << 6) /* Fade other GPencil objects */
#define V3D_GP_SHOW_STROKE_DIRECTION (1 << 7) /* Show Strokes Directions */
#define V3D_GP_SHOW_MATERIAL_NAME (1 << 8) /* Show Material names */
#define V3D_GP_SHOW_GRID_XRAY (1 << 9) /* Show Canvas Grid on Top */
/** #View3DShading.flag */
enum {

View File

@ -3905,6 +3905,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop, "Fade Grease Pencil Objects", "Fade Grease Pencil Objects, except the active one");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
prop = RNA_def_property(srna, "use_gpencil_canvas_xray", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_GRID_XRAY);
RNA_def_property_ui_text(prop, "Canvas X-Ray", "Put Canvas grid on top of any other object");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
prop = RNA_def_property(srna, "use_gpencil_show_directions", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_STROKE_DIRECTION);
RNA_def_property_ui_text(prop,