Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-20 04:33:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-20 04:33:11 +0400
commit7cafd45f2b0e97fcaef1f631537958f460d71196 (patch)
treea45059c21decd6d732e87f22d1372458bfbd110f /source/blender/bmesh/operators/bmo_wireframe.c
parent5716762c02b753e3d3320176d41e7c4f13359233 (diff)
fix for crash in wireframe tool with verts that only have one boundary edge (degenerate cases - edge with 3+ faces using it).
Diffstat (limited to 'source/blender/bmesh/operators/bmo_wireframe.c')
-rw-r--r--source/blender/bmesh/operators/bmo_wireframe.c69
1 files changed, 46 insertions, 23 deletions
diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c
index e0b0794816a..b34d9edc430 100644
--- a/source/blender/bmesh/operators/bmo_wireframe.c
+++ b/source/blender/bmesh/operators/bmo_wireframe.c
@@ -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 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 */
+
+ /* 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);
- /* average edge face normal */
- add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
+ copy_v3_v3(no_face, l_a->f->no);
- /* average edge direction */
- v_a = BM_edge_other_vert(e_a, v);
- v_b = BM_edge_other_vert(e_b, v);
+ /* edge direction */
+ v_a = BM_edge_other_vert(e_a, v);
+ v_b = NULL;
- 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(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)];