Add float3 support to TerrainSpriteLayer.

This commit is contained in:
Paul Chote
2016-04-04 16:16:29 -04:00
parent 19a276da2b
commit c00ef40151
2 changed files with 11 additions and 8 deletions

View File

@@ -68,12 +68,15 @@ namespace OpenRA.Graphics
public void Update(CPos cell, Sprite sprite) public void Update(CPos cell, Sprite sprite)
{ {
var pos = sprite == null ? float2.Zero : var xy = sprite == null ? float2.Zero :
worldRenderer.ScreenPosition(map.CenterOfCell(cell)) + sprite.Offset - 0.5f * sprite.Size; worldRenderer.ScreenPosition(map.CenterOfCell(cell)) + sprite.Offset - 0.5f * sprite.Size;
Update(cell.ToMPos(map.Grid.Type), sprite, pos);
// TODO: Deal with sprite z offsets
var z = worldRenderer.ScreenZPosition(map.CenterOfCell(cell), 0);
Update(cell.ToMPos(map.Grid.Type), sprite, new float3(xy.X, xy.Y, z));
} }
public void Update(MPos uv, Sprite sprite, float2 pos) public void Update(MPos uv, Sprite sprite, float3 pos)
{ {
if (sprite != null) if (sprite != null)
{ {

View File

@@ -21,15 +21,15 @@ namespace OpenRA.Graphics
static readonly int[] ChannelMasks = { 2, 1, 0, 3 }; static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
static readonly float[] ChannelSelect = { 0.2f, 0.4f, 0.6f, 0.8f }; static readonly float[] ChannelSelect = { 0.2f, 0.4f, 0.6f, 0.8f };
public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, float paletteTextureIndex, int nv, float2 size) public static void FastCreateQuad(Vertex[] vertices, float3 o, Sprite r, float paletteTextureIndex, int nv, float3 size)
{ {
var b = new float2(o.X + size.X, o.Y); var b = new float3(o.X + size.X, o.Y, o.Z);
var c = new float2(o.X + size.X, o.Y + size.Y); var c = new float3(o.X + size.X, o.Y + size.Y, o.Z + size.Z);
var d = new float2(o.X, o.Y + size.Y); var d = new float3(o.X, o.Y + size.Y, o.Z + size.Z);
FastCreateQuad(vertices, o, b, c, d, r, paletteTextureIndex, nv); FastCreateQuad(vertices, o, b, c, d, r, paletteTextureIndex, nv);
} }
public static void FastCreateQuad(Vertex[] vertices, float2 a, float2 b, float2 c, float2 d, Sprite r, float paletteTextureIndex, int nv) public static void FastCreateQuad(Vertex[] vertices, float3 a, float3 b, float3 c, float3 d, Sprite r, float paletteTextureIndex, int nv)
{ {
var attribC = ChannelSelect[(int)r.Channel]; var attribC = ChannelSelect[(int)r.Channel];
if (r.Sheet.Type == SheetType.DualIndexed) if (r.Sheet.Type == SheetType.DualIndexed)