fix for crash in wireframe tool with verts that only have one boundary edge (degenerate cases - edge with 3+ faces using it).
This commit is contained in:
@@ -77,39 +77,60 @@ static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3
|
||||
}
|
||||
}
|
||||
|
||||
l_a = bm_edge_tag_faceloop(e_a);
|
||||
l_b = bm_edge_tag_faceloop(e_b);
|
||||
if (e_a && e_b) {
|
||||
l_a = bm_edge_tag_faceloop(e_a);
|
||||
l_b = bm_edge_tag_faceloop(e_b);
|
||||
|
||||
/* average edge face normal */
|
||||
add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
|
||||
/* average edge face normal */
|
||||
add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
|
||||
|
||||
/* average edge direction */
|
||||
v_a = BM_edge_other_vert(e_a, v);
|
||||
v_b = BM_edge_other_vert(e_b, v);
|
||||
/* average edge direction */
|
||||
v_a = BM_edge_other_vert(e_a, v);
|
||||
v_b = BM_edge_other_vert(e_b, v);
|
||||
|
||||
sub_v3_v3v3(tvec_a, v->co, v_a->co);
|
||||
sub_v3_v3v3(tvec_b, v_b->co, v->co);
|
||||
normalize_v3(tvec_a);
|
||||
normalize_v3(tvec_b);
|
||||
add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */
|
||||
sub_v3_v3v3(tvec_a, v->co, v_a->co);
|
||||
sub_v3_v3v3(tvec_b, v_b->co, v->co);
|
||||
normalize_v3(tvec_a);
|
||||
normalize_v3(tvec_b);
|
||||
add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */
|
||||
|
||||
/* check are we flipped the right way */
|
||||
BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
|
||||
BM_edge_calc_face_tangent(e_b, l_b, tvec_b);
|
||||
add_v3_v3(tvec_a, tvec_b);
|
||||
|
||||
*r_va_other = v_a;
|
||||
*r_vb_other = v_b;
|
||||
}
|
||||
else {
|
||||
/* degenerate case - vertex connects a boundary edged face to other faces,
|
||||
* so we have only one boundary face - only use it for calculations */
|
||||
l_a = bm_edge_tag_faceloop(e_a);
|
||||
|
||||
copy_v3_v3(no_face, l_a->f->no);
|
||||
|
||||
/* edge direction */
|
||||
v_a = BM_edge_other_vert(e_a, v);
|
||||
v_b = NULL;
|
||||
|
||||
sub_v3_v3v3(no_edge, v->co, v_a->co);
|
||||
|
||||
/* check are we flipped the right way */
|
||||
BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
|
||||
|
||||
*r_va_other = NULL;
|
||||
*r_vb_other = NULL;
|
||||
}
|
||||
|
||||
/* find the normal */
|
||||
cross_v3_v3v3(r_no, no_edge, no_face);
|
||||
normalize_v3(r_no);
|
||||
|
||||
/* check are we flipped the right way */
|
||||
BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
|
||||
BM_edge_calc_face_tangent(e_b, l_b, tvec_b);
|
||||
add_v3_v3(tvec_a, tvec_b);
|
||||
|
||||
if (dot_v3v3(r_no, tvec_a) > 0.0f) {
|
||||
negate_v3(r_no);
|
||||
}
|
||||
|
||||
copy_v3_v3(r_no_face, no_face);
|
||||
*r_va_other = v_a;
|
||||
*r_vb_other = v_b;
|
||||
}
|
||||
|
||||
/* check if we are the only tagged loop-face around this edge */
|
||||
@@ -269,10 +290,12 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
|
||||
/* similar to code above but different angle calc */
|
||||
fac = inset;
|
||||
if (use_even_offset) {
|
||||
fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co,
|
||||
l_pair[i]->v->co,
|
||||
vb_other->co,
|
||||
no_face)) * 0.5f);
|
||||
if (va_other) { /* for verts with only one boundary edge - this will be NULL */
|
||||
fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co,
|
||||
l_pair[i]->v->co,
|
||||
vb_other->co,
|
||||
no_face)) * 0.5f);
|
||||
}
|
||||
}
|
||||
if (use_relative_offset) {
|
||||
fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)];
|
||||
|
||||
Reference in New Issue
Block a user