private bool CheckCollision(Vector2f a, Vector2f b) { var p1 = body.Transform.TransformPoint(body.GetPoint(0)); var p2 = body.Transform.TransformPoint(body.GetPoint(1)); var p3 = body.Transform.TransformPoint(body.GetPoint(2)); var p4 = body.Transform.TransformPoint(body.GetPoint(3)); return (CollisionManager.CheckCollision(a, b, p1, p2) != null || CollisionManager.CheckCollision(a, b, p2, p3) != null || CollisionManager.CheckCollision(a, b, p3, p4) != null || CollisionManager.CheckCollision(a, b, p4, p1) != null); }
public static bool CheckCollisionRect(RectangleShape rectangleShape1, RectangleShape rectangleShape2) { Vector2f aa = rectangleShape1.Transform.TransformPoint(rectangleShape1.GetPoint(0)); Vector2f ab = rectangleShape1.Transform.TransformPoint(rectangleShape1.GetPoint(1)); Vector2f ac = rectangleShape1.Transform.TransformPoint(rectangleShape1.GetPoint(2)); Vector2f ad = rectangleShape1.Transform.TransformPoint(rectangleShape1.GetPoint(3)); Vector2f ba = rectangleShape2.Transform.TransformPoint(rectangleShape2.GetPoint(0)); Vector2f bb = rectangleShape2.Transform.TransformPoint(rectangleShape2.GetPoint(1)); Vector2f bc = rectangleShape2.Transform.TransformPoint(rectangleShape2.GetPoint(2)); Vector2f bd = rectangleShape2.Transform.TransformPoint(rectangleShape2.GetPoint(3)); return (PointIntol(aa, ba, bc, rectangleShape2.Rotation) || PointIntol(ab, ba, bc, rectangleShape2.Rotation) || PointIntol(ac, ba, bc, rectangleShape2.Rotation) || PointIntol(ad, ba, bc, rectangleShape2.Rotation) || PointIntol(ba, aa, ac, rectangleShape1.Rotation) || PointIntol(bb, aa, ac, rectangleShape1.Rotation) || PointIntol(bc, aa, ac, rectangleShape1.Rotation) || PointIntol(bd, aa, ac, rectangleShape1.Rotation)); }