Skip to content

Commit f3c2374

Browse files
committed
Another fix for #22
tesedgeSign() does not evaluate to the same sign as tesedgeEval() when the x-coordinates are almost zero. In the test data we had values like -1.70990830e-08f, -8.38190317e-09f, -3.35276112e-10f. The fix is to always use tesedgeEval() so that we have consistent signs. This is slight perf degrade, but the code written in '94 tried really hard to avoid one floating point division, and I think we can handle with that today.
1 parent c3b8ed4 commit f3c2374

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Source/geom.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
#endif
4949

5050
#define EdgeEval(u,v,w) tesedgeEval(u,v,w)
51-
#define EdgeSign(u,v,w) tesedgeSign(u,v,w)
51+
52+
/* EdgeSign used to call tesedgeSign(), which is a cheaper version of tesedgeEval(), but should return the same sign.
53+
* This does not seem to be the case if the x coordinates are almost 0. Always using tesedgeEval() fixes this discrepancy.
54+
* See https://github.com/memononen/libtess2/issues/22 for example data that triggers the issue.
55+
*/
56+
#define EdgeSign(u,v,w) tesedgeEval(u,v,w)
5257

5358
/* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */
5459

0 commit comments

Comments
 (0)