diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2014-06-15 01:42:06 +0400 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2014-06-15 01:47:44 +0400 |
commit | b5213b2dea984afcc1c1528c97a70168c2faf25a (patch) | |
tree | 45427cea2e9e05e35d3452bf27e5bfb9e14ec462 /source | |
parent | fa17e3b14c102e11887292536f62967388cbcba1 (diff) |
Fix T40007 Bevel tool resets after getting to 1.
If the side of a beveled edge hit another vertex, the offset
amount reset to zero. This was the result of commit rB1582dd5e4d7c
which clamped the amount to zero to avoid creating spikes with
obtuse angles. Now we clamp the amount to the closest end of
the edge to where the amount wants to be.
Also fixes the first part of T40365.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 76d1d3d9bc0..c583464ab6d 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -555,13 +555,22 @@ 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]) +/* Is co not on the edge e? if not, return the closer end of e in ret_closer_v */ +static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_v) { float d_squared; d_squared = dist_squared_to_line_segment_v3(co, e->e->v1->co, e->e->v2->co); - return d_squared > 10000.0f * BEVEL_EPSILON_SQ; + if (d_squared > BEVEL_EPSILON_BIG * BEVEL_EPSILON_BIG) { + if (len_squared_v3v3(co, e->e->v1->co) > len_squared_v3v3(co, e->e->v2->co)) + *ret_closer_v = e->e->v2; + else + *ret_closer_v = e->e->v1; + return true; + } + else { + return false; + } } /* @@ -580,6 +589,7 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, float { float dir1[3], dir2[3], norm_v[3], norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3], isect2[3], ang, d; + BMVert *closer_v; /* get direction vectors for two offset lines */ sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co); @@ -657,14 +667,15 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, float /* 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; + * This can happen if angle between them is > 180 degrees, + * or if the offset amount is > the edge length*/ + if (e1->offset_r == 0.0f && is_outside_edge(e1, meetco, &closer_v)) { + copy_v3_v3(meetco, closer_v->co); + e2->offset_l = len_v3v3(meetco, v->co); + } + if (e2->offset_l == 0.0f && is_outside_edge(e2, meetco, &closer_v)) { + copy_v3_v3(meetco, closer_v->co); + e1->offset_r = len_v3v3(meetco, v->co); } } } |