Changed Vertex constructors to pass more parameters as plain floats.

This avoids callers having to construct a float2 struct, only to have the Vertex constructor unwrap it into individual components again.
This commit is contained in:
RoosterDragon
2014-10-10 09:38:14 +01:00
parent 31a096dcf1
commit 69125989ab
6 changed files with 32 additions and 46 deletions

View File

@@ -29,12 +29,13 @@ namespace OpenRA.Graphics
public static void FastCreateQuad(Vertex[] vertices, float2 a, float2 b, float2 c, float2 d, Sprite r, int palette, int nv)
{
var attrib = new float2(palette / (float)HardwarePalette.MaxPalettes, channelSelect[(int)r.channel]);
var attribP = palette / (float)HardwarePalette.MaxPalettes;
var attribC = channelSelect[(int)r.channel];
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);
vertices[nv] = new Vertex(a, r.left, r.top, attribP, attribC);
vertices[nv + 1] = new Vertex(b, r.right, r.top, attribP, attribC);
vertices[nv + 2] = new Vertex(c, r.right, r.bottom, attribP, attribC);
vertices[nv + 3] = new Vertex(d, r.left, r.bottom, attribP, attribC);
}
static readonly int[] channelMasks = { 2, 1, 0, 3 }; // yes, our channel order is nuts.