From 5834d7615b0e844ab825025373ac50ceedd516e6 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 24 May 2017 00:26:46 +0200 Subject: [PATCH] Fix Rectangle OuterRadius Rectangle shapes always assumed that either top-left or bottom-right would have the largest distance from actor center, which is wrong, because depending on the position of the shape, top-right or bottom-left can be the furthest away corner as well, potentially resulting in a too small OuterRadius. --- OpenRA.Mods.Common/HitShapes/Rectangle.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/HitShapes/Rectangle.cs b/OpenRA.Mods.Common/HitShapes/Rectangle.cs index dc8a35f4a6..f6dfd4b40e 100644 --- a/OpenRA.Mods.Common/HitShapes/Rectangle.cs +++ b/OpenRA.Mods.Common/HitShapes/Rectangle.cs @@ -67,7 +67,10 @@ namespace OpenRA.Mods.Common.HitShapes quadrantSize = (BottomRight - TopLeft) / 2; center = TopLeft + quadrantSize; - OuterRadius = new WDist(Math.Max(TopLeft.Length, BottomRight.Length)); + var topRight = new int2(BottomRight.X, TopLeft.Y); + var bottomLeft = new int2(TopLeft.X, BottomRight.Y); + var corners = new[] { TopLeft, BottomRight, topRight, bottomLeft }; + OuterRadius = new WDist(corners.Select(x => x.Length).Max()); combatOverlayVertsTop = new WVec[] {