public virtual int Collide(PShape s1, PShape s2, PContact[] cs) { PCollider collider = null; bool flip = false; switch (s1._type) { case Physics.PShapeType.BOX_SHAPE: case Physics.PShapeType.CONVEX_SHAPE: switch (s2._type) { case Physics.PShapeType.BOX_SHAPE: case Physics.PShapeType.CONVEX_SHAPE: collider = new PPolygonPolygonCollider(); break; case Physics.PShapeType.CIRCLE_SHAPE: collider = new PCirclePolygonCollider(); flip = true; break; case Physics.PShapeType.CONCAVE_SHAPE: default: break; } break; case Physics.PShapeType.CIRCLE_SHAPE: switch (s2._type) { case Physics.PShapeType.BOX_SHAPE: case Physics.PShapeType.CONVEX_SHAPE: collider = new PCirclePolygonCollider(); break; case Physics.PShapeType.CIRCLE_SHAPE: collider = new PCircleCirlceCollider(); break; case Physics.PShapeType.CONCAVE_SHAPE: default: break; } break; case Physics.PShapeType.CONCAVE_SHAPE: default: break; } if (collider == null) { return 0; } if (flip) { int res = collider.Collide(s2, s1, cs); if (res > 0) { for (int i = 0; i < res; i++) { cs[i].normal.NegateLocal(); } } return res; } return collider.Collide(s1, s2, cs); }
public virtual int Collide(PShape s1, PShape s2, PContact[] cs) { PCollider collider = null; bool flip = false; switch (s1._type) { case Physics.PShapeType.BOX_SHAPE: case Physics.PShapeType.CONVEX_SHAPE: switch (s2._type) { case Physics.PShapeType.BOX_SHAPE: case Physics.PShapeType.CONVEX_SHAPE: collider = new PPolygonPolygonCollider(); break; case Physics.PShapeType.CIRCLE_SHAPE: collider = new PCirclePolygonCollider(); flip = true; break; case Physics.PShapeType.CONCAVE_SHAPE: default: break; } break; case Physics.PShapeType.CIRCLE_SHAPE: switch (s2._type) { case Physics.PShapeType.BOX_SHAPE: case Physics.PShapeType.CONVEX_SHAPE: collider = new PCirclePolygonCollider(); break; case Physics.PShapeType.CIRCLE_SHAPE: collider = new PCircleCirlceCollider(); break; case Physics.PShapeType.CONCAVE_SHAPE: default: break; } break; case Physics.PShapeType.CONCAVE_SHAPE: default: break; } if (collider == null) { return(0); } if (flip) { int res = collider.Collide(s2, s1, cs); if (res > 0) { for (int i = 0; i < res; i++) { cs[i].normal.NegateLocal(); } } return(res); } return(collider.Collide(s1, s2, cs)); }