Polygon ear clipping fails for segments positioned on a line (?)

  • updated
  • Fixed

Hi, I'm trying to create an arrow from the polygon, and triangulation prints errors (in edit and when spawning an object) "Invalid polygon triangulation - no convex edges found. Your polygon is likely self-intersecting". Luckily for me, it still renders fine with this error (although you can see glitches on the video in some cases - but only when it is actually self-intersecting, so that's okay), and also in convex-only triangulation mode.

The video would be the best description: https://dl.dropboxusercontent.com/s/k56gycj3o7ym45z/2020-10-05_03-11-39.mp4

I tried to show that I don't have any self-intersections there, and that it only prints errors when those two segments are on the same line (but not intersecting). I haven't looked deeper or tried other polygon parameters to reproduce it, though.

Am I doing something wrong or does some math have to be fixed?

Notes:

- Using WebGL build, but that seems irrelevant

- Also have been reproduced on 2019.4.4. 

Reporting a bug? please specify Unity version:
2019.4.11f1
Reporting a bug? please specify Shapes version:
2.3.1
Pinned replies
Freya Holmér
  • Answer
  • Fixed

looks like I forgot to negate a threshold when defining the polygon counter-clockwise rather than clockwise! This has now been fixed in 2.3.2


Freya Holmér
  • Answer
  • Fixed

looks like I forgot to negate a threshold when defining the polygon counter-clockwise rather than clockwise! This has now been fixed in 2.3.2


Xorboo ‪
Quote from Freya Holmér

looks like I forgot to negate a threshold when defining the polygon counter-clockwise rather than clockwise! This has now been fixed in 2.3.2


Hey Freya. Thanks for the patch, my arrow works perfectly with ear clipping now.

Overall ccw works much better (aka works for all real-life use cases and segments on a single line), but it still throws the same error for really small triangles positioned along a similar line. Not sure it is worth fixing, but still wanted to let you know.
https://dl.dropboxusercontent.com/s/3w79dn1q6ferwg1/2020-10-21_00-26-57.mp4