scooterman/libgdx-cpp — Issue #21: Bug in EarClippingTriangulator
Author: AscensionSystems
Created: 2011-12-08 02:11:28+00:00
State: open

Not sure if this issue is in the original GDX (java) code or not but it is definitely present here. I ran the following vertices through the triangulator:

... and the triangulator gave me back a list of vertices without complaint. However, when passing those triangles directly to box2D, one or more were provided in backward winding order and reversing the order of the triangle(s) to correct the issue resulted in a further breakdown of the overall structure. Note that leaving all my other code the same and swapping out the EarClippingTriangulator with a utility method in the Box2D trunk yielded the desired, correct results which serves as my proof that the error didn't originate in my code. See the following link for the utility class in the box2D source:

http://code.google.com/p/box2d/source/browse/#svn%2Ftrunk%2FContributions%2FUtilities%2FConvexDecomposition
Specifically the method "DecomposeConvexAndAddTo" in b2Polygon.cpp.