MS suck at perf :) (System.ValueType)
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1121 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -123,6 +123,30 @@ namespace OpenRa.FileFormats
|
|||||||
{
|
{
|
||||||
public ushort tile;
|
public ushort tile;
|
||||||
public byte image;
|
public byte image;
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return tile.GetHashCode() ^ image.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TileReference r = (TileReference)obj;
|
||||||
|
return (r.image == image && r.tile == tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(TileReference a, TileReference b)
|
||||||
|
{
|
||||||
|
return a.Equals(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(TileReference a, TileReference b)
|
||||||
|
{
|
||||||
|
return !a.Equals(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct TreeReference
|
public struct TreeReference
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace OpenRa.Game
|
|||||||
new Dictionary<TileReference, SheetRectangle<Sheet>>();
|
new Dictionary<TileReference, SheetRectangle<Sheet>>();
|
||||||
|
|
||||||
FvfVertexBuffer<Vertex> vertexBuffer;
|
FvfVertexBuffer<Vertex> vertexBuffer;
|
||||||
IndexBuffer indexBuffer;
|
|
||||||
|
|
||||||
void LoadTextures()
|
void LoadTextures()
|
||||||
{
|
{
|
||||||
@@ -63,26 +62,40 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
void LoadVertexBuffer()
|
void LoadVertexBuffer()
|
||||||
{
|
{
|
||||||
|
Dictionary<Sheet, List<ushort>> indexMap = new Dictionary<Sheet, List<ushort>>();
|
||||||
|
|
||||||
Vertex[] vertices = new Vertex[4 * 128 * 128];//map.Width * map.Height];
|
Vertex[] vertices = new Vertex[4 * 128 * 128];//map.Width * map.Height];
|
||||||
|
|
||||||
for( int i = 0; i < 128; i++ )
|
for( int i = 0; i < 128; i++ )
|
||||||
for (int j = 0; j < 128; j++)
|
for (int j = 0; j < 128; j++)
|
||||||
{
|
{
|
||||||
int offset = 4 * (i * 128 + j);
|
SheetRectangle<Sheet> tile = tileMapping[map.MapTiles[i, j]];
|
||||||
|
|
||||||
|
ushort offset = (ushort)(4 * (i * 128 + j));
|
||||||
|
|
||||||
vertices[offset] = new Vertex(24 * i, 24 * j, 0, 0, 0);
|
vertices[offset] = new Vertex(24 * i, 24 * j, 0, 0, 0);
|
||||||
vertices[offset + 1] = new Vertex(24 + 24 * i, 24 * j, 0, 1, 0);
|
vertices[offset + 1] = new Vertex(24 + 24 * i, 24 * j, 0, 1, 0);
|
||||||
vertices[offset + 2] = new Vertex(24 * i, 24 + 24 * j, 0, 0, 1);
|
vertices[offset + 2] = new Vertex(24 * i, 24 + 24 * j, 0, 0, 1);
|
||||||
vertices[offset + 3] = new Vertex(24 + 24 * i, 24 + 24 * j, 0, 1, 1);
|
vertices[offset + 3] = new Vertex(24 + 24 * i, 24 + 24 * j, 0, 1, 1);
|
||||||
|
|
||||||
|
List<ushort> indexList;
|
||||||
|
if (!indexMap.TryGetValue(tile.sheet, out indexList))
|
||||||
|
indexMap.Add(tile.sheet, indexList = new List<ushort>());
|
||||||
|
|
||||||
|
indexList.Add(offset);
|
||||||
|
indexList.Add((ushort)(offset + 1));
|
||||||
|
indexList.Add((ushort)(offset + 2));
|
||||||
|
|
||||||
|
indexList.Add((ushort)(offset + 1));
|
||||||
|
indexList.Add((ushort)(offset + 3));
|
||||||
|
indexList.Add((ushort)(offset + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
vertexBuffer = new FvfVertexBuffer<Vertex>(device, vertices.Length, Vertex.Format);
|
vertexBuffer = new FvfVertexBuffer<Vertex>(device, vertices.Length, Vertex.Format);
|
||||||
vertexBuffer.SetData(vertices);
|
vertexBuffer.SetData(vertices);
|
||||||
|
|
||||||
ushort[] indices = new ushort[6 * map.Width * map.Height];
|
Dictionary<Sheet, IndexBuffer> indexBuffers = new Dictionary<Sheet, IndexBuffer>();
|
||||||
|
|
||||||
indexBuffer = new IndexBuffer(device, indices.Length);
|
|
||||||
indexBuffer.SetData(indices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
|
|||||||
Reference in New Issue
Block a user