ridiculous perf win in SmudgeLayer
This commit is contained in:
@@ -16,13 +16,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
@@ -57,6 +58,8 @@ namespace OpenRA.FileFormats
|
|||||||
public int2 TopLeft;
|
public int2 TopLeft;
|
||||||
public int2 BottomRight;
|
public int2 BottomRight;
|
||||||
|
|
||||||
|
public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } }
|
||||||
|
|
||||||
public TileReference<ushort, byte>[,] MapTiles;
|
public TileReference<ushort, byte>[,] MapTiles;
|
||||||
public TileReference<byte, byte>[,] MapResources;
|
public TileReference<byte, byte>[,] MapResources;
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ namespace OpenRA.Graphics
|
|||||||
if (firstRow < 0) firstRow = 0;
|
if (firstRow < 0) firstRow = 0;
|
||||||
if (lastRow > map.Height) lastRow = map.Height;
|
if (lastRow > map.Height) lastRow = map.Height;
|
||||||
|
|
||||||
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.bounds.HasValue)
|
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.Bounds.HasValue)
|
||||||
{
|
{
|
||||||
var r = world.LocalPlayer.Shroud.bounds.Value;
|
var r = world.LocalPlayer.Shroud.Bounds.Value;
|
||||||
if (firstRow < r.Top - map.YOffset)
|
if (firstRow < r.Top - map.YOffset)
|
||||||
firstRow = r.Top - map.YOffset;
|
firstRow = r.Top - map.YOffset;
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using OpenRA.Network;
|
|||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
@@ -196,5 +197,12 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
Center( player.World.Queries.OwnedBy[ player ].WithTrait<Selectable>().Select( a => a.Actor ) );
|
Center( player.World.Queries.OwnedBy[ player ].WithTrait<Selectable>().Select( a => a.Actor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rectangle? ShroudBounds()
|
||||||
|
{
|
||||||
|
var localPlayer = Game.world.LocalPlayer;
|
||||||
|
if (localPlayer == null) return null;
|
||||||
|
return localPlayer.Shroud.Bounds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
Rectangle GetBoundsRect()
|
Rectangle GetBoundsRect()
|
||||||
{
|
{
|
||||||
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.bounds.HasValue)
|
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.Bounds.HasValue)
|
||||||
{
|
{
|
||||||
var r = world.LocalPlayer.Shroud.bounds.Value;
|
var r = world.LocalPlayer.Shroud.Bounds.Value;
|
||||||
|
|
||||||
var left = (int)(Game.CellSize * r.Left - Game.viewport.Location.X);
|
var left = (int)(Game.CellSize * r.Left - Game.viewport.Location.X);
|
||||||
var top = (int)(Game.CellSize * r.Top - Game.viewport.Location.Y);
|
var top = (int)(Game.CellSize * r.Top - Game.viewport.Location.Y);
|
||||||
@@ -169,7 +169,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
DrawBox(bounds, Color.Red);
|
DrawBox(bounds, Color.Red);
|
||||||
if (world.LocalPlayer != null)
|
if (world.LocalPlayer != null)
|
||||||
DrawBox(world.LocalPlayer.Shroud.bounds.Value, Color.Blue);
|
DrawBox(world.LocalPlayer.Shroud.Bounds.Value, Color.Blue);
|
||||||
|
|
||||||
for (var j = 0; j < world.Map.MapSize.Y;
|
for (var j = 0; j < world.Map.MapSize.Y;
|
||||||
j += world.WorldActor.Info.Traits.Get<SpatialBinsInfo>().BinSize)
|
j += world.WorldActor.Info.Traits.Get<SpatialBinsInfo>().BinSize)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA
|
|||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
Map map;
|
Map map;
|
||||||
|
|
||||||
public Rectangle? bounds { get { return shroud.exploredBounds; } }
|
public Rectangle? Bounds { get { return shroud.exploredBounds; } }
|
||||||
|
|
||||||
public ShroudRenderer(Player owner, Map map)
|
public ShroudRenderer(Player owner, Map map)
|
||||||
{
|
{
|
||||||
@@ -149,11 +149,12 @@ namespace OpenRA
|
|||||||
fogSprites[i, j] = ChooseFog(i, j);
|
fogSprites[i, j] = ChooseFog(i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
var miny = bounds.HasValue ? Math.Max(map.YOffset, bounds.Value.Top) : map.YOffset;
|
var clipRect = Bounds.HasValue ? Rectangle.Intersect(Bounds.Value, map.Bounds) : map.Bounds;
|
||||||
var maxy = bounds.HasValue ? Math.Min(map.YOffset + map.Height, bounds.Value.Bottom) : map.YOffset + map.Height;
|
|
||||||
|
|
||||||
var minx = bounds.HasValue ? Math.Max(map.XOffset, bounds.Value.Left) : map.XOffset;
|
var miny = clipRect.Top;
|
||||||
var maxx = bounds.HasValue ? Math.Min(map.XOffset + map.Width, bounds.Value.Right) : map.XOffset + map.Width;
|
var maxy = clipRect.Bottom;
|
||||||
|
var minx = clipRect.Left;
|
||||||
|
var maxx = clipRect.Right;
|
||||||
|
|
||||||
var shroudPalette = "fog";
|
var shroudPalette = "fog";
|
||||||
|
|
||||||
|
|||||||
@@ -82,12 +82,18 @@ 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user