Commit: 8277bee748188dbcab431e15bedd5c1b5559508a Author: mano-wii Date: Mon Oct 30 17:21:48 2017 +1100 Branches: blender2.8 https://developer.blender.org/rB8277bee748188dbcab431e15bedd5c1b5559508a
Draw Manager: re-enable edit-mesh text overlay =================================================================== M source/blender/draw/CMakeLists.txt M source/blender/draw/intern/draw_manager.c M source/blender/draw/modes/edit_mesh_mode.c A source/blender/draw/modes/edit_mesh_mode_intern.h A source/blender/draw/modes/edit_mesh_mode_text.c =================================================================== diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 265993e8114..4e55e3d74f0 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -69,6 +69,7 @@ set(SRC modes/edit_curve_mode.c modes/edit_lattice_mode.c modes/edit_mesh_mode.c + modes/edit_mesh_mode_text.c modes/edit_metaball_mode.c modes/edit_surface_mode.c modes/edit_text_mode.c @@ -98,6 +99,7 @@ set(SRC intern/draw_manager_profiling.h intern/draw_view.h modes/draw_mode_engines.h + modes/edit_mesh_mode_intern.h engines/basic/basic_engine.h engines/clay/clay_engine.h engines/eevee/eevee_engine.h diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 63910321f39..36008099b70 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2573,6 +2573,10 @@ static void DRW_viewport_var_init(void) DST.backface = GL_CW; glFrontFace(DST.frontface); + if (DST.draw_ctx.scene->obedit) { + ED_view3d_init_mats_rv3d(DST.draw_ctx.scene->obedit, rv3d); + } + /* Alloc array of texture reference. */ if (RST.bound_texs == NULL) { RST.bound_texs = MEM_callocN(sizeof(GPUTexture *) * GPU_max_textures(), "Bound GPUTexture refs"); diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 08310d75a57..1a8c03e3933 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -27,12 +27,16 @@ #include "DRW_render.h" #include "GPU_shader.h" + +#include "DNA_mesh_types.h" #include "DNA_view3d_types.h" #include "draw_common.h" #include "draw_mode_engines.h" +#include "edit_mesh_mode_intern.h" /* own include */ + extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */ extern struct GlobalsUboStorage ts; /* draw_common.c */ @@ -444,6 +448,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) if (ob->type == OB_MESH) { if (ob == obedit) { + const Mesh *me = ob->data; IDProperty *ces_mode_ed = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_EDIT, ""); bool do_occlude_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ed, "show_occlude_wire"); bool do_show_weight = BKE_collection_engine_property_value_get_bool(ces_mode_ed, "show_weight"); @@ -500,6 +505,16 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) scene, ob, stl->g_data->face_overlay_shgrp, stl->g_data->ledges_overlay_shgrp, stl->g_data->lverts_overlay_shgrp, stl->g_data->facedot_overlay_shgrp, NULL); } + + /* 3D text overlay */ + if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | + ME_DRAWEXTRA_FACEAREA | + ME_DRAWEXTRA_FACEANG | + ME_DRAWEXTRA_EDGEANG)) + { + DRW_edit_mesh_mode_text_measure_stats( + draw_ctx->ar, v3d, ob, &scene->unit); + } } } } diff --git a/source/blender/draw/modes/edit_mesh_mode_intern.h b/source/blender/draw/modes/edit_mesh_mode_intern.h new file mode 100644 index 00000000000..99298bd41f4 --- /dev/null +++ b/source/blender/draw/modes/edit_mesh_mode_intern.h @@ -0,0 +1,38 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/draw/modes/edit_mesh_mode_intern.h + * \ingroup draw + */ + +#ifndef __EDIT_MESH_MODE_INTERN_H__ +#define __EDIT_MESH_MODE_INTERN_H__ + +struct ARegion; +struct Object; +struct UnitSettings; +struct View3D; + +/* edit_mesh_mode_text.c */ +void DRW_edit_mesh_mode_text_measure_stats( + struct ARegion *ar, struct View3D *v3d, + struct Object *ob, const UnitSettings *unit); + +#endif /* __EDIT_MESH_MODE_INTERN_H__ */ diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c new file mode 100644 index 00000000000..a7f461b6d1b --- /dev/null +++ b/source/blender/draw/modes/edit_mesh_mode_text.c @@ -0,0 +1,300 @@ +/* + * Copyright 2016, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Institute + * + */ + +/** \file blender/draw/modes/edit_mesh_mode_text.c + * \ingroup draw + */ + +#include "BLI_math.h" + +#include "BKE_editmesh.h" +#include "BKE_global.h" +#include "BKE_unit.h" + +#include "ED_view3d.h" + +#include "GPU_shader.h" +#include "GPU_viewport.h" + +#include "DNA_mesh_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_view3d_types.h" + +#include "UI_resources.h" + +#include "draw_manager_text.h" + +#include "edit_mesh_mode_intern.h" /* own include */ + +/* Copied from drawobject.c */ +void DRW_edit_mesh_mode_text_measure_stats( + ARegion *ar, View3D *v3d, + Object *ob, const UnitSettings *unit) +{ + /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.). + * See bug #36090. + */ + struct DRWTextStore *dt = DRW_text_cache_ensure(); + const short txt_flag = DRW_TEXT_CACHE_LOCALCLIP | (unit->system ? 0 : DRW_TEXT_CACHE_ASCII); + Mesh *me = ob->data; + BMEditMesh *em = me->edit_btmesh; + float v1[3], v2[3], v3[3], vmid[3], fvec[3]; + char numstr[32]; /* Stores the measurement display text here */ + size_t numstr_len; + const char *conv_float; /* Use a float conversion matching the grid size */ + unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */ + float area; /* area of the face */ + float grid = unit->system ? unit->scale_length : v3d->grid; + const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0; + 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 = (me->drawflag & ME_DRAWEXTRA_EDGELEN) && (me->drawflag & ME_DRAWEXTRA_EDGEANG); + const float edge_texpair_sep = 0.4f; + float clip_planes[4][4]; + /* allow for displaying shape keys and deform mods */ + BMIter iter; + + /* make the precision of the display value proportionate to the gridsize */ + + if (grid <= 0.01f) conv_float = "%.6g"; + else if (grid <= 0.1f) conv_float = "%.5g"; + else if (grid <= 1.0f) conv_float = "%.4g"; + else if (grid <= 10.0f) conv_float = "%.3g"; + else conv_float = "%.2g"; + + if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG)) { + BoundBox bb; + const rcti rect = {0, ar->winx, 0, ar->winy}; + + ED_view3d_clipping_calc(&bb, clip_planes, ar, em->ob, &rect); + } + + if (me->drawflag & ME_DRAWEXTRA_EDGELEN) { + BMEdge *eed; + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); + + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { + /* draw selected edges, or edges next to selected verts while dragging */ + if (BM_elem_flag_test(eed, BM_ELEM_SELECT) || + (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))) + { + float v1_clip[3], v2_clip[3]; + + copy_v3_v3(v1, eed->v1->co); + copy_v3_v3(v2, eed->v2->co); + + if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { + + if (do_edge_textpair) { + interp_v3_v3v3(vmid, v1, v2, edge_texpair_sep); + } + else { + mid_v3_v3v3(vmid, v1_clip, v2_clip); + } + + if (do_global) { + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); + } + + if (unit->system) { + numstr_len = bUnit_AsString( + numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3, + unit->system, B_UNIT_LENGTH, do_split, false); + } + else { + numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2)); + } + + DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, txt_flag, col); + } + } + } + } + + if (me->drawflag & ME_DRAWEXTRA_EDGEANG) { + const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS); + BMEdge *eed; + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col); + + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { + BMLoop *l_a, *l_b; + if (BM_edge_loop_pair(eed, &l_a, &l_b)) { + /* draw selected edges, or edges next to selected verts while dragging */ + if (BM_elem_flag_test(eed, BM_ELEM_SELECT) || + (do_moving && + (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) || + /* special case, this is useful to show when verts connected to + * this edge via a face are being transformed */ + BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) || + BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) || + BM_elem_flag_test(l_b->next-> @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs