minimap: add support for sprite scaling to SpriteRenderer/Graphics.Util
This commit is contained in:
@@ -55,12 +55,17 @@ namespace OpenRa.Game.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float2 location, PaletteType palette)
|
public void DrawSprite(Sprite s, float2 location, PaletteType palette)
|
||||||
|
{
|
||||||
|
DrawSprite(s, location, palette, s.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawSprite(Sprite s, float2 location, PaletteType palette, float2 size)
|
||||||
{
|
{
|
||||||
if (s.sheet != currentSheet)
|
if (s.sheet != currentSheet)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
currentSheet = s.sheet;
|
currentSheet = s.sheet;
|
||||||
Util.FastCreateQuad(vertices, indices, location.ToInt2(), s, (int) palette, nv, ni);
|
Util.FastCreateQuad(vertices, indices, location.ToInt2(), s, (int)palette, nv, ni, size);
|
||||||
nv += 4; ni += 6;
|
nv += 4; ni += 6;
|
||||||
if (++sprites >= spritesPerBatch)
|
if (++sprites >= spritesPerBatch)
|
||||||
Flush();
|
Flush();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
||||||
{
|
{
|
||||||
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
||||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni);
|
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
ni += 6;
|
ni += 6;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,14 +57,14 @@ namespace OpenRa.Game.Graphics
|
|||||||
|
|
||||||
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
||||||
|
|
||||||
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni)
|
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni, float2 size)
|
||||||
{
|
{
|
||||||
float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]);
|
float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]);
|
||||||
|
|
||||||
vertices[nv] = new Vertex(KLerp(o, r.size, 0), r.FastMapTextureCoords(0), attrib);
|
vertices[nv] = new Vertex(KLerp(o, size, 0), r.FastMapTextureCoords(0), attrib);
|
||||||
vertices[nv + 1] = new Vertex(KLerp(o, r.size, 1), r.FastMapTextureCoords(1), attrib);
|
vertices[nv + 1] = new Vertex(KLerp(o, size, 1), r.FastMapTextureCoords(1), attrib);
|
||||||
vertices[nv + 2] = new Vertex(KLerp(o, r.size, 2), r.FastMapTextureCoords(2), attrib);
|
vertices[nv + 2] = new Vertex(KLerp(o, size, 2), r.FastMapTextureCoords(2), attrib);
|
||||||
vertices[nv + 3] = new Vertex(KLerp(o, r.size, 3), r.FastMapTextureCoords(3), attrib);
|
vertices[nv + 3] = new Vertex(KLerp(o, size, 3), r.FastMapTextureCoords(3), attrib);
|
||||||
|
|
||||||
indices[ni] = (ushort)(nv);
|
indices[ni] = (ushort)(nv);
|
||||||
indices[ni + 1] = indices[ni + 3] = (ushort)(nv + 1);
|
indices[ni + 1] = indices[ni + 3] = (ushort)(nv + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user