Tidy TerrainRenderer formatting (no code changes).
This commit is contained in:
@@ -30,22 +30,18 @@ namespace OpenRA.Graphics
|
|||||||
this.map = world.Map;
|
this.map = world.Map;
|
||||||
|
|
||||||
var tileSize = new Size(Game.CellSize, Game.CellSize);
|
var tileSize = new Size(Game.CellSize, Game.CellSize);
|
||||||
var tileMapping = new Cache<TileReference<ushort,byte>, Sprite>(
|
var tileMapping = new Cache<TileReference<ushort,byte>, Sprite>(x =>
|
||||||
x => Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize));
|
Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize));
|
||||||
|
|
||||||
var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
|
|
||||||
|
|
||||||
terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet;
|
terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet;
|
||||||
|
var terrainPalette = wr.Palette("terrain").Index;
|
||||||
|
var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
|
||||||
int nv = 0;
|
int nv = 0;
|
||||||
|
|
||||||
var terrainPalette = wr.Palette("terrain").Index;
|
for (var j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
|
||||||
|
for (var i = map.Bounds.Left; i < map.Bounds.Right; i++)
|
||||||
for( int j = map.Bounds.Top; j < map.Bounds.Bottom; j++ )
|
|
||||||
for( int i = map.Bounds.Left; i < map.Bounds.Right; i++ )
|
|
||||||
{
|
{
|
||||||
var tile = tileMapping[map.MapTiles.Value[i, j]];
|
var tile = tileMapping[map.MapTiles.Value[i, j]];
|
||||||
// TODO: move GetPaletteIndex out of the inner loop.
|
|
||||||
Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size);
|
Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
|
|
||||||
@@ -59,7 +55,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void Draw(WorldRenderer wr, Viewport viewport)
|
public void Draw(WorldRenderer wr, Viewport viewport)
|
||||||
{
|
{
|
||||||
int verticesPerRow = map.Bounds.Width * 4;
|
int verticesPerRow = 4*map.Bounds.Width;
|
||||||
|
|
||||||
int visibleRows = (int)(viewport.Height * 1f / Game.CellSize / viewport.Zoom + 2);
|
int visibleRows = (int)(viewport.Height * 1f / Game.CellSize / viewport.Zoom + 2);
|
||||||
|
|
||||||
@@ -79,10 +75,15 @@ namespace OpenRA.Graphics
|
|||||||
firstRow = r.Bottom - map.Bounds.Top;
|
firstRow = r.Bottom - map.Bounds.Top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstRow < 0) firstRow = 0;
|
// Sanity checking
|
||||||
if (lastRow > map.Bounds.Height) lastRow = map.Bounds.Height;
|
if (firstRow < 0)
|
||||||
|
firstRow = 0;
|
||||||
|
|
||||||
if( lastRow < firstRow ) lastRow = firstRow;
|
if (lastRow > map.Bounds.Height)
|
||||||
|
lastRow = map.Bounds.Height;
|
||||||
|
|
||||||
|
if (lastRow < firstRow)
|
||||||
|
lastRow = firstRow;
|
||||||
|
|
||||||
Game.Renderer.WorldSpriteRenderer.DrawVertexBuffer(
|
Game.Renderer.WorldSpriteRenderer.DrawVertexBuffer(
|
||||||
vertexBuffer, verticesPerRow * firstRow, verticesPerRow * (lastRow - firstRow),
|
vertexBuffer, verticesPerRow * firstRow, verticesPerRow * (lastRow - firstRow),
|
||||||
|
|||||||
Reference in New Issue
Block a user