diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2018-05-29 16:29:55 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2018-05-29 16:31:00 +0300 |
commit | 44b99d10520a09baa010454cb7b3b2661c7e3b51 (patch) | |
tree | 8dc4bf19990e1699356850ac23deca4cbeaf61e2 /source/blender/draw/modes | |
parent | 43584f4a41cb986fbe13bf193fecdde41d23a4da (diff) |
For 2.8, bring back debug mode indices display.
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r-- | source/blender/draw/modes/edit_mesh_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/edit_mesh_mode_text.c | 53 |
2 files changed, 54 insertions, 2 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 85a7c4ec528..58ebef040da 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -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); diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c index a832c61cab5..def96e79eba 100644 --- a/source/blender/draw/modes/edit_mesh_mode_text.c +++ b/source/blender/draw/modes/edit_mesh_mode_text.c @@ -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); + } + } + } + } } |