Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager_text.c
| Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | void DRW_text_edit_mesh_measure_stats(ARegion *ar, | ||||
| char numstr[32]; /* Stores the measurement display text here */ | char numstr[32]; /* Stores the measurement display text here */ | ||||
| size_t numstr_len; | size_t numstr_len; | ||||
| const char *conv_float; /* Use a float conversion matching the grid size */ | const char *conv_float; /* Use a float conversion matching the grid size */ | ||||
| uchar col[4] = {0, 0, 0, 255}; /* color of the text to draw */ | uchar col[4] = {0, 0, 0, 255}; /* color of the text to draw */ | ||||
| float area; /* area of the face */ | float area; /* area of the face */ | ||||
| float grid = unit->system ? unit->scale_length : v3d->grid; | float grid = unit->system ? unit->scale_length : v3d->grid; | ||||
| const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0; | const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0; | ||||
| const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 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]; | float clip_planes[4][4]; | ||||
| /* allow for displaying shape keys and deform mods */ | /* allow for displaying shape keys and deform mods */ | ||||
| BMIter iter; | 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 */ | /* make the precision of the display value proportionate to the gridsize */ | ||||
| if (grid <= 0.01f) { | if (grid <= 0.01f) { | ||||
| conv_float = "%.6g"; | conv_float = "%.6g"; | ||||
| } | } | ||||
| else if (grid <= 0.1f) { | else if (grid <= 0.1f) { | ||||
| conv_float = "%.5g"; | conv_float = "%.5g"; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { | ||||
| numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2)); | numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2)); | ||||
| } | } | ||||
| DRW_text_cache_add(dt, | DRW_text_cache_add(dt, | ||||
| vmid, | vmid, | ||||
| numstr, | numstr, | ||||
| numstr_len, | numstr_len, | ||||
| 0, | 0, | ||||
| (do_edge_textpair) ? edge_texpair_sep : 0, | edge_tex_sep, | ||||
| txt_flag, | txt_flag, | ||||
| col); | col); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) { | if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) { | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { | ||||
| (is_rad) ? angle : RAD2DEGF(angle), | (is_rad) ? angle : RAD2DEGF(angle), | ||||
| (is_rad) ? "r" : "°"); | (is_rad) ? "r" : "°"); | ||||
| DRW_text_cache_add(dt, | DRW_text_cache_add(dt, | ||||
| vmid, | vmid, | ||||
| numstr, | numstr, | ||||
| numstr_len, | numstr_len, | ||||
| 0, | 0, | ||||
| (do_edge_textpair) ? -edge_texpair_sep : 0, | -edge_tex_sep, | ||||
| txt_flag, | txt_flag, | ||||
| col); | col); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | if (em->selectmode & SCE_SELECT_VERTEX) { | ||||
| DRW_text_cache_add(dt, vec, numstr, numstr_len, 0, 0, txt_flag, col); | DRW_text_cache_add(dt, vec, numstr, numstr_len, 0, 0, txt_flag, col); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (em->selectmode & SCE_SELECT_EDGE) { | if (em->selectmode & SCE_SELECT_EDGE) { | ||||
| BMEdge *e; | 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) { | BM_ITER_MESH_INDEX (e, &iter, em->bm, BM_EDGES_OF_MESH, i) { | ||||
| if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { | if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { | ||||
| float v1_clip[3], v2_clip[3]; | float v1_clip[3], v2_clip[3]; | ||||
| copy_v3_v3(v1, e->v1->co); | copy_v3_v3(v1, e->v1->co); | ||||
| copy_v3_v3(v2, e->v2->co); | copy_v3_v3(v2, e->v2->co); | ||||
| if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { | if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { | ||||
| mid_v3_v3v3(vmid, v1_clip, v2_clip); | mid_v3_v3v3(vmid, v1_clip, v2_clip); | ||||
| mul_m4_v3(ob->obmat, vmid); | mul_m4_v3(ob->obmat, vmid); | ||||
| numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); | 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); | |||||
| } | } | ||||
campbellbarton: These could be defined outside the loop. | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (em->selectmode & SCE_SELECT_FACE) { | if (em->selectmode & SCE_SELECT_FACE) { | ||||
| BMFace *f; | BMFace *f; | ||||
| BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, i) { | BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, i) { | ||||
| Show All 11 Lines | |||||
These could be defined outside the loop.