Wrong output of specific polygon
Hi Mikko I'm a C++ developer from China. Thank you for contributing this great library. However, I find something wrong when I draw a rectangle with a hole which has 2 coincident edges. The version is v1.0.2. As shown below, When I draw a rectangle(0->1->2->3) with a hole(4->5->6->7). Line 56 coincides with Line 32, and Line 01 coincides with Line 47. Forgive me that I can't attach my source code for some reason. My code like this:
tessAddContour(tess, 2, polyPoints[0], 2 * sizeof(float), 4);
tessAddContour(tess, 2, polyPoints[1], 2 * sizeof(float), 4);
tessTesselate(tess, TessWindingRule::TESS_WINDING_ODD, TessElementType::TESS_POLYGONS, 3, 2, 0);
triangleVerts = tessGetVertices(tess);
elemCount = tessGetElementCount(tess);
triangleElems = tessGetElements(tess);
After that, I find that elemCount is 3, and I calculate the output triangles by triangleVerts and triangleElems in TESS_POLYGONS way. I get only 3 triangles:
(0,5,3)(5,0,4)(2,7,1). After renderring, my output picture shown like this below. One triangle (2,7,6) is missing.
I'm confused and I've done many experiments. I find that this commit will cause my problem. I am sure about this. I would be very greatful if you can point the connection between this "<=" and my problem, Or maybe my code is wrong?
Same problem with the mentioned commit:
I noticed an error like this when moving to the current version of the library from an older version I've been using for years. I may or may not have "fixed" this version of the library at one point so as not to exhibit the bug.
Here's my source code for a version of the library that doesn't create these diagonal artifacts. Note that this version does not support orientation reversal or the Delaunay feature. libtess2_source_without_triangle_bug.zip
It appears my source code matches this commit: https://github.com/memononen/libtess2/commit/d7c34ac3ff11993b0fc0395fe7d96f4cc75e6bb6 So the regression was introduced sometime afterwards.
I'm particularly suspicious of a specific line change to sweep.c that changed a comparison from < to <=.