From 907df4800a90b824525bb20433e5eaa7ece853ef Mon Sep 17 00:00:00 2001 From: evgeniysergeev Date: Thu, 22 Oct 2015 20:53:15 +0300 Subject: [PATCH] flip or/and mirror sprites with negative width and heigth --- OpenRA.Game/Graphics/Sprite.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Graphics/Sprite.cs b/OpenRA.Game/Graphics/Sprite.cs index 89916c6b3c..aaafa2b648 100644 --- a/OpenRA.Game/Graphics/Sprite.cs +++ b/OpenRA.Game/Graphics/Sprite.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Drawing; namespace OpenRA.Graphics @@ -37,10 +38,10 @@ namespace OpenRA.Graphics FractionalOffset = offset / Size; - Left = (float)bounds.Left / sheet.Size.Width; - Top = (float)bounds.Top / sheet.Size.Height; - Right = (float)bounds.Right / sheet.Size.Width; - Bottom = (float)bounds.Bottom / sheet.Size.Height; + Left = (float)Math.Min(bounds.Left, bounds.Right) / sheet.Size.Width; + Top = (float)Math.Min(bounds.Top, bounds.Bottom) / sheet.Size.Height; + Right = (float)Math.Max(bounds.Left, bounds.Right) / sheet.Size.Width; + Bottom = (float)Math.Max(bounds.Top, bounds.Bottom) / sheet.Size.Height; } }