[Bf-blender-cvs] [09c1cb8a17e] master: Fix T84260: NURBS edit mode lines not showing

Falk David noreply at git.blender.org
Mon Jan 4 15:35:33 CET 2021


Commit: 09c1cb8a17e4c1a0aeea0d5477ec2db61390a5e8
Author: Falk David
Date:   Mon Jan 4 15:31:53 2021 +0100
Branches: master
https://developer.blender.org/rB09c1cb8a17e4c1a0aeea0d5477ec2db61390a5e8

Fix T84260: NURBS edit mode lines not showing

When in edit mode, the edit lines for de-selected surfaces did not
show up.

The bug was caused by the is_gpencil bool which reused another flag.
Both grease pencil and nurbs surfaces use the edit_curve_handle shader.
A dedicated flag was added to make sure the is_gpencil bool is
set correctly.

Reviewed By: fclem

Maniphest Tasks: T84260

Differential Revision: https://developer.blender.org/D9985

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

M	source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_gpencil.c
M	source/blender/draw/intern/shaders/common_globals_lib.glsl

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

diff --git a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
index 442f69aec7e..ad791a9416d 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
@@ -53,9 +53,8 @@ void main()
   bool edge_selected = (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED) != 0);
   bool handle_selected = (showCurveHandles &&
                           (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED_BEZT_HANDLE) != 0));
-  /* It reuses freestyle flag because the flag is 8 bits and all are already used and this
-   * flag is not used in this context. */
-  bool is_gpencil = ((vertFlag[1] & EDGE_FREESTYLE) != 0);
+
+  bool is_gpencil = ((vertFlag[1] & VERT_GPENCIL_BEZT_HANDLE) != 0);
 
   /* If handle type is only selected and the edge is not selected, don't show. */
   if ((curveHandleDisplay != CURVE_HANDLE_ALL) && (!handle_selected)) {
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 46b6cc7d708..7b97ce43558 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -230,6 +230,8 @@ enum {
   VFLAG_EDGE_SHARP = 1 << 6,
   VFLAG_EDGE_FREESTYLE = 1 << 7,
   /* Beware to not go over 1 << 7 (it's a byte flag). */
+  /* NOTE: Grease pencil edit curve use another type of data format that allows for this value. */
+  VFLAG_VERT_GPENCIL_BEZT_HANDLE = 1 << 30,
 };
 
 enum {
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index 4e809ad45fe..b1814d54353 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -211,7 +211,7 @@ static GPUVertFormat *gpencil_edit_stroke_format(void)
 /* MUST match the format below. */
 typedef struct gpEditCurveVert {
   float pos[3];
-  int data;
+  uint32_t data;
 } gpEditCurveVert;
 
 static GPUVertFormat *gpencil_edit_curve_format(void)
@@ -220,7 +220,7 @@ static GPUVertFormat *gpencil_edit_curve_format(void)
   if (format.attr_len == 0) {
     /* initialize vertex formats */
     GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
-    GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT);
+    GPU_vertformat_attr_add(&format, "data", GPU_COMP_U32, 1, GPU_FETCH_INT);
   }
   return &format;
 }
@@ -754,17 +754,16 @@ static void gpencil_edit_curve_stroke_count_cb(bGPDlayer *gpl,
   iter->curve_len += gps->editcurve->tot_curve_points * 4;
 }
 
-static char gpencil_beztriple_vflag_get(char flag,
+static uint32_t gpencil_beztriple_vflag_get(char flag,
                                         char col_id,
                                         bool handle_point,
                                         const bool handle_selected)
 {
-  char vflag = 0;
+  uint32_t vflag = 0;
   SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED);
   SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE);
   SET_FLAG_FROM_TEST(vflag, handle_selected, VFLAG_VERT_SELECTED_BEZT_HANDLE);
-  /* Reuse flag of Freestyle to indicate is GPencil data. */
-  vflag |= VFLAG_EDGE_FREESTYLE;
+  vflag |= VFLAG_VERT_GPENCIL_BEZT_HANDLE;
 
   /* Handle color id. */
   vflag |= col_id << COLOR_SHIFT;
@@ -794,7 +793,7 @@ static void gpencil_edit_curve_stroke_iter_cb(bGPDlayer *gpl,
   for (int i = 0; i < editcurve->tot_curve_points; i++) {
     BezTriple *bezt = &editcurve->curve_points[i].bezt;
     const bool handle_selected = BEZT_ISSEL_ANY(bezt);
-    const char vflag[3] = {
+    const uint32_t vflag[3] = {
         gpencil_beztriple_vflag_get(bezt->f1, bezt->h1, true, handle_selected),
         gpencil_beztriple_vflag_get(bezt->f2, bezt->h1, hide, handle_selected),
         gpencil_beztriple_vflag_get(bezt->f3, bezt->h2, true, handle_selected),
diff --git a/source/blender/draw/intern/shaders/common_globals_lib.glsl b/source/blender/draw/intern/shaders/common_globals_lib.glsl
index 691f1d5e519..91fb822edac 100644
--- a/source/blender/draw/intern/shaders/common_globals_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_globals_lib.glsl
@@ -125,7 +125,7 @@ layout(std140) uniform globalsBlock
 #define sizeViewportInv (sizeViewport.zw)
 
 /* See: 'draw_cache_impl.h' for matching includes. */
-
+#define VERT_GPENCIL_BEZT_HANDLE (1 << 30)
 /* data[0] (1st byte flags) */
 #define FACE_ACTIVE (1 << 0)
 #define FACE_SELECTED (1 << 1)



More information about the Bf-blender-cvs mailing list