forked from bartvdbraak/blender
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:
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,21 +464,40 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
dist = FLT_MAX;
|
||||
|
||||
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)) {
|
||||
float l_mid_co[3];
|
||||
BM_loop_calc_face_tangent(l, l_mid_co);
|
||||
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);
|
||||
|
||||
/* scale to average of surrounding edge size, only needs to be approx */
|
||||
mul_v3_fl(l_mid_co, (BM_edge_calc_length(l->e) + BM_edge_calc_length(l->prev->e)) / 2.0f);
|
||||
add_v3_v3(l_mid_co, v->co);
|
||||
d = edbm_rip_rip_edgedist(ar, projectMat, v->co, e_mid_co, fmval);
|
||||
|
||||
d = edbm_rip_rip_edgedist(ar, projectMat, v->co, l_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)) {
|
||||
float l_mid_co[3];
|
||||
BM_loop_calc_face_tangent(l, l_mid_co);
|
||||
|
||||
if (d < dist) {
|
||||
dist = d;
|
||||
vi_best = i;
|
||||
/* scale to average of surrounding edge size, only needs to be approx */
|
||||
mul_v3_fl(l_mid_co, (BM_edge_calc_length(l->e) + BM_edge_calc_length(l->prev->e)) / 2.0f);
|
||||
add_v3_v3(l_mid_co, v->co);
|
||||
|
||||
d = edbm_rip_rip_edgedist(ar, projectMat, v->co, l_mid_co, fmval);
|
||||
|
||||
if (d < dist) {
|
||||
dist = d;
|
||||
vi_best = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user