diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-11-02 01:31:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-11-02 02:09:14 +0300 |
commit | b7174c9320c5e3446d8237059841d982279e32e9 (patch) | |
tree | dff0041b0846622804bd44fbd5137ddbd5996ff9 /source/blender/editors/mesh/editmesh_tools.c | |
parent | e8b8ee7d280b99f6b3d253a30822c98a3c38c2c5 (diff) |
Fix connect-vertices failing for concave ngons
Also add:
- generic callback for bmesh elements.
- ability to pass an existing array to a bmesh operator.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 20c7f4eb521..4f4a7998a87 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -877,23 +877,50 @@ static int edbm_vert_connect_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; BMOperator bmop; - const bool is_pair = (bm->totvertsel == 2); + bool is_pair = (bm->totvertsel == 2); int len; - + bool check_degenerate = true; + const int verts_len = bm->totvertsel; + BMVert **verts; + + + verts = MEM_mallocN(sizeof(*verts) * verts_len, __func__); + { + BMIter iter; + BMVert *v; + int i = 0; + + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { + verts[i++] = v; + } + } + + if (is_pair) { + if (BM_vert_pair_share_face_check_cb( + verts[0], verts[1], + BM_elem_cb_check_hflag_disabled_simple(BMFace *, BM_ELEM_HIDDEN))) + { + check_degenerate = false; + is_pair = false; + } + } + } + if (is_pair) { if (!EDBM_op_init(em, &bmop, op, - "connect_vert_pair verts=%hv verts_exclude=%hv faces_exclude=%hf", - BM_ELEM_SELECT, BM_ELEM_HIDDEN, BM_ELEM_HIDDEN)) + "connect_vert_pair verts=%eb verts_exclude=%hv faces_exclude=%hf", + verts, verts_len, BM_ELEM_HIDDEN, BM_ELEM_HIDDEN)) { - return OPERATOR_CANCELLED; + goto finally; } } else { if (!EDBM_op_init(em, &bmop, op, - "connect_verts verts=%hv faces_exclude=%hf check_degenerate=%b", - BM_ELEM_SELECT, BM_ELEM_HIDDEN, true)) + "connect_verts verts=%eb faces_exclude=%hf check_degenerate=%b", + verts, verts_len, BM_ELEM_HIDDEN, check_degenerate)) { - return OPERATOR_CANCELLED; + goto finally; } } @@ -908,15 +935,18 @@ static int edbm_vert_connect_exec(bContext *C, wmOperator *op) } if (!EDBM_op_finish(em, &bmop, op, true)) { - return OPERATOR_CANCELLED; + len = 0; } else { EDBM_selectmode_flush(em); /* so newly created edges get the selection state from the vertex */ EDBM_update_generic(em, true, true); - - return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } + + +finally: + MEM_freeN(verts); + return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void MESH_OT_vert_connect(wmOperatorType *ot) |