private bool CheckCirclePolygon(IShape A, Vector2 APos, IShape B, Vector2 BPos, out Contact[] contacts) { CircleShape circleA = A as CircleShape; PolygonShape polyB = B as PolygonShape; Polygon polygonB = new Polygon(polyB.Shape); polygonB.Translate(BPos); Vector2 closestPoint = polygonB.ClosestPoint(APos); Vector2 d = closestPoint - APos; if (Vector2.Dot(d, d) > circleA.Radius * circleA.Radius) { contacts = null; return(false); } if (SAT.Test(circleA, APos, polygonB, out Contact? contact)) { if (contact == null) { contacts = new Contact[0]; } else { contacts = new Contact[] { new Contact(closestPoint, contact.Value.Normal, contact.Value.PenetrationDepth, null) }; } return(true); } contacts = null; return(false); }