BMesh: rip-tool can now split off isolated fans

Useful since there wasn't a good way to do this previously.
This commit is contained in:
Campbell Barton 2015-05-03 06:15:51 +10:00
parent dd48ddd605
commit 6bc8a3f8d3
1 changed files with 29 additions and 2 deletions

View File

@ -559,9 +559,10 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve
}
}
/* this should be impossible, but sanity checks are a good thing */
if (!v)
/* (v == NULL) should be impossible */
if ((v == NULL) || (v->e == NULL)) {
return OPERATOR_CANCELLED;
}
is_wire = BM_vert_is_wire(v);
@ -621,6 +622,32 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve
}
}
if (e2) {
/* Try to split off a non-manifold fan (when we have multiple disconnected fans) */
/* note: we're lazy here and first split then check there are any faces remaining,
* this isn't good practice, however its less hassle then checking for multiple-disconnected regions */
BMLoop *l_sep = e2->l->v == v ? e2->l : e2->l->next;
BMVert *v_new;
BLI_assert(l_sep->v == v);
v_new = bmesh_urmv_loop_region(bm, l_sep);
if (BM_vert_find_first_loop(v)) {
BM_vert_select_set(bm, v, false);
BM_select_history_remove(bm, v);
BM_vert_select_set(bm, v_new, true);
if (ese.ele) {
BM_select_history_store(bm, v_new);
}
return OPERATOR_FINISHED;
}
else {
/* rewind */
BM_vert_splice(bm, v, v_new);
}
}
/* should we go ahead with edge rip or do we need to do special case, split off vertex?:
* split off vertex if...
* - we cant find an edge - this means we are ripping a faces vert that is connected to other