Only render shroud/ore that is in the current viewport

This commit is contained in:
Paul Chote
2010-09-19 18:33:47 +12:00
parent fef291a27e
commit 23da8a24bd
3 changed files with 12 additions and 1 deletions

View File

@@ -158,5 +158,14 @@ namespace OpenRA.Graphics
if (localPlayer.Shroud.Disabled) return null;
return localPlayer.Shroud.Bounds;
}
public Rectangle ViewBounds()
{
int2 boundary = new int2(3,3); // Add a curtain of cells around the viewport to account for rounding errors
var origin = new int2((int)(scrollPosition.X/Game.CellSize), (int)(scrollPosition.Y/Game.CellSize));
var tl = ViewToWorld(origin).ToInt2() - boundary;
var br = ViewToWorld(origin + new int2(Width, Height)).ToInt2() + boundary;
return Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
}
}
}