Polygon Triangulation Failed

Avatar
  • updated
  • Fixed

Hello Freya and thank you for creating this asset!

I've stumbled across a polygon case where the error


Invalid polygon triangulation - no convex edges found. Your polygon is likely self-intersecting

is reported, even though the polygon is not self-intersecting.

The polygon looks like this:

Image 554

If I add a bit of displacement to the right lower corner, it renders correctly:

Image 555

The component is a Polygon using Ear Clipping. The points are as follows (you should be able to copy that block and paste it as points, and the error should occur):

GenericPropertyJSON:{"name":"points","type":-1,"arraySize":16,"arrayType":"Vector2","children":[{"name":"Array","type":-1,"arraySize":16,"arrayType":"Vector2","children":[{"name":"size","type":12,"val":16},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.2189188},{"name":"y","type":2,"val":-0.5327203}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.2189188},{"name":"y","type":2,"val":-0.502940953}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.189009},{"name":"y","type":2,"val":-0.473161519}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.15909886},{"name":"y","type":2,"val":-0.4433821}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.129189},{"name":"y","type":2,"val":-0.4136027}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.09927917},{"name":"y","type":2,"val":-0.4433821}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.06936932},{"name":"y","type":2,"val":-0.473161519}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.03945923},{"name":"y","type":2,"val":-0.502940953}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.00954938},{"name":"y","type":2,"val":-0.5327203}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.03945923},{"name":"y","type":2,"val":-0.562499762}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.06936932},{"name":"y","type":2,"val":-0.5922792}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.09927917},{"name":"y","type":2,"val":-0.5922792}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.129189},{"name":"y","type":2,"val":-0.6220586}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.15909886},{"name":"y","type":2,"val":-0.5922792}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.18900847},{"name":"y","type":2,"val":-0.5922792}]},{"name":"data","type":8,"children":[{"name":"x","type":2,"val":2.2189188},{"name":"y","type":2,"val":-0.562499642}]}]}]}

I have also checked the point order and it seems to be correct. Thanks for looking into this!

Reporting a bug? please specify Unity version:
2021.2.10f1
Reporting a bug? please specify Shapes version:
4.1.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator
  • Fixed

good catch and thanks for the test case!
polygon triangulation has now been stabilized and handles this case just fine :)

Or at least, my reduced test case of getting down to the minimal set of points causing the issue (excuse the bad looking debug labels)