diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 23 |
1 files changed, 23 insertions, 0 deletions
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; + } + } } } |