minor improvements to rip

- rip tool didnt select the best edge to rip for wire verts (no connected faces)
- ripping one vert with 2 edges connected didnt work.
This commit is contained in:
Campbell Barton 2012-09-07 06:31:54 +00:00
parent acfff7a65f
commit cdc9e553c1

@ -380,6 +380,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
float dist = FLT_MAX;
float d;
int is_wire;
BMEditSelection ese;
int totboundary_edge = 0;
@ -403,6 +404,8 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
if (!v)
return OPERATOR_CANCELLED;
is_wire = BM_vert_is_wire(v);
e2 = NULL;
if (v->e) {
@ -430,8 +433,11 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
* - we cant find an edge - this means we are ripping a faces vert that is connected to other
* geometry only at the vertex.
* - the boundary edge total is greater then 2,
* in this case edge split _can_ work but we get far nicer results if we use this special case. */
if (totboundary_edge > 2) {
* in this case edge split _can_ work but we get far nicer results if we use this special case.
* - there are only 2 edges but we are a wire vert. */
if ((is_wire == FALSE && totboundary_edge > 2) ||
(is_wire == TRUE && totboundary_edge > 1))
{
BMVert **vout;
int vout_len;
@ -458,6 +464,24 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
dist = FLT_MAX;
if (is_wire) {
for (i = 0; i < vout_len; i++) {
BM_ITER_ELEM (e, &iter, vout[i], BM_EDGES_OF_VERT) {
if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
float e_mid_co[3];
mid_v3_v3v3(e_mid_co, e->v1->co, e->v2->co);
d = edbm_rip_rip_edgedist(ar, projectMat, v->co, e_mid_co, fmval);
if (d < dist) {
dist = d;
vi_best = i;
}
}
}
}
}
else {
for (i = 0; i < vout_len; i++) {
BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) {
if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
@ -477,6 +501,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
}
}
}
}
/* select the vert from the best region */
v = vout[vi_best];