HardonCollider: Polygon incompatible with triangulation
Posted: Sat Jan 07, 2012 9:53 pm
Hi!
I'm currently trying to get HardonCollider to work properly with collision shapes supplied from an external map source(Tiled). The problem is that many of the shapes created for collision detection in the editor are not reliably compatible with the Kong algorithm used to subdivide the polygon into triangles. While collinear points are discarded when the polygon is first passed to the shape constructor, many of my shapes end up with collinear points during the triangulation process (see the attached sketch) causing the process to fail when trying to convert these invalid triangles to shapes (all three vertices get discarded, creating an empty shape).
Now, the easiest solution would of course be not to use such shapes, but they are simply the most practical solution for the mapping part. I've got some basic ideas to address the issue (discard invalid triangles, discard points with adjacent collinear points, reinitialise the remaining polygon every step) but I've got almost no experience with such algorithms so I'd probably break something or take a very inefficient approach. Any help and tips on how to do this efficiently would be greatly appreciated! Thanks in advance!
I'm currently trying to get HardonCollider to work properly with collision shapes supplied from an external map source(Tiled). The problem is that many of the shapes created for collision detection in the editor are not reliably compatible with the Kong algorithm used to subdivide the polygon into triangles. While collinear points are discarded when the polygon is first passed to the shape constructor, many of my shapes end up with collinear points during the triangulation process (see the attached sketch) causing the process to fail when trying to convert these invalid triangles to shapes (all three vertices get discarded, creating an empty shape).
Now, the easiest solution would of course be not to use such shapes, but they are simply the most practical solution for the mapping part. I've got some basic ideas to address the issue (discard invalid triangles, discard points with adjacent collinear points, reinitialise the remaining polygon every step) but I've got almost no experience with such algorithms so I'd probably break something or take a very inefficient approach. Any help and tips on how to do this efficiently would be greatly appreciated! Thanks in advance!