From 1582dd5e4d7c1cb395b8ad48cc61f2b41af43d4b Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Fri, 28 Feb 2014 11:05:53 -0500 Subject: Partial fix for T38871, Bevel could create a far-out spike. There needed to be a check that when a newly created point is supposed to be on an edge, that it stays within the bounds of either end of the edge. This fixes the hole-in-cube example in the bug, but not the boolean modifier one, which still needs more work. --- source/blender/bmesh/tools/bmesh_bevel.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index ba289bb4de4..dcb604056fa 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -552,6 +552,15 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) madd_v3_v3fl(slideco, dir, -d); } +/* Is co not on the edge e? */ +static bool is_outside_edge(EdgeHalf *e, const float co[3]) +{ + float d_squared; + + d_squared = dist_squared_to_line_segment_v3(co, e->e->v1->co, e->e->v2->co); + return d_squared > BEVEL_EPSILON_SQ; +} + /* * Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco. * e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of @@ -633,6 +642,20 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, float if (fabsf(d - e2->offset_l) > BEVEL_EPSILON) e2->offset_l = d; } + else { + /* The lines intersect, but is it at a reasonable place? + * One problem to check: if one of the offsets is 0, then don't + * want an intersection that is outside that edge itself. + * This can happen if angle between them is > 180 degrees. */ + if (e1->offset_r == 0.0f && is_outside_edge(e1, meetco)) { + copy_v3_v3(meetco, v->co); + e2->offset_l = 0.0f; + } + if (e2->offset_l == 0.0f && is_outside_edge(e2, meetco)) { + copy_v3_v3(meetco, v->co); + e1->offset_r = 0.0f; + } + } } } -- cgit v1.2.3