diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index b5661c958e..ac383cc7ee 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -138,14 +138,22 @@ namespace OpenRA.Graphics return new Rectangle(left, top, right - left, bottom - top); } + int2 cachedScroll = new int2(int.MaxValue, int.MaxValue); + Rectangle cachedRect; + public Rectangle WorldBounds(World world) { - int2 boundary = new int2(1,1); // Add a curtain of cells around the viewport to account for rounding errors - var tl = ViewToWorld(int2.Zero).ToInt2() - boundary; - var br = ViewToWorld(new int2(Width, Height)).ToInt2() + boundary; - var view = Rectangle.Intersect(Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y), world.Map.Bounds); + if (cachedScroll != scrollPosition) + { + int2 boundary = new int2(1,1); // Add a curtain of cells around the viewport to account for rounding errors + var tl = ViewToWorld(int2.Zero).ToInt2() - boundary; + var br = ViewToWorld(new int2(Width, Height)).ToInt2() + boundary; + cachedRect = Rectangle.Intersect(Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y), world.Map.Bounds); + cachedScroll = scrollPosition; + } + var b = world.LocalShroud.Bounds; - return (b.HasValue) ? Rectangle.Intersect(view, b.Value) : view; + return (b.HasValue) ? Rectangle.Intersect(cachedRect, b.Value) : cachedRect; } } } \ No newline at end of file diff --git a/OpenRA.Game/ShroudRenderer.cs b/OpenRA.Game/ShroudRenderer.cs index da48af59ea..3c58d2c685 100644 --- a/OpenRA.Game/ShroudRenderer.cs +++ b/OpenRA.Game/ShroudRenderer.cs @@ -128,9 +128,11 @@ namespace OpenRA for (var j = clip.Top; j < clip.Bottom; j++) { var starti = clip.Left; + var last = shadowBits[0x0f]; for (var i = clip.Left; i < clip.Right; i++) { - if (s[i, j] == shadowBits[0x0f]) + if ((s[i, j] == shadowBits[0x0f] && last == shadowBits[0x0f]) + || (s[i, j] == shadowBits[0] && last == shadowBits[0])) continue; if (starti != i) @@ -146,6 +148,7 @@ namespace OpenRA Game.CellSize * new float2(i, j), shroudPalette); starti = i + 1; + last = s[i, j]; } if (starti < clip.Right)