[Bf-blender-cvs] [fd025b0b7a4] blender-v2.83-release: GPencil: Add new X-Ray option for Canvas Grid

Antonio Vazquez noreply at git.blender.org
Wed May 13 22:48:14 CEST 2020


Commit: fd025b0b7a46c5e56f348b73cf989c6bbddec707
Author: Antonio Vazquez
Date:   Wed May 13 17:07:32 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBfd025b0b7a46c5e56f348b73cf989c6bbddec707

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

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/engines/overlay/overlay_gpencil.c
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index fca4cb4c321..643776fc612 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6733,9 +6733,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="")
diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.c
index b79d5753686..1397ef7b4b2 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -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();
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 21def800e4a..11c3c1c4d1b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index d4d35e07c2a..326dd88dc59 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3852,6 +3852,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,



More information about the Bf-blender-cvs mailing list