diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 23 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.h | 6 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_inset.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_split_edges.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_edgesplit.c | 8 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_edgesplit.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_rip.c | 32 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_edgesplit.c | 2 |
8 files changed, 34 insertions, 45 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 51461190233..b296c367575 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -1915,7 +1915,8 @@ bool BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target) * * \return Success */ -void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len) +void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len, + const bool copy_select) { const int v_edgetot = BM_vert_face_count(v); BMEdge **stack = BLI_array_alloca(stack, v_edgetot); @@ -1970,6 +1971,9 @@ void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len verts[0] = v; for (i = 1; i < maxindex; i++) { verts[i] = BM_vert_create(bm, v->co, v, 0); + if (copy_select) { + BM_elem_select_copy(bm, bm, verts[i], v); + } } /* Replace v with the new verts in each group */ @@ -2052,11 +2056,11 @@ void BM_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len, for (i = 0; i < e_in_len; i++) { BMEdge *e = e_in[i]; if (e->l && BM_vert_in_edge(e, v)) { - bmesh_edge_separate(bm, e, e->l); + bmesh_edge_separate(bm, e, e->l, false); } } - bmesh_vert_separate(bm, v, r_vout, r_vout_len); + bmesh_vert_separate(bm, v, r_vout, r_vout_len, false); } /** @@ -2112,7 +2116,8 @@ bool BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *e_target) * \note Does nothing if \a l_sep is already the only loop in the * edge radial. */ -void bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep) +void bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep, + const bool copy_select) { BMEdge *e_new; #ifndef NDEBUG @@ -2136,6 +2141,10 @@ void bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep) bmesh_radial_append(e_new, l_sep); l_sep->e = e_new; + if (copy_select) { + BM_elem_select_copy(bm, bm, e_new, e); + } + BLI_assert(bmesh_radial_length(e->l) == radlen - 1); BLI_assert(bmesh_radial_length(e_new->l) == 1); @@ -2159,8 +2168,8 @@ BMVert *bmesh_urmv_loop(BMesh *bm, BMLoop *l_sep) /* peel the face from the edge radials on both sides of the * loop vert, disconnecting the face from its fan */ - bmesh_edge_separate(bm, l_sep->e, l_sep); - bmesh_edge_separate(bm, l_sep->prev->e, l_sep->prev); + bmesh_edge_separate(bm, l_sep->e, l_sep, false); + bmesh_edge_separate(bm, l_sep->prev->e, l_sep->prev, false); if (bmesh_disk_count(v_sep) == 2) { /* If there are still only two edges out of v_sep, then @@ -2178,7 +2187,7 @@ BMVert *bmesh_urmv_loop(BMesh *bm, BMLoop *l_sep) /* Split all fans connected to the vert, duplicating it for * each fans. */ - bmesh_vert_separate(bm, v_sep, &vtar, &len); + bmesh_vert_separate(bm, v_sep, &vtar, &len, false); /* There should have been at least two fans cut apart here, * otherwise the early exit would have kicked in. */ diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h index ea25a5c3ee7..c9e806335dd 100644 --- a/source/blender/bmesh/intern/bmesh_core.h +++ b/source/blender/bmesh/intern/bmesh_core.h @@ -50,11 +50,13 @@ void BM_face_kill(BMesh *bm, BMFace *f); void BM_edge_kill(BMesh *bm, BMEdge *e); void BM_vert_kill(BMesh *bm, BMVert *v); -void bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep); +void bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep, + const bool copy_select); bool BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *e_target); bool BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target); -void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len); +void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len, + const bool copy_select); bool bmesh_loop_reverse(BMesh *bm, BMFace *f); diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 60fdf075d18..a7b98cda2b3 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -457,7 +457,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) /* run the separate arg */ - bmesh_edge_separate(bm, es->e_old, es->l); + bmesh_edge_separate(bm, es->e_old, es->l, false); /* calc edge-split info */ es->e_new = es->l->e; @@ -535,7 +535,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) /* disable touching twice, this _will_ happen if the flags not disabled */ BM_elem_flag_disable(v, BM_ELEM_TAG); - bmesh_vert_separate(bm, v, &vout, &r_vout_len); + bmesh_vert_separate(bm, v, &vout, &r_vout_len, false); v = NULL; /* don't use again */ /* in some cases the edge doesn't split off */ diff --git a/source/blender/bmesh/operators/bmo_split_edges.c b/source/blender/bmesh/operators/bmo_split_edges.c index c0847930422..88c1c3dca44 100644 --- a/source/blender/bmesh/operators/bmo_split_edges.c +++ b/source/blender/bmesh/operators/bmo_split_edges.c @@ -48,7 +48,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) } /* this is where everything happens */ - BM_mesh_edgesplit(bm, use_verts, true); + BM_mesh_edgesplit(bm, use_verts, true, false); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_INTERNAL_TAG); } diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.c b/source/blender/bmesh/tools/bmesh_edgesplit.c index 3ae5c712f0a..adcf325b51c 100644 --- a/source/blender/bmesh/tools/bmesh_edgesplit.c +++ b/source/blender/bmesh/tools/bmesh_edgesplit.c @@ -98,7 +98,7 @@ static void bm_edgesplit_validate_seams(BMesh *bm) MEM_freeN(vtouch); } -void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only) +void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, const bool copy_select) { BMIter iter; BMEdge *e; @@ -136,7 +136,7 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only) /* keep splitting until each loop has its own edge */ do { - bmesh_edge_separate(bm, e, e->l); + bmesh_edge_separate(bm, e, e->l, copy_select); } while (!BM_edge_is_boundary(e)); BM_elem_flag_enable(e->v1, BM_ELEM_TAG); @@ -159,11 +159,11 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only) if (BM_elem_flag_test(e, BM_ELEM_TAG)) { if (BM_elem_flag_test(e->v1, BM_ELEM_TAG)) { BM_elem_flag_disable(e->v1, BM_ELEM_TAG); - bmesh_vert_separate(bm, e->v1, NULL, NULL); + bmesh_vert_separate(bm, e->v1, NULL, NULL, copy_select); } if (BM_elem_flag_test(e->v2, BM_ELEM_TAG)) { BM_elem_flag_disable(e->v2, BM_ELEM_TAG); - bmesh_vert_separate(bm, e->v2, NULL, NULL); + bmesh_vert_separate(bm, e->v2, NULL, NULL, copy_select); } } } diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.h b/source/blender/bmesh/tools/bmesh_edgesplit.h index 8c1231dd794..bd66f6a9e2f 100644 --- a/source/blender/bmesh/tools/bmesh_edgesplit.h +++ b/source/blender/bmesh/tools/bmesh_edgesplit.h @@ -27,6 +27,6 @@ * \ingroup bmesh */ -void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only); +void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, const bool copy_select); #endif /* __BMESH_EDGESPLIT_H__ */ diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 1128d705e47..253aef7d5fe 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -50,6 +50,8 @@ #include "ED_transform.h" #include "ED_view3d.h" +#include "tools/bmesh_edgesplit.h" + #include "mesh_intern.h" /* own include */ /** @@ -510,24 +512,6 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u /* --- end 'face-fill' code --- */ - -static bool edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) -{ - BMOperator bmop; - - if (!EDBM_op_init(em, &bmop, op, "split_edges edges=%he verts=%hv use_verts=%b", - BM_ELEM_TAG, BM_ELEM_SELECT, true)) - { - return false; - } - BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, true)) { - return false; - } - - return true; -} - /** * This is the main vert ripping function (rip when one vertex is selected) */ @@ -648,7 +632,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve BM_vert_select_set(bm, v, false); - bmesh_vert_separate(bm, v, &vout, &vout_len); + bmesh_vert_separate(bm, v, &vout, &vout_len, true); if (vout_len < 2) { MEM_freeN(vout); @@ -784,10 +768,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve fill_uloop_pairs = edbm_tagged_loop_pairs_to_fill(bm); } - if (!edbm_rip_call_edgesplit(em, op)) { - if (fill_uloop_pairs) MEM_freeN(fill_uloop_pairs); - return OPERATOR_CANCELLED; - } + BM_mesh_edgesplit(em->bm, true, true, true); } dist = FLT_MAX; @@ -949,10 +930,7 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve fill_uloop_pairs = edbm_tagged_loop_pairs_to_fill(bm); } - if (!edbm_rip_call_edgesplit(em, op)) { - if (fill_uloop_pairs) MEM_freeN(fill_uloop_pairs); - return OPERATOR_CANCELLED; - } + BM_mesh_edgesplit(em->bm, true, true, true); /* note: the output of the bmesh operator is ignored, since we built * the contiguous loop pairs to split already, its possible that some diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index e37fc56d08c..d79360c58ef 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -91,7 +91,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) } } - BM_mesh_edgesplit(bm, FALSE, TRUE); + BM_mesh_edgesplit(bm, false, true, false); /* BM_mesh_validate(bm); */ /* for troubleshooting */ |