![]() |
|
Triangulator error - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Ab4d.SharpEngine (https://forum.ab4d.com/forumdisplay.php?fid=12) +--- Thread: Triangulator error (/showthread.php?tid=4486) |
Triangulator error - Artipo - 07-10-2025 Hi, I tried to change the 'RectangleWithHoles' positions in the 'TriangulatedExtrudedShapeSample' of 'Ab4d.SharpEngine.Samples' to: Code: multiShapePositions = new Vector2[][]The result is this: ![]() Do you have any idea what can I look for to fix this? Thank you. RE: Triangulator error - abenedik - 07-11-2025 The triangulator uses a so-called ear clipping algorithm that also supports holes. This algorithm identifies the "ears" of the polygon and removes them until a simple triangle fan can be used to triangulate the remaining positions. But in your case, the algorithm at some point cannot get any "ear" anymore. Because of this, the remaining positions are processed by using a triangle fan. This produces the triangles that overlap with the previously defined triangles. In the paper that defines the algorithm there is no advice on how to solve that. Anyway, I have found out that by reorganizing the holes the triangulation of your positions succeeds. Also, if all your positions are reversed, then the result is also correct. However, I suppose that reorganizing the holes may still not be able to solve all the possible polygons. Therefore, I have added a new FailedToFindPolygonEars property that is set to true after the Triangulation and in this case the user knows that the triangulation was not correct. I will send you a pre-release version with the updated SharpEngine that can reorganize the holes and works correctly for your case. If you find any additional array of positions that does not work, please post it here or send it to me. RE: Triangulator error - Artipo - 07-11-2025 You were very fast! Thank you so much! |