From 7d96a6ac9634428fda0ab5365a255a7a680909a4 Mon Sep 17 00:00:00 2001 From: huwpascoe Date: Wed, 20 Aug 2014 00:21:53 +0100 Subject: [PATCH] Fixed SpriteRenderer offset bug. --- OpenRA.Game/Graphics/Sprite.cs | 3 +++ OpenRA.Game/Graphics/SpriteRenderer.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Graphics/Sprite.cs b/OpenRA.Game/Graphics/Sprite.cs index c71be5ccdb..d90d1cbba9 100644 --- a/OpenRA.Game/Graphics/Sprite.cs +++ b/OpenRA.Game/Graphics/Sprite.cs @@ -20,6 +20,7 @@ namespace OpenRA.Graphics public readonly TextureChannel channel; public readonly float2 size; public readonly float2 offset; + public readonly float2 fractionalOffset; readonly float2[] textureCoords; public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel) @@ -37,6 +38,8 @@ namespace OpenRA.Graphics this.size = new float2(bounds.Size); this.blendMode = blendMode; + this.fractionalOffset = offset / this.size; + var left = (float)(bounds.Left) / sheet.Size.Width; var top = (float)(bounds.Top) / sheet.Size.Height; var right = (float)(bounds.Right) / sheet.Size.Width; diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index e9ccf19969..8c076e7bc5 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -73,7 +73,7 @@ namespace OpenRA.Graphics currentBlend = s.blendMode; currentSheet = s.sheet; - Util.FastCreateQuad(vertices, location + s.offset, s, paletteIndex, nv, size); + Util.FastCreateQuad(vertices, location + s.fractionalOffset * size, s, paletteIndex, nv, size); nv += 4; }