[Bf-blender-cvs] [e0afee86b35] master: Fix T72128: Overlay: Edge indices stacking on top of edge measurements

Philipp Oeser noreply at git.blender.org
Thu Dec 19 13:55:31 CET 2019


Commit: e0afee86b3527bd30cad8319385ccb3bc2a255b4
Author: Philipp Oeser
Date:   Wed Dec 4 11:05:02 2019 +0100
Branches: master
https://developer.blender.org/rBe0afee86b3527bd30cad8319385ccb3bc2a255b4

Fix T72128: Overlay: Edge indices stacking on top of edge measurements

Make indices accommodate into the measures of edgelength and edgeangle
so this results in a nice stack of up to three rows.

Maniphest Tasks: T72128

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

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

M	source/blender/draw/intern/draw_manager_text.c

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

diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c
index 38e8544de07..4abc96375a3 100644
--- a/source/blender/draw/intern/draw_manager_text.c
+++ b/source/blender/draw/intern/draw_manager_text.c
@@ -213,14 +213,23 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
   float grid = unit->system ? unit->scale_length : v3d->grid;
   const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
   const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0;
-  /* when 2 edge-info options are enabled, space apart */
-  const bool do_edge_textpair = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) &&
-                                (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG);
-  const short edge_texpair_sep = (short)(5.0f * U.dpi_fac);
   float clip_planes[4][4];
   /* allow for displaying shape keys and deform mods */
   BMIter iter;
 
+  /* when 2 or more edge-info options are enabled, space apart */
+  short edge_tex_count = 0;
+  if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) {
+    edge_tex_count += 1;
+  }
+  if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) {
+    edge_tex_count += 1;
+  }
+  if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) && (em->selectmode & SCE_SELECT_EDGE)) {
+    edge_tex_count += 1;
+  }
+  const short edge_tex_sep = (short)((edge_tex_count - 1) * 5.0f * U.dpi_fac);
+
   /* make the precision of the display value proportionate to the gridsize */
 
   if (grid <= 0.01f) {
@@ -290,7 +299,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
                              numstr,
                              numstr_len,
                              0,
-                             (do_edge_textpair) ? edge_texpair_sep : 0,
+                             edge_tex_sep,
                              txt_flag,
                              col);
         }
@@ -352,7 +361,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
                                numstr,
                                numstr_len,
                                0,
-                               (do_edge_textpair) ? -edge_texpair_sep : 0,
+                               -edge_tex_sep,
                                txt_flag,
                                col);
           }
@@ -494,6 +503,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
     if (em->selectmode & SCE_SELECT_EDGE) {
       BMEdge *e;
 
+      const bool use_edge_tex_sep = (edge_tex_count == 2);
+      const bool use_edge_tex_len = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN);
+
       BM_ITER_MESH_INDEX (e, &iter, em->bm, BM_EDGES_OF_MESH, i) {
         if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
           float v1_clip[3], v2_clip[3];
@@ -506,7 +518,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
             mul_m4_v3(ob->obmat, vmid);
 
             numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
-            DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col);
+            DRW_text_cache_add(dt,
+                               vmid,
+                               numstr,
+                               numstr_len,
+                               0,
+                               (use_edge_tex_sep) ? (use_edge_tex_len) ? -edge_tex_sep : edge_tex_sep : 0,
+                               txt_flag,
+                               col);
           }
         }
       }



More information about the Bf-blender-cvs mailing list