Relax screen clipping bounds.
Fixes missing tiles in TS.
This commit is contained in:
@@ -95,9 +95,8 @@ namespace OpenRA.Graphics
|
|||||||
var cells = viewport.VisibleCells;
|
var cells = viewport.VisibleCells;
|
||||||
|
|
||||||
// Only draw the rows that are visible.
|
// Only draw the rows that are visible.
|
||||||
// VisibleCells is clamped to the map, so additional checks are unnecessary
|
var firstRow = cells.MapCoords.TopLeft.V;
|
||||||
var firstRow = cells.TopLeft.ToMPos(map).V;
|
var lastRow = Math.Min(cells.MapCoords.BottomRight.V + 1, map.MapSize.Y);
|
||||||
var lastRow = cells.BottomRight.ToMPos(map).V + 1;
|
|
||||||
|
|
||||||
Game.Renderer.Flush();
|
Game.Renderer.Flush();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace OpenRA.Graphics
|
|||||||
readonly Rectangle mapBounds;
|
readonly Rectangle mapBounds;
|
||||||
|
|
||||||
readonly int maxGroundHeight;
|
readonly int maxGroundHeight;
|
||||||
|
readonly Size tileSize;
|
||||||
|
|
||||||
// Viewport geometry (world-px)
|
// Viewport geometry (world-px)
|
||||||
public int2 CenterLocation { get; private set; }
|
public int2 CenterLocation { get; private set; }
|
||||||
@@ -101,6 +102,7 @@ namespace OpenRA.Graphics
|
|||||||
maxGroundHeight = wr.World.TileSet.MaxGroundHeight;
|
maxGroundHeight = wr.World.TileSet.MaxGroundHeight;
|
||||||
CenterLocation = (tl + br) / 2;
|
CenterLocation = (tl + br) / 2;
|
||||||
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
||||||
|
tileSize = Game.ModData.Manifest.TileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPos ViewToWorld(int2 view)
|
public CPos ViewToWorld(int2 view)
|
||||||
@@ -211,7 +213,10 @@ namespace OpenRA.Graphics
|
|||||||
// Convert to screen coordinates
|
// Convert to screen coordinates
|
||||||
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl - new WVec(0, 0, ctl.Z))).Clamp(ScreenClip);
|
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl - new WVec(0, 0, ctl.Z))).Clamp(ScreenClip);
|
||||||
var br = WorldToViewPx(worldRenderer.ScreenPxPosition(cbr - new WVec(0, 0, cbr.Z))).Clamp(ScreenClip);
|
var br = WorldToViewPx(worldRenderer.ScreenPxPosition(cbr - new WVec(0, 0, cbr.Z))).Clamp(ScreenClip);
|
||||||
return Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
|
|
||||||
|
// Add an extra one cell fudge in each direction for safety
|
||||||
|
return Rectangle.FromLTRB(tl.X - tileSize.Width, tl.Y - tileSize.Height,
|
||||||
|
br.X + tileSize.Width, br.Y + tileSize.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,6 +230,11 @@ namespace OpenRA.Graphics
|
|||||||
var wtl = worldRenderer.Position(TopLeft);
|
var wtl = worldRenderer.Position(TopLeft);
|
||||||
var wbr = worldRenderer.Position(BottomRight);
|
var wbr = worldRenderer.Position(BottomRight);
|
||||||
|
|
||||||
|
// Map editor shows the full map (including the area outside the regular bounds)
|
||||||
|
Func<MPos, MPos> clamp = map.Clamp;
|
||||||
|
if (worldRenderer.World.Type == WorldType.Editor)
|
||||||
|
clamp = map.MapTiles.Value.Clamp;
|
||||||
|
|
||||||
// Due to diamond tile staggering, we need to adjust the top-left bounds outwards by half a cell.
|
// Due to diamond tile staggering, we need to adjust the top-left bounds outwards by half a cell.
|
||||||
if (map.TileShape == TileShape.Diamond)
|
if (map.TileShape == TileShape.Diamond)
|
||||||
wtl -= new WVec(512, 512, 0);
|
wtl -= new WVec(512, 512, 0);
|
||||||
@@ -234,11 +244,11 @@ namespace OpenRA.Graphics
|
|||||||
var ctl = new MPos(wtl.X / 1024, wtl.Y / dy);
|
var ctl = new MPos(wtl.X / 1024, wtl.Y / dy);
|
||||||
var cbr = new MPos(wbr.X / 1024, wbr.Y / dy);
|
var cbr = new MPos(wbr.X / 1024, wbr.Y / dy);
|
||||||
|
|
||||||
var tl = map.Clamp(ctl.ToCPos(map));
|
var tl = clamp(ctl).ToCPos(map.TileShape);
|
||||||
|
|
||||||
// Also need to account for height of cells in rows below the bottom.
|
// Also need to account for height of cells in rows below the bottom.
|
||||||
var heightPadding = map.TileShape == TileShape.Diamond ? 2 : 0;
|
var heightPadding = map.TileShape == TileShape.Diamond ? 3 : 0;
|
||||||
var br = map.Clamp(new MPos(cbr.U, cbr.V + heightPadding + maxGroundHeight / 2).ToCPos(map));
|
var br = clamp(new MPos(cbr.U, cbr.V + heightPadding + maxGroundHeight / 2 + 1)).ToCPos(map.TileShape);
|
||||||
|
|
||||||
cells = new CellRegion(map.TileShape, tl, br);
|
cells = new CellRegion(map.TileShape, tl, br);
|
||||||
cellsDirty = false;
|
cellsDirty = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user