LibGDX: Miscalculated polygon collision

These 2 polygons are not colliding, though this method returns true:

Intersector.overlapConvexPolygons(
new float[]{
100.0f, 750.0f,
200.0f, 750.0f,
100.0f, 150.0f,
200.0f, 150.0f
},
new float[]{
77.0f, 695.0f,
91.0f, 695.0f,
84.0f, 681.0f
},
null);


Am I using it correctly?

1 Answer

The first polygon is not convex, swapping vertex 3 and 4 solved the problem

• Then please mark you answer as final (the green check icon). – Philip Allgaier Apr 5 '14 at 13:55
• Is there any documentation that mentions the specific order that you need to define your verticies in? – ashes999 Apr 5 '14 at 14:42
• I need to wait 2 days until I can mark my own answer as the correct one. – cahen Apr 5 '14 at 18:56
• @ashes999, you need to enter in the same order you would if you were drawing it with a pen, but of course this doesn't guarantee it's convex – cahen Apr 5 '14 at 18:58