Fix T44961, bevel spikes out when certain angles near 180.

Made the test for whether one can "see" an adjacent edge less
knife-close to 180. This means it will chose to slide along
such an edge less often, and avoid some spikes.
This commit is contained in:
Howard Trickey
2015-06-05 12:56:49 -04:00
parent e708042aa0
commit 68cdd2b361

View File

@@ -782,11 +782,14 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e
}
}
/* chosen so that 1/sin(BEVEL_GOOD_ANGLE) is about 4, giving that expansion factor to bevel width */
#define BEVEL_GOOD_ANGLE 0.25f
/* Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
* where e1 precedes e2 in CCW order around their common vertex v (viewed from normal side).
* If r_angle is provided, return the angle between e and emeet in *r_angle.
* If the angle is 0, or it is 180 degrees or larger, there will be no meeting point;
* return false in that case, else true */
* return false in that case, else true. */
static bool offset_meet_edge(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetco[3], float *r_angle)
{
float dir1[3], dir2[3], fno[3], ang, sinang;
@@ -798,7 +801,7 @@ static bool offset_meet_edge(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetc
/* find angle from dir1 to dir2 as viewed from vertex normal side */
ang = angle_normalized_v3v3(dir1, dir2);
if (ang < BEVEL_EPSILON) {
if (fabs(ang) < BEVEL_GOOD_ANGLE) {
if (r_angle)
*r_angle = 0.0f;
return false;
@@ -809,10 +812,11 @@ static bool offset_meet_edge(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetc
if (r_angle)
*r_angle = ang;
if (ang - (float)M_PI > BEVEL_EPSILON)
if (fabs(ang - (float)M_PI) < BEVEL_GOOD_ANGLE)
return false;
sinang = sinf(ang);
copy_v3_v3(meetco, v->co);
if (e1->offset_r == 0.0f)
madd_v3_v3fl(meetco, dir1, e2->offset_l / sinang);