similar perf wins in BibLayer/ResourceLayer

This commit is contained in:
Chris Forbes
2010-04-18 18:23:47 +12:00
parent 9e705a3bcd
commit df661fec03
2 changed files with 21 additions and 10 deletions

View File

@@ -85,11 +85,17 @@ namespace OpenRA.Traits
public void Render() public void Render()
{ {
var tl = world.Map.TopLeft; var cliprect = Game.viewport.ShroudBounds().HasValue
var br = world.Map.BottomRight; ? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
for (int x = tl.X; x < br.X; x++) var minx = cliprect.Left;
for (int y = tl.Y; y < br.Y; y++) var maxx = cliprect.Right;
var miny = cliprect.Top;
var maxy = cliprect.Bottom;
for (int x = minx; x < maxx; x++)
for (int y = miny; y < maxy; y++)
{ {
var t = new int2(x, y); var t = new int2(x, y);
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue; if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;

View File

@@ -22,6 +22,7 @@ using System;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.GameRules; using OpenRA.GameRules;
using System.Drawing;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
@@ -45,13 +46,17 @@ namespace OpenRA.Traits
public void Render() public void Render()
{ {
var map = world.Map; var cliprect = Game.viewport.ShroudBounds().HasValue
? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
var tl = world.Map.TopLeft; var minx = cliprect.Left;
var br = world.Map.BottomRight; var maxx = cliprect.Right;
for (int x = tl.X; x < br.X; x++) var miny = cliprect.Top;
for (int y = tl.Y; y < br.Y; y++) var maxy = cliprect.Bottom;
for (int x = minx; x < maxx; x++)
for (int y = miny; y < maxy; y++)
{ {
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(new int2(x, y))) continue; if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(new int2(x, y))) continue;