Don't store pre-calculated texture coords in Sprite.

By storing only the four corners, we can save the object overhead of an array and 4 float elements per sprite. This results in savings of around 5 MiB to store these coordinates.
This commit is contained in:
RoosterDragon
2014-10-03 21:04:21 +01:00
parent 59b3cd154d
commit bbb3990a0f
3 changed files with 30 additions and 22 deletions

View File

@@ -31,10 +31,10 @@ namespace OpenRA.Graphics
{
var attrib = new float2(palette / (float)HardwarePalette.MaxPalettes, channelSelect[(int)r.channel]);
vertices[nv] = new Vertex(a, r.FastMapTextureCoords(0), attrib);
vertices[nv + 1] = new Vertex(b, r.FastMapTextureCoords(1), attrib);
vertices[nv + 2] = new Vertex(c, r.FastMapTextureCoords(3), attrib);
vertices[nv + 3] = new Vertex(d, r.FastMapTextureCoords(2), attrib);
vertices[nv] = new Vertex(a, r.TopLeftTextureCoords, attrib);
vertices[nv + 1] = new Vertex(b, r.TopRightTextureCoords, attrib);
vertices[nv + 2] = new Vertex(c, r.BottomRightTextureCoords, attrib);
vertices[nv + 3] = new Vertex(d, r.BottomLeftTextureCoords, attrib);
}
static readonly int[] channelMasks = { 2, 1, 0, 3 }; // yes, our channel order is nuts.