/**
* @see eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.collide.Collider#collide(eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Contact[], eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body, eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.raw.Body)
*/
@Override
public int collide(Contact[] contacts, PhysicsAgent2D<?> bodyA, PhysicsAgent2D<?> bodyB) {
Polygon polyA = (Polygon) bodyA.getBodyShape();
Polygon polyB = (Polygon) bodyB.getBodyShape();
Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
Vector2f[] vertsB = polyB.getVertices(bodyB.getPosition(), bodyB.getRotation());
Vector2f centroidA = new Vector2f(polyA.getCentroid());
centroidA.add(bodyA.getPosition());
Vector2f centroidB = new Vector2f(polyB.getCentroid());
centroidB.add(bodyB.getPosition());
int[][] collEdgeCands = getCollisionCandidates(vertsA, vertsB, centroidA, centroidB);
Intersection[][] intersections = getIntersectionPairs(vertsA, vertsB, collEdgeCands);
return populateContacts(contacts, vertsA, vertsB, intersections);