Remove the now-unused ExploredBounds optimization.
This commit is contained in:
@@ -47,8 +47,6 @@ namespace OpenRA.Graphics
|
|||||||
public int2 TopLeft { get { return CenterLocation - viewportSize / 2; } }
|
public int2 TopLeft { get { return CenterLocation - viewportSize / 2; } }
|
||||||
public int2 BottomRight { get { return CenterLocation + viewportSize / 2; } }
|
public int2 BottomRight { get { return CenterLocation + viewportSize / 2; } }
|
||||||
int2 viewportSize;
|
int2 viewportSize;
|
||||||
bool cellBoundsDirty = true;
|
|
||||||
|
|
||||||
CellRegion cells;
|
CellRegion cells;
|
||||||
bool cellsDirty = true;
|
bool cellsDirty = true;
|
||||||
|
|
||||||
@@ -64,7 +62,6 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
zoom = value;
|
zoom = value;
|
||||||
viewportSize = (1f / zoom * new float2(Game.Renderer.Resolution)).ToInt2();
|
viewportSize = (1f / zoom * new float2(Game.Renderer.Resolution)).ToInt2();
|
||||||
cellBoundsDirty = true;
|
|
||||||
cellsDirty = true;
|
cellsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +112,6 @@ namespace OpenRA.Graphics
|
|||||||
public void Center(WPos pos)
|
public void Center(WPos pos)
|
||||||
{
|
{
|
||||||
CenterLocation = worldRenderer.ScreenPxPosition(pos).Clamp(mapBounds);
|
CenterLocation = worldRenderer.ScreenPxPosition(pos).Clamp(mapBounds);
|
||||||
cellBoundsDirty = true;
|
|
||||||
cellsDirty = true;
|
cellsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +119,6 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
// Convert scroll delta from world-px to viewport-px
|
// Convert scroll delta from world-px to viewport-px
|
||||||
CenterLocation += (1f / Zoom * delta).ToInt2();
|
CenterLocation += (1f / Zoom * delta).ToInt2();
|
||||||
cellBoundsDirty = true;
|
|
||||||
cellsDirty = true;
|
cellsDirty = true;
|
||||||
|
|
||||||
if (!ignoreBorders)
|
if (!ignoreBorders)
|
||||||
@@ -136,36 +131,14 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var r = CellBounds;
|
var ctl = VisibleCells.TopLeft.TopLeft;
|
||||||
var ctl = new CPos(r.Left, r.Top).TopLeft;
|
var cbr = VisibleCells.BottomRight.BottomRight;
|
||||||
var cbr = new CPos(r.Right, r.Bottom).TopLeft;
|
|
||||||
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl)).Clamp(ScreenClip);
|
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl)).Clamp(ScreenClip);
|
||||||
var br = WorldToViewPx(worldRenderer.ScreenPxPosition(cbr)).Clamp(ScreenClip);
|
var br = WorldToViewPx(worldRenderer.ScreenPxPosition(cbr)).Clamp(ScreenClip);
|
||||||
return Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
|
return Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rectangle (in cell coords) of cells that are currently visible on the screen
|
|
||||||
Rectangle cachedRect;
|
|
||||||
public Rectangle CellBounds
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (cellBoundsDirty)
|
|
||||||
{
|
|
||||||
var boundary = new CVec(1, 1);
|
|
||||||
var tl = worldRenderer.Position(TopLeft).ToCPos() - boundary;
|
|
||||||
var br = worldRenderer.Position(BottomRight).ToCPos() + boundary;
|
|
||||||
|
|
||||||
cachedRect = Rectangle.Intersect(Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y), worldRenderer.world.Map.Bounds);
|
|
||||||
cellBoundsDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var b = worldRenderer.world.VisibleBounds;
|
|
||||||
return b.HasValue ? Rectangle.Intersect(cachedRect, b.Value) : cachedRect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CellRegion VisibleCells
|
public CellRegion VisibleCells
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ namespace OpenRA.Traits
|
|||||||
Dictionary<Actor, CPos[]> visibility = new Dictionary<Actor, CPos[]>();
|
Dictionary<Actor, CPos[]> visibility = new Dictionary<Actor, CPos[]>();
|
||||||
Dictionary<Actor, CPos[]> generation = new Dictionary<Actor, CPos[]>();
|
Dictionary<Actor, CPos[]> generation = new Dictionary<Actor, CPos[]>();
|
||||||
|
|
||||||
public Rectangle ExploredBounds { get; private set; }
|
|
||||||
|
|
||||||
public int Hash { get; private set; }
|
public int Hash { get; private set; }
|
||||||
|
|
||||||
public Shroud(Actor self)
|
public Shroud(Actor self)
|
||||||
@@ -57,9 +55,6 @@ namespace OpenRA.Traits
|
|||||||
self.World.ActorAdded += AddShroudGeneration;
|
self.World.ActorAdded += AddShroudGeneration;
|
||||||
self.World.ActorRemoved += RemoveShroudGeneration;
|
self.World.ActorRemoved += RemoveShroudGeneration;
|
||||||
|
|
||||||
if (!self.World.LobbyInfo.GlobalSettings.Shroud)
|
|
||||||
ExploredBounds = map.Bounds;
|
|
||||||
|
|
||||||
fogVisibilities = Exts.Lazy(() => self.TraitsImplementing<IFogVisibilityModifier>().ToArray());
|
fogVisibilities = Exts.Lazy(() => self.TraitsImplementing<IFogVisibilityModifier>().ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,15 +87,6 @@ namespace OpenRA.Traits
|
|||||||
var visible = origins.SelectMany(o => FindVisibleTiles(a.World, o, rs.Range))
|
var visible = origins.SelectMany(o => FindVisibleTiles(a.World, o, rs.Range))
|
||||||
.Distinct().ToArray();
|
.Distinct().ToArray();
|
||||||
|
|
||||||
// Update bounding rect
|
|
||||||
var r = (rs.Range.Range + 1023) / 1024;
|
|
||||||
|
|
||||||
foreach (var o in origins)
|
|
||||||
{
|
|
||||||
var box = new Rectangle(o.X - r, o.Y - r, 2 * r + 1, 2 * r + 1);
|
|
||||||
ExploredBounds = Rectangle.Union(ExploredBounds, box);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update visibility
|
// Update visibility
|
||||||
foreach (var c in visible)
|
foreach (var c in visible)
|
||||||
{
|
{
|
||||||
@@ -205,10 +191,6 @@ namespace OpenRA.Traits
|
|||||||
foreach (var q in FindVisibleTiles(world, center, range))
|
foreach (var q in FindVisibleTiles(world, center, range))
|
||||||
explored[q] = true;
|
explored[q] = true;
|
||||||
|
|
||||||
var r = (range.Range + 1023) / 1024;
|
|
||||||
var box = new Rectangle(center.X - r, center.Y - r, 2 * r + 1, 2 * r + 1);
|
|
||||||
ExploredBounds = Rectangle.Union(ExploredBounds, box);
|
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +200,6 @@ namespace OpenRA.Traits
|
|||||||
if (s.explored[cell])
|
if (s.explored[cell])
|
||||||
explored[cell] = true;
|
explored[cell] = true;
|
||||||
|
|
||||||
ExploredBounds = Rectangle.Union(ExploredBounds, s.ExploredBounds);
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,8 +207,6 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
explored.Clear(true);
|
explored.Clear(true);
|
||||||
|
|
||||||
ExploredBounds = world.Map.Bounds;
|
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,17 +55,6 @@ namespace OpenRA
|
|||||||
public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); }
|
public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); }
|
||||||
public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); }
|
public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); }
|
||||||
|
|
||||||
public Rectangle? VisibleBounds
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (RenderPlayer == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return RenderPlayer.Shroud.ExploredBounds;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsReplay
|
public bool IsReplay
|
||||||
{
|
{
|
||||||
get { return orderManager.Connection is ReplayConnection; }
|
get { return orderManager.Connection is ReplayConnection; }
|
||||||
|
|||||||
Reference in New Issue
Block a user