Rename MapGridType.Diamond to MapGridType.RectangularIsometric
This commit is contained in:
@@ -128,9 +128,9 @@ namespace OpenRA
|
||||
public bool Contains(CPos cell)
|
||||
{
|
||||
// .ToMPos() returns the same result if the X and Y coordinates
|
||||
// are switched. X < Y is invalid in the Diamond coordinate system,
|
||||
// are switched. X < Y is invalid in the RectangularIsometric coordinate system,
|
||||
// so we pre-filter these to avoid returning the wrong result
|
||||
if (GridType == MapGridType.Diamond && cell.X < cell.Y)
|
||||
if (GridType == MapGridType.RectangularIsometric && cell.X < cell.Y)
|
||||
return false;
|
||||
|
||||
return Contains(cell.ToMPos(GridType));
|
||||
|
||||
@@ -426,10 +426,10 @@ namespace OpenRA
|
||||
foreach (var uv in AllCells.MapCoords)
|
||||
CustomTerrain[uv] = byte.MaxValue;
|
||||
|
||||
var leftDelta = Grid.Type == MapGridType.Diamond ? new WVec(-512, 0, 0) : new WVec(-512, -512, 0);
|
||||
var topDelta = Grid.Type == MapGridType.Diamond ? new WVec(0, -512, 0) : new WVec(512, -512, 0);
|
||||
var rightDelta = Grid.Type == MapGridType.Diamond ? new WVec(512, 0, 0) : new WVec(512, 512, 0);
|
||||
var bottomDelta = Grid.Type == MapGridType.Diamond ? new WVec(0, 512, 0) : new WVec(-512, 512, 0);
|
||||
var leftDelta = Grid.Type == MapGridType.RectangularIsometric ? new WVec(-512, 0, 0) : new WVec(-512, -512, 0);
|
||||
var topDelta = Grid.Type == MapGridType.RectangularIsometric ? new WVec(0, -512, 0) : new WVec(512, -512, 0);
|
||||
var rightDelta = Grid.Type == MapGridType.RectangularIsometric ? new WVec(512, 0, 0) : new WVec(512, 512, 0);
|
||||
var bottomDelta = Grid.Type == MapGridType.RectangularIsometric ? new WVec(0, 512, 0) : new WVec(-512, 512, 0);
|
||||
CellCorners = CellCornerHalfHeights.Select(ramp => new WVec[]
|
||||
{
|
||||
leftDelta + new WVec(0, 0, 512 * ramp[0]),
|
||||
@@ -752,9 +752,9 @@ namespace OpenRA
|
||||
public bool Contains(CPos cell)
|
||||
{
|
||||
// .ToMPos() returns the same result if the X and Y coordinates
|
||||
// are switched. X < Y is invalid in the Diamond coordinate system,
|
||||
// are switched. X < Y is invalid in the RectangularIsometric coordinate system,
|
||||
// so we pre-filter these to avoid returning the wrong result
|
||||
if (Grid.Type == MapGridType.Diamond && cell.X < cell.Y)
|
||||
if (Grid.Type == MapGridType.RectangularIsometric && cell.X < cell.Y)
|
||||
return false;
|
||||
|
||||
return Contains(cell.ToMPos(this));
|
||||
@@ -789,7 +789,7 @@ namespace OpenRA
|
||||
if (Grid.Type == MapGridType.Rectangular)
|
||||
return new WPos(1024 * cell.X + 512, 1024 * cell.Y + 512, 0);
|
||||
|
||||
// Convert from diamond cell position (x, y) to world position (u, v):
|
||||
// Convert from isometric cell position (x, y) to world position (u, v):
|
||||
// (a) Consider the relationships:
|
||||
// - Center of origin cell is (512, 512)
|
||||
// - +x adds (512, 512) to world pos
|
||||
@@ -821,7 +821,7 @@ namespace OpenRA
|
||||
if (Grid.Type == MapGridType.Rectangular)
|
||||
return new CPos(pos.X / 1024, pos.Y / 1024);
|
||||
|
||||
// Convert from world position to diamond cell position:
|
||||
// Convert from world position to isometric cell position:
|
||||
// (a) Subtract (512, 512) to move the rotation center to the middle of the corner cell
|
||||
// (b) Rotate axes by -pi/4
|
||||
// (c) Divide through by sqrt(2) to bring us to an equivalent world pos aligned with u,v axes
|
||||
@@ -896,10 +896,10 @@ namespace OpenRA
|
||||
// Directly calculate the projected map corners in world units avoiding unnecessary
|
||||
// conversions. This abuses the definition that the width of the cell is always
|
||||
// 1024 units, and that the height of two rows is 2048 for classic cells and 1024
|
||||
// for diamond cells.
|
||||
// for isometric cells.
|
||||
var wtop = tl.V * 1024;
|
||||
var wbottom = (br.V + 1) * 1024;
|
||||
if (Grid.Type == MapGridType.Diamond)
|
||||
if (Grid.Type == MapGridType.RectangularIsometric)
|
||||
{
|
||||
wtop /= 2;
|
||||
wbottom /= 2;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA
|
||||
{
|
||||
public sealed class MapCache : IEnumerable<MapPreview>, IDisposable
|
||||
{
|
||||
public static readonly MapPreview UnknownMap = new MapPreview(null, MapGridType.Rectangle, null);
|
||||
public static readonly MapPreview UnknownMap = new MapPreview(null, MapGridType.Rectangular, null);
|
||||
readonly Cache<string, MapPreview> previews;
|
||||
readonly ModData modData;
|
||||
readonly SheetBuilder sheetBuilder;
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.IO;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public enum MapGridType { Rectangular, Diamond }
|
||||
public enum MapGridType { Rectangular, RectangularIsometric }
|
||||
|
||||
public class MapGrid : IGlobalModData
|
||||
{
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace OpenRA
|
||||
// The bottom edge is trickier: cells at MPos.V > bottomRight.V may have
|
||||
// been projected into this region if they have height > 0.
|
||||
// Each height step is equivalent to 512 WRange units, which is one MPos
|
||||
// step for diamond cells, but only half a MPos step for classic cells. Doh!
|
||||
// step for isometric cells, but only half a MPos step for classic cells. Doh!
|
||||
var maxHeight = map.Grid.MaximumTerrainHeight;
|
||||
var heightOffset = map.Grid.Type == MapGridType.Diamond ? maxHeight : maxHeight / 2;
|
||||
var heightOffset = map.Grid.Type == MapGridType.RectangularIsometric ? maxHeight : maxHeight / 2;
|
||||
|
||||
// Use the MapHeight data array to clamp the bottom coordinate so it doesn't overflow the map
|
||||
mapBottomRight = map.MapHeight.Value.Clamp(new MPos(bottomRight.U, bottomRight.V + heightOffset));
|
||||
|
||||
Reference in New Issue
Block a user