Fix sprite overlap outside the map border.
This commit is contained in:
@@ -139,10 +139,9 @@ namespace OpenRA.Graphics
|
||||
get
|
||||
{
|
||||
// Visible rectangle in world coordinates (expanded to the corners of the cells)
|
||||
// Expand the cordon by an additional cell to account for staggered rows on diamond cell grids.
|
||||
var map = worldRenderer.world.Map;
|
||||
var ctl = map.CenterOfCell(VisibleCells.TopLeft) - new WVec(1536, 1536, 0);
|
||||
var cbr = map.CenterOfCell(VisibleCells.BottomRight) + new WVec(1535, 1535, 0);
|
||||
var ctl = map.CenterOfCell(VisibleCells.TopLeft) - new WVec(512, 512, 0);
|
||||
var cbr = map.CenterOfCell(VisibleCells.BottomRight) + new WVec(512, 512, 0);
|
||||
|
||||
// Convert to screen coordinates
|
||||
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl)).Clamp(ScreenClip);
|
||||
|
||||
@@ -40,6 +40,16 @@ namespace OpenRA
|
||||
mapBottomRight = Map.CellToMap(shape, BottomRight);
|
||||
}
|
||||
|
||||
/// <summary>Expand the specified region with an additional cordon. This may expand the region outside the map borders.</summary>
|
||||
public static CellRegion Expand(CellRegion region, int cordon)
|
||||
{
|
||||
var offset = new CVec(cordon, cordon);
|
||||
var tl = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.TopLeft) - offset);
|
||||
var br = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.BottomRight) + offset);
|
||||
|
||||
return new CellRegion(region.shape, tl, br);
|
||||
}
|
||||
|
||||
public bool Contains(CPos cell)
|
||||
{
|
||||
var uv = Map.CellToMap(shape, cell);
|
||||
|
||||
Reference in New Issue
Block a user