Fixed SpriteRenderer offset bug.
This commit is contained in:
@@ -20,6 +20,7 @@ namespace OpenRA.Graphics
|
|||||||
public readonly TextureChannel channel;
|
public readonly TextureChannel channel;
|
||||||
public readonly float2 size;
|
public readonly float2 size;
|
||||||
public readonly float2 offset;
|
public readonly float2 offset;
|
||||||
|
public readonly float2 fractionalOffset;
|
||||||
readonly float2[] textureCoords;
|
readonly float2[] textureCoords;
|
||||||
|
|
||||||
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
||||||
@@ -37,6 +38,8 @@ namespace OpenRA.Graphics
|
|||||||
this.size = new float2(bounds.Size);
|
this.size = new float2(bounds.Size);
|
||||||
this.blendMode = blendMode;
|
this.blendMode = blendMode;
|
||||||
|
|
||||||
|
this.fractionalOffset = offset / this.size;
|
||||||
|
|
||||||
var left = (float)(bounds.Left) / sheet.Size.Width;
|
var left = (float)(bounds.Left) / sheet.Size.Width;
|
||||||
var top = (float)(bounds.Top) / sheet.Size.Height;
|
var top = (float)(bounds.Top) / sheet.Size.Height;
|
||||||
var right = (float)(bounds.Right) / sheet.Size.Width;
|
var right = (float)(bounds.Right) / sheet.Size.Width;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
currentBlend = s.blendMode;
|
currentBlend = s.blendMode;
|
||||||
currentSheet = s.sheet;
|
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;
|
nv += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user