fix bug with editmesh rip, active edge could be left on the unselected side of the edge loops.

This commit is contained in:
Campbell Barton
2013-08-14 09:14:33 +00:00
parent 731672fc9b
commit 7d67261a7b
2 changed files with 61 additions and 10 deletions

View File

@@ -103,6 +103,21 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, con
BMIter iter;
BMEdge *e;
bool use_ese = false;
GHash *ese_gh = NULL;
if (copy_select && bm->selected.first) {
BMEditSelection *ese;
ese_gh = BLI_ghash_ptr_new(__func__);
for (ese = bm->selected.first; ese; ese = ese->next) {
if (ese->htype != BM_FACE) {
BLI_ghash_insert(ese_gh, ese->ele, ese);
}
}
use_ese = true;
}
if (tag_only == false) {
BM_mesh_elem_hflag_enable_all(bm, BM_EDGE | (use_verts ? BM_VERT : 0), BM_ELEM_TAG, false);
@@ -135,9 +150,18 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, con
BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG);
/* keep splitting until each loop has its own edge */
do {
bmesh_edge_separate(bm, e, e->l, copy_select);
} while (!BM_edge_is_boundary(e));
while (!BM_edge_is_boundary(e)) {
BMLoop *l_sep = e->l;
bmesh_edge_separate(bm, e, l_sep, copy_select);
BLI_assert(l_sep->e != e);
if (use_ese) {
BMEditSelection *ese = BLI_ghash_lookup(ese_gh, e);
if (UNLIKELY(ese)) {
BM_select_history_store_after_notest(bm, ese, l_sep->e);
}
}
}
BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
@@ -157,14 +181,39 @@ void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, con
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
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, 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, copy_select);
unsigned int i;
for (i = 0; i < 2; i++) {
BMVert *v = ((&e->v1)[i]);
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
BM_elem_flag_disable(v, BM_ELEM_TAG);
if (use_ese) {
BMVert **vtar;
int vtar_len;
bmesh_vert_separate(bm, v, &vtar, &vtar_len, copy_select);
if (vtar_len) {
BMEditSelection *ese = BLI_ghash_lookup(ese_gh, v);
if (UNLIKELY(ese)) {
int j;
for (j = 0; j < vtar_len; j++) {
BLI_assert(v != vtar[j]);
BM_select_history_store_after_notest(bm, ese, vtar[j]);
}
}
}
MEM_freeN(vtar);
}
else {
bmesh_vert_separate(bm, v, NULL, NULL, copy_select);
}
}
}
}
}
if (use_ese) {
BLI_ghash_free(ese_gh, NULL, NULL);
}
}

View File

@@ -952,6 +952,8 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve
return OPERATOR_CANCELLED;
}
BM_select_history_validate(bm);
return OPERATOR_FINISHED;
}