https://bugs.winehq.org/show_bug.cgi?id=52492
--- Comment #12 from Fabian Maurer dark.shadow4@web.de --- (In reply to Rob F from comment #10)
@Rob F
May I ask what exactly you did?
Also, could I get permission to include your tests when I try to submit that as a fix?
Certainly -- please feel free to incorporate the tests that were originally submitted. The problem was the limited precision of the floating-point calculations can result in the equality-test failing.
The patch I have been using locally replaces the equality test with a taxi-cab distance check of the closeness between the end-points and mid-point against flatness:
.... mp[2].X = (mp[1].X + mp[3].X) / 2.0; mp[2].Y = (mp[1].Y + mp[3].Y) / 2.0;
pt = end->pt; pt_st = start->pt; /* test for closely spaced points to avoid limited-precision errors in
flatness check */ if((fabs(pt.X - mp[2].X) + fabs(pt.Y - mp[2].Y) + fabs(pt_st.X - mp[2].X) + fabs(pt_st.Y - mp[2].Y) ) <= flatness) return TRUE;
/* check flatness as a half of distance between middle point and a
linearized path */ ....
Seems like a sensible approach to me. Although I admit I don't understand why you just add up all the differences, why not sqrt to get the distance between the points? And don't you need flatness * 0.5 like below? Don't take that as critique though, I just don't understand what exactly you're doing.
While we're at it, do you plan to send this to wine? IMHO you got a good fix, or a possibly at least a good start. If there's need for improvement, Wine devs will point it out, and they know a lot more than me.