diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-27 03:49:13 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-27 03:49:13 +0400 |
commit | 556912792ad3c37c294256a558c96b39f264e7b5 (patch) | |
tree | 9b6ee8cf1ad92ee89c04f27a89be11599c5b40c0 /source/blender/editors/mesh | |
parent | 9251d628db0abe599d927d79170025d8545c8ace (diff) | |
parent | c84383301c5a2582e95259a7e4468a23a3566401 (diff) |
Merged changes in the trunk up to revision 54110.
Conflicts resolved:
source/blender/blenfont/SConscript
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/intern/rna_scene.c
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 81 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 41 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 30 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_slide.c | 793 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 19 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 29 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 11 |
9 files changed, 118 insertions, 888 deletions
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 3180886b2b6..b51d55aaf0e 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -48,7 +48,6 @@ set(SRC editmesh_select.c editmesh_tools.c editmesh_utils.c - editmesh_slide.c mesh_data.c mesh_ops.c meshtools.c diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 5e1d954a2ea..e49dc3c28f9 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -128,7 +128,7 @@ typedef struct KnifePosData { BMFace *bmface; int is_space; - int mval[2]; /* mouse screen position */ + float mval[2]; /* mouse screen position (may be non-integral if snapped to something) */ } KnifePosData; /* struct for properties used while drawing */ @@ -204,10 +204,10 @@ typedef struct KnifeTool_OpData { static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, BMFace *f); #if 0 -static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2], +static void knife_input_ray_cast(KnifeTool_OpData *kcd, const float mval[2], float r_origin[3], float r_ray[3]); #endif -static void knife_input_ray_segment(KnifeTool_OpData *kcd, const int mval_i[2], const float ofs, +static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], const float ofs, float r_origin[3], float r_dest[3]); static void knife_update_header(bContext *C, KnifeTool_OpData *kcd) @@ -225,6 +225,10 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd) ED_area_headerprint(CTX_wm_area(C), header); } +BLI_INLINE int round_ftoi(float x) +{ + return x > 0.0f ? (int)(x + 0.5f) : (int)(x - 0.5f); +} static void knife_project_v3(KnifeTool_OpData *kcd, const float co[3], float sco[3]) { @@ -238,8 +242,8 @@ static void knife_pos_data_clear(KnifePosData *kpd) kpd->vert = NULL; kpd->edge = NULL; kpd->bmface = NULL; - kpd->mval[0] = 0; - kpd->mval[1] = 0; + kpd->mval[0] = 0.0f; + kpd->mval[1] = 0.0f; } static ListBase *knife_empty_list(KnifeTool_OpData *kcd) @@ -1420,17 +1424,14 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) /* this works but gives numeric problems [#33400] */ #if 0 -static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2], +static void knife_input_ray_cast(KnifeTool_OpData *kcd, const float mval[2], float r_origin[3], float r_ray[3]) { bglMats mats; - float mval[2], imat[3][3]; + float imat[3][3]; knife_bgl_get_mats(kcd, &mats); - mval[0] = (float)mval_i[0]; - mval[1] = (float)mval_i[1]; - /* unproject to find view ray */ ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f); @@ -1452,23 +1453,19 @@ static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2], } #endif -static void knife_input_ray_segment(KnifeTool_OpData *kcd, const int mval_i[2], const float ofs, +static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], const float ofs, float r_origin[3], float r_origin_ofs[3]) { bglMats mats; - float mval[2]; knife_bgl_get_mats(kcd, &mats); - mval[0] = (float)mval_i[0]; - mval[1] = (float)mval_i[1]; - /* unproject to find view ray */ ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f); ED_view3d_unproject(&mats, r_origin_ofs, mval[0], mval[1], ofs); /* transform into object space */ - invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); + invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); mul_m4_v3(kcd->ob->imat, r_origin); mul_m4_v3(kcd->ob->imat, r_origin_ofs); @@ -1483,7 +1480,7 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, float co[3], float float ray[3]; /* unproject to find view ray */ - knife_input_ray_segment(kcd, kcd->vc.mval, 1.0f, origin, origin_ofs); + knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs); sub_v3_v3v3(ray, origin_ofs, origin); f = BMBVH_RayCast(kcd->bmbvh, origin, ray, co, cageco); @@ -1641,8 +1638,8 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo /* update mouse coordinates to the snapped-to edge's screen coordinates * this is important for angle snap, which uses the previous mouse position */ edgesnap = new_knife_vert(kcd, p, cagep); - kcd->curr.mval[0] = (int)edgesnap->sco[0]; - kcd->curr.mval[1] = (int)edgesnap->sco[1]; + kcd->curr.mval[0] = edgesnap->sco[0]; + kcd->curr.mval[1] = edgesnap->sco[1]; } else { @@ -1720,8 +1717,8 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo /* update mouse coordinates to the snapped-to vertex's screen coordinates * this is important for angle snap, which uses the previous mouse position */ - kcd->curr.mval[0] = (int)curv->sco[0]; - kcd->curr.mval[1] = (int)curv->sco[1]; + kcd->curr.mval[0] = curv->sco[0]; + kcd->curr.mval[1] = curv->sco[1]; } return curv; @@ -1740,48 +1737,56 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo return NULL; } +/* update both kcd->curr.mval and kcd->vc.mval to snap to required angle */ static void knife_snap_angle(KnifeTool_OpData *kcd) { - int dx, dy; + float dx, dy; float w, abs_tan; - dx = kcd->vc.mval[0] - kcd->prev.mval[0]; - dy = kcd->vc.mval[1] - kcd->prev.mval[1]; - if (dx == 0 || dy == 0) + dx = kcd->curr.mval[0] - kcd->prev.mval[0]; + dy = kcd->curr.mval[1] - kcd->prev.mval[1]; + if (dx == 0.0f && dy == 0.0f) return; - w = (float)dy / (float)dx; + if (dx == 0.0f) { + kcd->angle_snapping = ANGLE_90; + kcd->curr.mval[0] = kcd->prev.mval[0]; + } + + w = dy / dx; abs_tan = fabsf(w); if (abs_tan <= 0.4142f) { /* tan(22.5 degrees) = 0.4142 */ kcd->angle_snapping = ANGLE_0; - kcd->vc.mval[1] = kcd->prev.mval[1]; + kcd->curr.mval[1] = kcd->prev.mval[1]; } else if (abs_tan < 2.4142f) { /* tan(67.5 degrees) = 2.4142 */ if (w > 0) { kcd->angle_snapping = ANGLE_45; - kcd->vc.mval[1] = kcd->prev.mval[1] + dx; + kcd->curr.mval[1] = kcd->prev.mval[1] + dx; } else { kcd->angle_snapping = ANGLE_135; - kcd->vc.mval[1] = kcd->prev.mval[1] - dx; + kcd->curr.mval[1] = kcd->prev.mval[1] - dx; } } else { kcd->angle_snapping = ANGLE_90; - kcd->vc.mval[0] = kcd->prev.mval[0]; + kcd->curr.mval[0] = kcd->prev.mval[0]; } + + kcd->vc.mval[0] = round_ftoi(kcd->curr.mval[0]); + kcd->vc.mval[1] = round_ftoi(kcd->curr.mval[1]); } /* update active knife edge/vert pointers */ static int knife_update_active(KnifeTool_OpData *kcd) { + knife_pos_data_clear(&kcd->curr); + kcd->curr.mval[0] = (float)kcd->vc.mval[0]; + kcd->curr.mval[1] = (float)kcd->vc.mval[1]; if (kcd->angle_snapping != ANGLE_FREE && kcd->mode == MODE_DRAGGING) knife_snap_angle(kcd); - knife_pos_data_clear(&kcd->curr); - kcd->curr.mval[0] = kcd->vc.mval[0]; - kcd->curr.mval[1] = kcd->vc.mval[1]; - /* XXX knife_snap_angle updates the view coordinate mouse values to constrained angles, * which current mouse values are set to current mouse values are then used * for vertex and edge snap detection, without regard to the exact angle constraint */ @@ -1799,7 +1804,7 @@ static int knife_update_active(KnifeTool_OpData *kcd) float origin[3]; float origin_ofs[3]; - knife_input_ray_segment(kcd, kcd->vc.mval, 1.0f, origin, origin_ofs); + knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs); closest_to_line_v3(kcd->curr.cage, kcd->prev.cage, origin_ofs, origin); } @@ -2929,11 +2934,11 @@ static void cage_mapped_verts_callback(void *userData, int index, const float co } } -static void knifetool_update_mval(KnifeTool_OpData *kcd, int mval[2]) +static void knifetool_update_mval(KnifeTool_OpData *kcd, int mval_i[2]) { knife_recalc_projmat(kcd); - kcd->vc.mval[0] = mval[0]; - kcd->vc.mval[1] = mval[1]; + kcd->vc.mval[0] = mval_i[0]; + kcd->vc.mval[1] = mval_i[1]; if (knife_update_active(kcd)) { ED_region_tag_redraw(kcd->ar); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 5f923dd65c6..d1373363992 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -154,9 +154,9 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed, static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) { BMEditMesh *em = lcd->em; - BMEdge *startedge = lcd->eed; - BMEdge *eed, *lasteed; - BMVert *v[2][2], *lastv1; + BMEdge *eed_start = lcd->eed; + BMEdge *eed, *eed_last; + BMVert *v[2][2], *v_last; BMWalker walker; float (*edges)[2][3] = NULL; BLI_array_declare(edges); @@ -164,7 +164,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) memset(v, 0, sizeof(v)); - if (!startedge) + if (!eed_start) return; if (lcd->edges) { @@ -183,8 +183,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - eed = BMW_begin(&walker, startedge); - for ( ; eed; eed = BMW_step(&walker)) { + for (eed = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) { BM_edge_select_set(em->bm, eed, TRUE); } BMW_end(&walker); @@ -197,22 +196,23 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - eed = startedge = BMW_begin(&walker, startedge); - lastv1 = NULL; - for (lasteed = NULL; eed; eed = BMW_step(&walker)) { - if (lasteed) { - if (lastv1) { + v_last = NULL; + eed_last = NULL; + + for (eed = eed_start = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) { + if (eed_last) { + if (v_last) { v[1][0] = v[0][0]; v[1][1] = v[0][1]; } else { - v[1][0] = lasteed->v1; - v[1][1] = lasteed->v2; - lastv1 = lasteed->v1; + v[1][0] = eed_last->v1; + v[1][1] = eed_last->v2; + v_last = eed_last->v1; } - edgering_find_order(lasteed, eed, lastv1, v); - lastv1 = v[0][0]; + edgering_find_order(eed_last, eed, v_last, v); + v_last = v[0][0]; BLI_array_grow_items(edges, previewlines); @@ -223,18 +223,18 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) tot++; } } - lasteed = eed; + eed_last = eed; } #ifdef BMW_EDGERING_NGON if (lasteed != startedge && BM_edge_share_face_check(lasteed, startedge)) { #else - if (lasteed != startedge && BM_edge_share_quad_check(lasteed, startedge)) { + if (eed_last != eed_start && BM_edge_share_quad_check(eed_last, eed_start)) { #endif v[1][0] = v[0][0]; v[1][1] = v[0][1]; - edgering_find_order(lasteed, startedge, lastv1, v); + edgering_find_order(eed_last, eed_start, v_last, v); BLI_array_grow_items(edges, previewlines); @@ -502,7 +502,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(lcd->ar); break; - case MOUSEMOVE: { /* mouse moved somewhere to select another loop */ + case MOUSEMOVE: /* mouse moved somewhere to select another loop */ + { float dist = 75.0f; BMEdge *edge; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 38887307a76..88d826c2f98 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -995,8 +995,8 @@ static void walker_select(BMEditMesh *em, int walkercode, void *start, int selec BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - ele = BMW_begin(&walker, start); - for (; ele; ele = BMW_step(&walker)) { + + for (ele = BMW_begin(&walker, start); ele; ele = BMW_step(&walker)) { if (!select) { BM_select_history_remove(bm, ele); } @@ -1782,7 +1782,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } /* ************************************************** */ @@ -2286,8 +2286,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - efa = BMW_begin(&walker, efa); - for (; efa; efa = BMW_step(&walker)) { + for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) { BM_face_select_set(bm, efa, sel); } BMW_end(&walker); @@ -2308,8 +2307,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - e = BMW_begin(&walker, eed->v1); - for (; e; e = BMW_step(&walker)) { + for (e = BMW_begin(&walker, eed->v1); e; e = BMW_step(&walker)) { BM_edge_select_set(bm, e, sel); } BMW_end(&walker); @@ -2380,8 +2378,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - efa = BMW_begin(&walker, efa); - for (; efa; efa = BMW_step(&walker)) { + for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) { BM_face_select_set(bm, efa, TRUE); } } @@ -2409,10 +2406,8 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { - e = BMW_begin(&walker, v); - for (; e; e = BMW_step(&walker)) { - BM_vert_select_set(em->bm, e->v1, TRUE); - BM_vert_select_set(em->bm, e->v2, TRUE); + for (e = BMW_begin(&walker, v); e; e = BMW_step(&walker)) { + BM_edge_select_set(em->bm, e, true); } } } @@ -2859,6 +2854,9 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) BMEdge *e; BMIter iter; + if (!RNA_boolean_get(op->ptr, "extend")) + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + /* Selects isolated verts, and edges that do not have 2 neighboring * faces */ @@ -2898,6 +2896,9 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend the selection"); } static int edbm_select_random_exec(bContext *C, wmOperator *op) @@ -2962,8 +2963,7 @@ void MESH_OT_select_random(wmOperatorType *ot) /* props */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly", 0.f, 100.0f); - RNA_def_boolean(ot->srna, "extend", 0, - "Extend Selection", "Extend selection instead of deselecting everything first"); + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } static int edbm_select_next_loop_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c deleted file mode 100644 index eb0a21261ce..00000000000 --- a/source/blender/editors/mesh/editmesh_slide.c +++ /dev/null @@ -1,793 +0,0 @@ -/* - * ***** 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. - * - * Contributor(s): Francisco De La Cruz - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/mesh/editmesh_slide.c - * \ingroup edmesh - */ - -/* Takes heavily from editmesh_loopcut.c */ - -#include "DNA_object_types.h" -#include "DNA_mesh_types.h" - -#include "MEM_guardedalloc.h" - -#include "BLI_array.h" -#include "BLI_math.h" - -#include "BLF_translation.h" - -#include "BKE_context.h" -#include "BKE_report.h" -#include "BKE_tessmesh.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "ED_screen.h" -#include "ED_view3d.h" -#include "ED_mesh.h" -#include "ED_space_api.h" - -#include "UI_resources.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "mesh_intern.h" - -#define VTX_SLIDE_SNAP_THRSH 15 - -/* Cusom VertexSlide Operator data */ -typedef struct VertexSlideOp { - /* Starting Vertex */ - BMVert *start_vtx; - BMEdge *sel_edge; - - ViewContext *view_context; - ARegion *active_region; - - /* Draw callback handle */ - void *draw_handle; - - /* Active Object */ - Object *obj; - - /* Are we in slide mode */ - int slide_mode; - int snap_n_merge; - int snap_to_end_vtx; - int snap_to_mid; - - /* Snap threshold */ - float snap_threshold; - - float distance; - float interp[3]; - - /* Edge Frame Count */ - int disk_edges; - - /* Edges */ - BMEdge **edge_frame; - - /* Slide Frame Endpoints */ - float (*vtx_frame)[3]; - - /* Mouse Click 2d pos */ - int m_co[2]; - -} VertexSlideOp; - -static void vtx_slide_draw(const bContext *C, ARegion *ar, void *arg); -static int edbm_vertex_slide_exec_ex(bContext *C, wmOperator *op, const int do_update); -static void vtx_slide_exit(const bContext *C, wmOperator *op); -static int vtx_slide_set_frame(VertexSlideOp *vso); - -static int vtx_slide_init(bContext *C, wmOperator *op) -{ - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BMEdit_FromObject(obedit); - BMEditSelection *ese; - - /* Custom data */ - VertexSlideOp *vso; - - const char *header_str = TIP_("Vertex Slide: Hover over an edge and left-click to select slide edge. " - "Left-Shift: Midpoint Snap, Left-Alt: Snap, Left-Ctrl: Snap & Merge"); - - if (!obedit) { - BKE_report(op->reports, RPT_ERROR, "Vertex slide error: no object in context"); - return FALSE; - } - - EDBM_selectmode_flush(em); - ese = em->bm->selected.last; - - /* Is there a starting vertex ? */ - if (ese == NULL || (ese->htype != BM_VERT && ese->htype != BM_EDGE)) { - BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex slide error: select a (single) vertex"); - return FALSE; - } - - vso = MEM_callocN(sizeof(VertexSlideOp), "Vertex Slide Operator"); - vso->view_context = MEM_callocN(sizeof(ViewContext), "Vertex Slide View Context"); - - op->customdata = vso; - - /* Set the start vertex */ - vso->start_vtx = (BMVert *)ese->ele; - - vso->sel_edge = NULL; - - /* Edges */ - vso->edge_frame = NULL; - - vso->vtx_frame = NULL; - - vso->disk_edges = 0; - - vso->slide_mode = FALSE; - - vso->snap_n_merge = FALSE; - - vso->snap_to_end_vtx = FALSE; - - vso->snap_to_mid = FALSE; - - vso->distance = 0.0f; - - vso->snap_threshold = 0.2f; - - /* Notify the viewport */ - view3d_operator_needs_opengl(C); - - /* Set the drawing region */ - vso->active_region = CTX_wm_region(C); - - /* Set the draw callback */ - vso->draw_handle = ED_region_draw_cb_activate(vso->active_region->type, vtx_slide_draw, vso, REGION_DRAW_POST_VIEW); - - ED_area_headerprint(CTX_wm_area(C), header_str); - - em_setup_viewcontext(C, vso->view_context); - - /* Set the object */ - vso->obj = obedit; - - /* Init frame */ - if (!vtx_slide_set_frame(vso)) { - BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex slide error: cannot find starting vertex!"); - vtx_slide_exit(C, op); - return FALSE; - } - - /* Add handler for the vertex sliding */ - WM_event_add_modal_handler(C, op); - - /* Tag for redraw */ - ED_region_tag_redraw(vso->active_region); - - return TRUE; -} - -static void vtx_slide_confirm(bContext *C, wmOperator *op) -{ - VertexSlideOp *vso = op->customdata; - BMEditMesh *em = BMEdit_FromObject(vso->obj); - BMesh *bm = em->bm; - BMVert *other = NULL; - - BMVert *mirr_vtx = NULL; - BMVert *mirr_vtx_other = NULL; - - /* Select new edge */ - BM_edge_select_set(bm, vso->sel_edge, TRUE); - - if (vso->snap_n_merge) { - other = BM_edge_other_vert(vso->sel_edge, vso->start_vtx); - } - - if (((Mesh *)em->ob->data)->editflag & ME_EDIT_MIRROR_X) { - EDBM_verts_mirror_cache_begin(em, TRUE); - - mirr_vtx = EDBM_verts_mirror_get(em, vso->start_vtx); - if (vso->snap_n_merge) { - mirr_vtx_other = EDBM_verts_mirror_get(em, other); - } - } - - /* Invoke operator - warning */ - edbm_vertex_slide_exec_ex(C, op, FALSE); - - if (mirr_vtx) { - mirr_vtx->co[0] = -vso->start_vtx->co[0]; - mirr_vtx->co[1] = vso->start_vtx->co[1]; - mirr_vtx->co[2] = vso->start_vtx->co[2]; - } - - if (vso->snap_n_merge) { - float other_d; - other_d = len_v3v3(vso->interp, other->co); - - /* Only snap if within threshold */ - if (other_d < vso->snap_threshold) { - BM_vert_select_set(bm, other, TRUE); - BM_vert_select_set(bm, vso->start_vtx, TRUE); - EDBM_op_callf(em, op, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, other->co); - EDBM_flag_disable_all(em, BM_ELEM_SELECT); - - if (mirr_vtx_other) { - BM_vert_select_set(bm, mirr_vtx, TRUE); - BM_vert_select_set(bm, mirr_vtx_other, TRUE); - EDBM_op_callf(em, op, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mirr_vtx_other->co); - EDBM_flag_disable_all(em, BM_ELEM_SELECT); - } - } - else { - /* Store in historty if not merging */ - BM_select_history_store(em->bm, vso->start_vtx); - } - } - else { - /* Store edit selection of the active vertex, allows other - * ops to run without reselecting */ - BM_select_history_store(em->bm, vso->start_vtx); - } - - if (((Mesh *)em->ob->data)->editflag & ME_EDIT_MIRROR_X) { - EDBM_verts_mirror_cache_end(em); - } - - EDBM_selectmode_flush(em); - - /* NC_GEOM | ND_DATA & Retess */ - EDBM_update_generic(em, TRUE, FALSE); - - ED_region_tag_redraw(vso->active_region); -} - -static void vtx_slide_exit(const bContext *C, wmOperator *op) -{ - /* Fetch custom data */ - VertexSlideOp *vso = op->customdata; - - /* Clean-up the custom data */ - ED_region_draw_cb_exit(vso->active_region->type, vso->draw_handle); - - /* Free Custom Data - * - */ - MEM_freeN(vso->view_context); - - vso->view_context = NULL; - - if (vso->edge_frame) { - MEM_freeN(vso->edge_frame); - } - - if (vso->vtx_frame) { - MEM_freeN(vso->vtx_frame); - } - - vso->edge_frame = NULL; - - vso->vtx_frame = NULL; - - vso->slide_mode = FALSE; - - MEM_freeN(vso); - vso = NULL; - op->customdata = NULL; - - /* Clear the header */ - ED_area_headerprint(CTX_wm_area(C), NULL); -} - -static void vtx_slide_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) -{ - VertexSlideOp *vso = arg; - - /* Have an edge to draw */ - if (vso && vso->sel_edge) { - /* Get 3d view */ - View3D *view3d = CTX_wm_view3d(C); - const float outline_w = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.8f; - const float pt_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; - - int i = 0; - - if (view3d && view3d->zbuf) - glDisable(GL_DEPTH_TEST); - - glPushAttrib(GL_CURRENT_BIT | GL_LINE_BIT | GL_POINT_BIT); - - glPushMatrix(); - glMultMatrixf(vso->obj->obmat); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - - if (vso->slide_mode && vso->disk_edges > 0) { - /* Draw intermediate edge frame */ - UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 50, -50); - - for (i = 0; i < vso->disk_edges; i++) { - glBegin(GL_LINES); - glVertex3fv(vso->vtx_frame[i]); - glVertex3fv(vso->interp); - glEnd(); - } - } - - /* Draw selected edge - * Add color offset and reduce alpha */ - UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 40, -50); - - glLineWidth(outline_w); - - glBegin(GL_LINES); - bglVertex3fv(vso->sel_edge->v1->co); - bglVertex3fv(vso->sel_edge->v2->co); - glEnd(); - - if (vso->slide_mode) { - /* Draw interpolated vertex */ - - UI_ThemeColorShadeAlpha(TH_FACE_DOT, -80, -50); - - glPointSize(pt_size); - - bglBegin(GL_POINTS); - bglVertex3fv(vso->interp); - bglEnd(); - } - - glDisable(GL_BLEND); - glPopMatrix(); - glPopAttrib(); - - if (view3d && view3d->zbuf) - glEnable(GL_DEPTH_TEST); - } -} - -static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2]) -{ - BMEdge *cl_edge = NULL; - if (vso->disk_edges > 0) { - int i = 0; - BMEdge *edge = NULL; - - float v1_proj[3], v2_proj[3]; - float min_dist = FLT_MAX; - - for (i = 0; i < vso->disk_edges; i++) { - edge = vso->edge_frame[i]; - - mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co); - mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co); - - /* we could use ED_view3d_project_float_object here, but for now dont since we dont have the context */ - if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && - (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) - { - const float dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj); - if (dist < min_dist) { - min_dist = dist; - cl_edge = edge; - } - } - } - } - return cl_edge; -} - -static void vtx_slide_find_edge(VertexSlideOp *vso, wmEvent *event) -{ - /* Nearest edge */ - BMEdge *nst_edge = NULL; - - const float mval_float[2] = {(float)event->mval[0], - (float)event->mval[1]}; - - /* Set mouse coords */ - copy_v2_v2_int(vso->view_context->mval, event->mval); - - /* Find nearest edge */ - nst_edge = vtx_slide_nrst_in_frame(vso, mval_float); - - if (nst_edge) { - /* Find a connected edge */ - if (BM_vert_in_edge(nst_edge, vso->start_vtx)) { - - /* Save mouse coords */ - copy_v2_v2_int(vso->m_co, event->mval); - - /* Set edge */ - vso->sel_edge = nst_edge; - } - } -} - -/* Updates the status of the operator - Invoked on mouse movement */ -static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event) -{ - BMEdge *edge; - - /* Find nearest edge */ - edge = vso->sel_edge; - - if (edge) { - float edge_other_proj[3]; - float start_vtx_proj[3]; - float edge_len; - BMVert *other; - - float interp[3]; - - /* Calculate interpolation value for preview */ - float t_val; - - float mval_float[2] = { (float)event->mval[0], (float)event->mval[1]}; - float closest_2d[2]; - - other = BM_edge_other_vert(edge, vso->start_vtx); - - /* Project points onto screen and do interpolation in 2D */ - mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co); - mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co); - - if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) || - (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK)) - { - /* not much we can do here */ - return; - } - - closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj); - - t_val = line_point_factor_v2(closest_2d, start_vtx_proj, edge_other_proj); - - /* Set snap threshold to be proportional to edge length */ - edge_len = len_v3v3(start_vtx_proj, edge_other_proj); - - if (edge_len <= 0.0f) - edge_len = VTX_SLIDE_SNAP_THRSH; - - edge_len = (BM_edge_calc_length(edge) * VTX_SLIDE_SNAP_THRSH) / edge_len; - - vso->snap_threshold = edge_len; - - /* Snap to mid */ - if (vso->snap_to_mid) { - t_val = 0.5f; - } - - /* Interpolate preview vertex 3D */ - interp_v3_v3v3(interp, vso->start_vtx->co, other->co, t_val); - copy_v3_v3(vso->interp, interp); - - vso->distance = t_val; - - /* If snapping */ - if (vso->snap_to_end_vtx) { - int start_at_v1 = edge->v1 == vso->start_vtx; - float v1_d = len_v3v3(vso->interp, edge->v1->co); - float v2_d = len_v3v3(vso->interp, edge->v2->co); - - if (v1_d > v2_d && v2_d < vso->snap_threshold) { - copy_v3_v3(vso->interp, edge->v2->co); - - if (start_at_v1) - vso->distance = 1.0f; - else - vso->distance = 0.0f; - } - if (v2_d > v1_d && v1_d < vso->snap_threshold) { - copy_v3_v3(vso->interp, edge->v1->co); - if (start_at_v1) - vso->distance = 0.0f; - else - vso->distance = 1.0f; - } - } - } -} - -/* Sets the outline frame */ -static int vtx_slide_set_frame(VertexSlideOp *vso) -{ - BMEdge *edge; - float (*vtx_frame)[3] = NULL; - BMEdge **edge_frame = NULL; - BMVert *curr_vert = NULL; - BLI_array_declare(vtx_frame); - BLI_array_declare(edge_frame); - BMIter iter; - BMVert *sel_vtx = vso->start_vtx; - int idx = 0; - - vso->disk_edges = 0; - - if (vso->edge_frame) { - MEM_freeN(vso->edge_frame); - vso->edge_frame = NULL; - } - - if (vso->vtx_frame) { - MEM_freeN(vso->vtx_frame); - vso->vtx_frame = NULL; - } - - /* Iterate over edges of vertex and copy them */ - BM_ITER_ELEM_INDEX (edge, &iter, sel_vtx, BM_EDGES_OF_VERT, idx) { - curr_vert = BM_edge_other_vert(edge, sel_vtx); - if (curr_vert) { - BLI_array_grow_one(vtx_frame); - - copy_v3_v3(vtx_frame[idx], curr_vert->co); - - BLI_array_append(edge_frame, edge); - vso->disk_edges++; - } - } - - vso->edge_frame = edge_frame; - vso->vtx_frame = vtx_frame; - - /* Set the interp at starting vtx */ - copy_v3_v3(vso->interp, sel_vtx->co); - - return vso->disk_edges > 0; -} - -static int edbm_vertex_slide_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - VertexSlideOp *vso = op->customdata; - char buff[128]; - - if (!vso) - return OPERATOR_CANCELLED; - - /* Notify the viewport */ - view3d_operator_needs_opengl(C); - - switch (event->type) { - case LEFTSHIFTKEY: - { - switch (event->val) { - case KM_PRESS: - vso->snap_to_mid = TRUE; - break; - case KM_RELEASE: - vso->snap_to_mid = FALSE; - break; - } - - break; - } - case LEFTCTRLKEY: - { - switch (event->val) { - case KM_PRESS: - vso->snap_n_merge = TRUE; - vso->snap_to_end_vtx = TRUE; - break; - case KM_RELEASE: - vso->snap_n_merge = FALSE; - vso->snap_to_end_vtx = FALSE; - break; - } - - break; - } - case LEFTALTKEY: - { - switch (event->val) { - case KM_PRESS: - vso->snap_to_end_vtx = TRUE; - break; - case KM_RELEASE: - vso->snap_to_end_vtx = FALSE; - break; - } - - break; - } - case RIGHTMOUSE: - case ESCKEY: - { - /* Enforce redraw */ - ED_region_tag_redraw(vso->active_region); - - /* Clean-up */ - vtx_slide_exit(C, op); - - return OPERATOR_CANCELLED; - } - case LEFTMOUSE: - { - if (event->val == KM_PRESS) { - /* Update mouse coords */ - copy_v2_v2_int(vso->m_co, event->mval); - - if (vso->slide_mode) { - vtx_slide_confirm(C, op); - /* Clean-up */ - vtx_slide_exit(C, op); - return OPERATOR_FINISHED; - } - else if (vso->sel_edge) { - vso->slide_mode = TRUE; - } - } - - ED_region_tag_redraw(vso->active_region); - break; - - } - case MOUSEMOVE: - { - sprintf(buff, "Vertex Slide: %f", vso->distance); - if (!vso->slide_mode) { - vtx_slide_find_edge(vso, event); - } - else { - vtx_slide_update(vso, event); - } - ED_area_headerprint(CTX_wm_area(C), buff); - ED_region_tag_redraw(vso->active_region); - break; - } - } - - return OPERATOR_RUNNING_MODAL; -} - -static int edbm_vertex_slide_cancel(bContext *C, wmOperator *op) -{ - /* Exit the modal */ - vtx_slide_exit(C, op); - - return OPERATOR_CANCELLED; -} - -static int edbm_vertex_slide_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - /* Initialize the operator */ - if (vtx_slide_init(C, op)) - return OPERATOR_RUNNING_MODAL; - else - return OPERATOR_CANCELLED; -} - -/* Vertex Slide */ -static int edbm_vertex_slide_exec_ex(bContext *C, wmOperator *op, const int do_update) -{ - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BMEdit_FromObject(obedit); - BMesh *bm = em->bm; - BMVert *start_vert; - BMOperator bmop; - BMEditSelection *ese = (BMEditSelection *)em->bm->selected.last; - - float factor = 0.0f; - - /* Invoked modally? */ - if (op->type->modal == edbm_vertex_slide_modal && op->customdata) { - VertexSlideOp *vso = (VertexSlideOp *)op->customdata; - - if (bm->totedgesel > 1) { - /* Reset selections */ - EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BM_edge_select_set(bm, vso->sel_edge, TRUE); - BM_vert_select_set(bm, vso->start_vtx, TRUE); - - BM_select_history_store(em->bm, vso->sel_edge); - BM_select_history_store(em->bm, vso->start_vtx); - ese = (BMEditSelection *)em->bm->selected.last; - } - factor = vso->distance; - RNA_float_set(op->ptr, "factor", factor); - } - else { - /* Get Properties */ - factor = RNA_float_get(op->ptr, "factor"); - } - - /* Is there a starting vertex ? */ - if ((ese == NULL) || (ese->htype != BM_VERT && ese->htype != BM_EDGE)) { - BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Vertex slide error: select a (single) vertex"); - return OPERATOR_CANCELLED; - } - - start_vert = (BMVert *)ese->ele; - - /* Prepare operator */ - if (!EDBM_op_init(em, &bmop, op, - "slide_vert vert=%e edges=%he factor=%f", - start_vert, BM_ELEM_SELECT, factor)) - { - return OPERATOR_CANCELLED; - } - /* Execute operator */ - BMO_op_exec(bm, &bmop); - - /* Deselect the input edges */ - BMO_slot_buffer_hflag_disable(bm, bmop.slots_in, "edges", BM_EDGE, BM_ELEM_SELECT, TRUE); - - /* Select the output vert */ - BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, TRUE); - - /* Flush the select buffers */ - EDBM_selectmode_flush(em); - - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { - return OPERATOR_CANCELLED; - } - - if (do_update) { - /* Update Geometry */ - EDBM_update_generic(em, TRUE, FALSE); - } - - return OPERATOR_FINISHED; -} - -#if 0 -static int edbm_vertex_slide_exec(bContext *C, wmOperator *op) -{ - return edbm_vertex_slide_exec_ex(C, op, TRUE); -} -#endif - -void MESH_OT_vert_slide(wmOperatorType *ot) -{ - PropertyRNA *prop; - - /* identifiers */ - ot->name = "Vertex Slide"; - ot->idname = "MESH_OT_vert_slide"; - ot->description = "Vertex slide"; - - /* api callback */ - ot->invoke = edbm_vertex_slide_invoke; - ot->modal = edbm_vertex_slide_modal; - ot->cancel = edbm_vertex_slide_cancel; - ot->poll = ED_operator_editmesh_region_view3d; - - /* ot->exec = edbm_vertex_slide_exec; - * ot->poll = ED_operator_editmesh; */ - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* Properties for vertex slide */ - prop = RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "Distance", -5.0f, 5.0f); - RNA_def_property_ui_range(prop, -5.0f, 5.0f, 0.1, 4); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); -} diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 27c68ce21bc..b411cd2bd27 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -387,7 +387,7 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, if (ele->head.htype == BM_FACE) { f = (BMFace *)ele; add_normal_aligned(nor, f->no); - }; + } } normalize_v3(nor); @@ -3190,8 +3190,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *base_old, BMesh BMW_FLAG_NOP, BMW_NIL_LAY); - e = BMW_begin(&walker, v_seed); - for (; e; e = BMW_step(&walker)) { + for (e = BMW_begin(&walker, v_seed); e; e = BMW_step(&walker)) { if (!BM_elem_flag_test(e->v1, BM_ELEM_TAG)) { BM_elem_flag_enable(e->v1, BM_ELEM_TAG); tot++; } if (!BM_elem_flag_test(e->v2, BM_ELEM_TAG)) { BM_elem_flag_enable(e->v2, BM_ELEM_TAG); tot++; } } @@ -3838,6 +3837,9 @@ static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op) const int numverts = RNA_int_get(op->ptr, "number"); const int type = RNA_enum_get(op->ptr, "type"); + if (!RNA_boolean_get(op->ptr, "extend")) + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { int select; @@ -3897,9 +3899,10 @@ void MESH_OT_select_face_by_sides(wmOperatorType *ot) /* properties */ RNA_def_int(ot->srna, "number", 4, 3, INT_MAX, "Number of Vertices", "", 3, INT_MAX); RNA_def_enum(ot->srna, "type", type_items, 1, "Type", "Type of comparison to make"); + RNA_def_boolean(ot->srna, "extend", TRUE, "Extend", "Extend the selection"); } -static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) +static int edbm_select_loose_verts_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); @@ -3907,6 +3910,9 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) BMEdge *eed; BMIter iter; + if (!RNA_boolean_get(op->ptr, "extend")) + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!eve->e) { BM_vert_select_set(em->bm, eve, TRUE); @@ -3938,6 +3944,9 @@ void MESH_OT_select_loose_verts(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } static int edbm_select_mirror_exec(bContext *C, wmOperator *op) @@ -4593,7 +4602,7 @@ static int edbm_noise_exec(bContext *C, wmOperator *op) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { float tin, dum; - externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum, 0); + externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum, 0, NULL); eve->co[2] += fac * tin; } } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index b95c8a05353..d62eba9728c 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -682,8 +682,10 @@ void undo_push_mesh(bContext *C, const char *name) undo_editmode_push(C, name, getEditMesh, free_undo, undoMesh_to_editbtMesh, editbtMesh_to_undoMesh, NULL); } -/* write comment here */ -UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, const float limit[2]) +/** + * Return a new UVVertMap from the editmesh + */ +UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float limit[2]) { BMVert *ev; BMFace *efa; @@ -696,6 +698,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, const float lim MLoopUV *luv; unsigned int a; int totverts, i, totuv; + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); @@ -704,8 +707,9 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, const float lim /* generate UvMapVert array */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!selected || ((!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) && BM_elem_flag_test(efa, BM_ELEM_SELECT))) + if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { totuv += efa->len; + } } if (totuv == 0) { @@ -726,7 +730,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, const float lim a = 0; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!selected || ((!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) && BM_elem_flag_test(efa, BM_ELEM_SELECT))) { + if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { i = 0; BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { buf->tfindex = i; @@ -761,7 +765,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, const float lim /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ l = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa, v->tfindex); - luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv = luv->uv; lastv = NULL; @@ -773,7 +777,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, const float lim /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ l = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex); - luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; sub_v2_v2v2(uvdiff, uv2, uv); @@ -831,6 +835,8 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, int selected, int do_is BMFace **stack; int stacksize = 0; + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); totverts = em->bm->totvert; @@ -843,8 +849,9 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, int selected, int do_is /* generate UvElement array */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!selected || ((!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) && BM_elem_flag_test(efa, BM_ELEM_SELECT))) + if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { totuv += efa->len; + } } if (totuv == 0) { @@ -869,7 +876,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, int selected, int do_is j = 0; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { island_number[j++] = INVALID_ISLAND; - if (!selected || ((!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) && BM_elem_flag_test(efa, BM_ELEM_SELECT))) { + if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { buf->l = l; buf->separate = 0; @@ -898,7 +905,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, int selected, int do_is newvlist = v; l = v->l; - luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv = luv->uv; lastv = NULL; @@ -908,7 +915,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, int selected, int do_is next = iterv->next; l = iterv->l; - luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; sub_v2_v2v2(uvdiff, uv2, uv); @@ -1339,7 +1346,7 @@ void EDBM_mesh_reveal(BMEditMesh *em) /* so many tools call these that we better make it a generic function. */ -void EDBM_update_generic(BMEditMesh *em, const short do_tessface, const short is_destructive) +void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_destructive) { Object *ob = em->ob; /* order of calling isn't important */ diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 790a7eae487..fe4917acdac 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -216,7 +216,6 @@ void MESH_OT_bevel(struct wmOperatorType *ot); void MESH_OT_bridge_edge_loops(struct wmOperatorType *ot); void MESH_OT_inset(struct wmOperatorType *ot); void MESH_OT_wireframe(struct wmOperatorType *ot); -void MESH_OT_vert_slide(struct wmOperatorType *ot); void MESH_OT_convex_hull(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 372d6feec0c..9403299b0cd 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -154,7 +154,6 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_solidify); WM_operatortype_append(MESH_OT_select_nth); WM_operatortype_append(MESH_OT_vert_connect); - WM_operatortype_append(MESH_OT_vert_slide); WM_operatortype_append(MESH_OT_knife_tool); WM_operatortype_append(MESH_OT_bevel); @@ -269,10 +268,14 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "Mesh", 0, 0); keymap->poll = ED_operator_editmesh; - WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "vertex_only", FALSE); + kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "vertex_only", TRUE); + /* selecting */ /* standard mouse selection goes via space_view3d */ kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); @@ -366,7 +369,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_vert_connect", JKEY, KM_PRESS, 0, 0); /* Vertex Slide */ - WM_keymap_add_item(keymap, "MESH_OT_vert_slide", VKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "TRANSFORM_OT_vert_slide", VKEY, KM_PRESS, KM_SHIFT, 0); /* use KM_CLICK because same key is used for tweaks */ kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "rotate_source", TRUE); |