For 2.8, bring back debug mode indices display.
authorHoward Trickey <howard.trickey@gmail.com>
Tue, 29 May 2018 13:29:55 +0000 (09:29 -0400)
committerHoward Trickey <howard.trickey@gmail.com>
Tue, 29 May 2018 13:31:00 +0000 (09:31 -0400)
release/scripts/startup/bl_ui/space_view3d.py
source/blender/draw/modes/edit_mesh_mode.c
source/blender/draw/modes/edit_mesh_mode_text.c

index 00e22aaaae91e7b95f9db48e1d5d411d21b91f21..51a7eb697fd7d00d75127c812f6d50d9f2a46ba7 100644 (file)
@@ -3808,7 +3808,7 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
         col.prop(mesh, "show_extra_face_area", text="Area")
         col.prop(mesh, "show_extra_face_angle", text="Angle")
         if bpy.app.debug:
-            layout.prop(mesh, "show_extra_indices")
+            layout.prop(mesh, "show_extra_indices", text="Indices")
 
 
 class VIEW3D_PT_view3d_meshstatvis(Panel):
index 85a7c4ec528d36d6efea97b0bc7f6649df009fb5..58ebef040daa266407341fbb4efa48f7ab2baa4a 100644 (file)
@@ -512,7 +512,8 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
                        if (me->drawflag & (ME_DRAWEXTRA_EDGELEN |
                                            ME_DRAWEXTRA_FACEAREA |
                                            ME_DRAWEXTRA_FACEANG |
-                                           ME_DRAWEXTRA_EDGEANG))
+                                           ME_DRAWEXTRA_EDGEANG |
+                                           ME_DRAWEXTRA_INDICES))
                        {
                                DRW_edit_mesh_mode_text_measure_stats(
                                       draw_ctx->ar, v3d, ob, &scene->unit);
index a832c61cab515145e759b34d9443aa179c6beea1..def96e79ebaf688219ba62c0f8059161ba86762a 100644 (file)
@@ -84,7 +84,7 @@ void DRW_edit_mesh_mode_text_measure_stats(
        else if (grid <= 10.0f) conv_float = "%.3g";
        else conv_float = "%.2g";
 
-       if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG)) {
+       if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG | ME_DRAWEXTRA_INDICES)) {
                BoundBox bb;
                const rcti rect = {0, ar->winx, 0, ar->winy};
 
@@ -298,4 +298,55 @@ void DRW_edit_mesh_mode_text_measure_stats(
                        }
                }
        }
+
+       /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with --debug */
+       if (me->drawflag & ME_DRAWEXTRA_INDICES) {
+               int i;
+
+               /* For now, reuse an appropriate theme color */
+               UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
+
+               if (em->selectmode & SCE_SELECT_VERTEX) {
+                       BMVert *v;
+
+                       BM_ITER_MESH_INDEX(v, &iter, em->bm, BM_VERTS_OF_MESH, i) {
+                               if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+                                       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
+                                       DRW_text_cache_add(dt, v->co, numstr, numstr_len, 0, txt_flag, col);
+                               }
+                       }
+               }
+
+               if (em->selectmode & SCE_SELECT_EDGE) {
+                       BMEdge *e;
+
+                       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];
+
+                                       copy_v3_v3(v1, e->v1->co);
+                                       copy_v3_v3(v2, e->v2->co);
+
+                                       if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) {
+                                               mid_v3_v3v3(vmid, v1_clip, v2_clip);
+                                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
+                                               DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, txt_flag, col);
+                                       }
+                               }
+                       }
+               }
+
+               if (em->selectmode & SCE_SELECT_FACE) {
+                       BMFace *f;
+
+                       BM_ITER_MESH_INDEX(f, &iter, em->bm, BM_FACES_OF_MESH, i) {
+                               if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+                                       BM_face_calc_center_mean(f, v1);
+
+                                       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
+                                       DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, txt_flag, col);
+                               }
+                       }
+               }
+       }
 }