Closed TannerRogalsky closed 6 years ago
Damn, I wished I found this earlier, because I had the same issue and opened an issue ticket #55 lol. I fixed it myself, too: https://github.com/MartyMaro/HC/commit/bde26eca15ffb340d622abd9c399cc59c86201d5
My question to your fix is, why checking for the collinears in the same statement like isEar? If you run into collinear matches it would increase the skipped counter. Is this really right? Because the assert below might be executed too early:
skipped = skipped + 1
assert(skipped <= n_vert, "Cannot triangulate polygon")
@MartyMaro Maybe! That makes sense!
Merged bde26eca15ffb340d622abd9c399cc59c86201d5 instead
I was running into an issue where, rarely,
Polygon:triangulate()
would find triangles that were comprised of collinear points. Then, when it went to great new sub-Polygons, it would throw an error about the collinear points.This additional check avoids adding triangles to the list of triangles if they will have no area.
I have included this test case to further illustrate the case I ran into.