[Bf-blender-cvs] [bf8b62e8748] master: Fix curve handle color ID display

Campbell Barton noreply at git.blender.org
Mon Jun 15 07:36:05 CEST 2020


Commit: bf8b62e874877b4bbe32c19b84bdc937320176ea
Author: Campbell Barton
Date:   Mon Jun 15 15:28:51 2020 +1000
Branches: master
https://developer.blender.org/rBbf8b62e874877b4bbe32c19b84bdc937320176ea

Fix curve handle color ID display

Regression in 49f59092e7c8c caused all handles to display using
the 'aligned' theme color.

Arrange flags to fix this, add assert to avoid this happening again.

Also rename flag so it's use is clearer.

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

M	source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
M	source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_curve.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 306fbb473ee..a400aadb052 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
@@ -52,7 +52,7 @@ void main()
 
   bool edge_selected = (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED) != 0);
   bool handle_selected = (showCurveHandles &&
-                          (((vertFlag[1] | vertFlag[0]) & HANDLE_SELECTED) != 0));
+                          (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED_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/engines/overlay/shaders/edit_curve_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
index b1e1c0879a5..a811fcca0d4 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
@@ -37,7 +37,7 @@ void main()
 #endif
 
   bool show_handle = showCurveHandles;
-  if ((curveHandleDisplay == CURVE_HANDLE_SELECTED) && ((data & HANDLE_SELECTED) == 0)) {
+  if ((curveHandleDisplay == CURVE_HANDLE_SELECTED) && ((data & VERT_SELECTED_BEZT_HANDLE) == 0)) {
     show_handle = false;
   }
 
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 80649143537..191d75342d0 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -201,18 +201,19 @@ struct GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me);
 
 int DRW_mesh_material_count_get(struct Mesh *me);
 
+/* See 'common_globals_lib.glsl' for duplicate defines. */
+
 /* Edit mesh bitflags (is this the right place?) */
 enum {
   VFLAG_VERT_ACTIVE = 1 << 0,
   VFLAG_VERT_SELECTED = 1 << 1,
-  VFLAG_EDGE_ACTIVE = 1 << 2,
-  VFLAG_EDGE_SELECTED = 1 << 3,
-  VFLAG_EDGE_SEAM = 1 << 4,
-  VFLAG_EDGE_SHARP = 1 << 5,
-  VFLAG_EDGE_FREESTYLE = 1 << 6,
-  VFLAG_HANDLE_SELECTED = 1 << 7,
-  /* Beware to not go over 1 << 7 (it's a byte flag)
-   * (see gpu_shader_edit_mesh_overlay_geom.glsl) */
+  VFLAG_VERT_SELECTED_BEZT_HANDLE = 1 << 2,
+  VFLAG_EDGE_ACTIVE = 1 << 3,
+  VFLAG_EDGE_SELECTED = 1 << 4,
+  VFLAG_EDGE_SEAM = 1 << 5,
+  VFLAG_EDGE_SHARP = 1 << 6,
+  VFLAG_EDGE_FREESTYLE = 1 << 7,
+  /* Beware to not go over 1 << 7 (it's a byte flag). */
 };
 
 enum {
@@ -224,8 +225,7 @@ enum {
   VFLAG_EDGE_UV_SELECT = 1 << 5,
   VFLAG_FACE_UV_ACTIVE = 1 << 6,
   VFLAG_FACE_UV_SELECT = 1 << 7,
-  /* Beware to not go over 1 << 7 (it's a byte flag)
-   * (see gpu_shader_edit_mesh_overlay_geom.glsl) */
+  /* Beware to not go over 1 << 7 (it's a byte flag). */
 };
 
 /* Particles */
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index c6112994b65..8798549a416 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -47,6 +47,7 @@
 
 #include "draw_cache_impl.h" /* own include */
 
+/* See: edit_curve_point_vert.glsl for duplicate includes. */
 #define SELECT 1
 #define ACTIVE_NURB 1 << 2
 #define BEZIER_HANDLE 1 << 3
@@ -698,7 +699,9 @@ static char beztriple_vflag_get(CurveRenderData *rdata,
   SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE);
   SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB);
   SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE);
-  SET_FLAG_FROM_TEST(vflag, handle_selected, VFLAG_HANDLE_SELECTED);
+  SET_FLAG_FROM_TEST(vflag, handle_selected, VFLAG_VERT_SELECTED_BEZT_HANDLE);
+  /* Setting flags that overlap with will cause the color id not to work properly. */
+  BLI_assert((vflag >> COLOR_SHIFT) == 0);
   /* handle color id */
   vflag |= col_id << COLOR_SHIFT;
   return vflag;
@@ -711,6 +714,8 @@ static char bpoint_vflag_get(CurveRenderData *rdata, char flag, int v_idx, int n
   SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE);
   SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB);
   SET_FLAG_FROM_TEST(vflag, ((u % 2) == 0), EVEN_U_BIT);
+  /* Setting flags that overlap with will cause the color id not to work properly. */
+  BLI_assert((vflag >> COLOR_SHIFT) == 0);
   vflag |= COLOR_NURB_ULINE_ID << COLOR_SHIFT;
   return vflag;
 }
diff --git a/source/blender/draw/intern/shaders/common_globals_lib.glsl b/source/blender/draw/intern/shaders/common_globals_lib.glsl
index a479a87e14b..40a527a6ba4 100644
--- a/source/blender/draw/intern/shaders/common_globals_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_globals_lib.glsl
@@ -123,6 +123,8 @@ layout(std140) uniform globalsBlock
 
 #define sizeViewportInv (sizeViewport.zw)
 
+/* See: 'draw_cache_impl.h' for matching includes. */
+
 /* data[0] (1st byte flags) */
 #define FACE_ACTIVE (1 << 0)
 #define FACE_SELECTED (1 << 1)
@@ -135,9 +137,9 @@ layout(std140) uniform globalsBlock
 /* data[1] (2st byte flags) */
 #define VERT_ACTIVE (1 << 0)
 #define VERT_SELECTED (1 << 1)
-#define EDGE_ACTIVE (1 << 2)
-#define EDGE_SELECTED (1 << 3)
-#define EDGE_SEAM (1 << 4)
-#define EDGE_SHARP (1 << 5)
-#define EDGE_FREESTYLE (1 << 6)
-#define HANDLE_SELECTED (1 << 7)
+#define VERT_SELECTED_BEZT_HANDLE (1 << 2)
+#define EDGE_ACTIVE (1 << 3)
+#define EDGE_SELECTED (1 << 4)
+#define EDGE_SEAM (1 << 5)
+#define EDGE_SHARP (1 << 6)
+#define EDGE_FREESTYLE (1 << 7)



More information about the Bf-blender-cvs mailing list