actor culling to shroud bounds

This commit is contained in:
Chris Forbes
2010-02-01 22:15:00 +13:00
parent d3c5f56d52
commit 0793e930fc

View File

@@ -58,7 +58,7 @@ namespace OpenRa.Graphics
} }
} }
public void Draw() Rectangle GetBoundsRect()
{ {
if (!world.LocalPlayer.Shroud.HasGPS && world.LocalPlayer.Shroud.bounds.HasValue) if (!world.LocalPlayer.Shroud.HasGPS && world.LocalPlayer.Shroud.bounds.HasValue)
{ {
@@ -74,24 +74,30 @@ namespace OpenRa.Graphics
if (right > Game.viewport.Width) right = Game.viewport.Width; if (right > Game.viewport.Width) right = Game.viewport.Width;
if (bottom > Game.viewport.Height) bottom = Game.viewport.Height; if (bottom > Game.viewport.Height) bottom = Game.viewport.Height;
renderer.Device.EnableScissor(left, top, right - left, bottom - top); return new Rectangle(left, top, right - left, bottom - top);
} }
else
return new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height);
}
public void Draw()
{
var bounds = GetBoundsRect();
renderer.Device.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
terrainRenderer.Draw(Game.viewport); terrainRenderer.Draw(Game.viewport);
var comparer = new SpriteComparer(); var comparer = new SpriteComparer();
var rect = new RectangleF( bounds.Offset((int)Game.viewport.Location.X, (int)Game.viewport.Location.Y);
Game.viewport.Location.ToPointF(),
new SizeF( Game.viewport.Width, Game.viewport.Height ));
var renderables = world.Actors.SelectMany(a => a.Render()) var renderables = world.Actors.SelectMany(a => a.Render())
.OrderBy(r => r, comparer); .OrderBy(r => r, comparer);
DrawSpriteList(rect, renderables); DrawSpriteList(bounds, renderables);
foreach (var e in world.Effects) foreach (var e in world.Effects)
DrawSpriteList(rect, e.Render()); DrawSpriteList(bounds, e.Render());
uiOverlay.Draw( world ); uiOverlay.Draw( world );