Lazily initialize cell projection mapping.
This commit is contained in:
@@ -246,6 +246,8 @@ namespace OpenRA
|
|||||||
[FieldLoader.Ignore] public Lazy<CellLayer<byte>> MapHeight;
|
[FieldLoader.Ignore] public Lazy<CellLayer<byte>> MapHeight;
|
||||||
|
|
||||||
[FieldLoader.Ignore] public CellLayer<byte> CustomTerrain;
|
[FieldLoader.Ignore] public CellLayer<byte> CustomTerrain;
|
||||||
|
|
||||||
|
[FieldLoader.Ignore] bool initializedCellProjection;
|
||||||
[FieldLoader.Ignore] CellLayer<PPos[]> cellProjection;
|
[FieldLoader.Ignore] CellLayer<PPos[]> cellProjection;
|
||||||
[FieldLoader.Ignore] CellLayer<List<MPos>> inverseCellProjection;
|
[FieldLoader.Ignore] CellLayer<List<MPos>> inverseCellProjection;
|
||||||
|
|
||||||
@@ -437,6 +439,14 @@ namespace OpenRA
|
|||||||
rightDelta + new WVec(0, 0, 512 * ramp[2]),
|
rightDelta + new WVec(0, 0, 512 * ramp[2]),
|
||||||
bottomDelta + new WVec(0, 0, 512 * ramp[3])
|
bottomDelta + new WVec(0, 0, 512 * ramp[3])
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitializeCellProjection()
|
||||||
|
{
|
||||||
|
if (initializedCellProjection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
initializedCellProjection = true;
|
||||||
|
|
||||||
if (MaximumTerrainHeight != 0)
|
if (MaximumTerrainHeight != 0)
|
||||||
{
|
{
|
||||||
@@ -462,6 +472,9 @@ namespace OpenRA
|
|||||||
if (MaximumTerrainHeight == 0)
|
if (MaximumTerrainHeight == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!initializedCellProjection)
|
||||||
|
InitializeCellProjection();
|
||||||
|
|
||||||
var uv = cell.ToMPos(TileShape);
|
var uv = cell.ToMPos(TileShape);
|
||||||
|
|
||||||
// Remove old reverse projection
|
// Remove old reverse projection
|
||||||
@@ -813,6 +826,9 @@ namespace OpenRA
|
|||||||
if (MaximumTerrainHeight == 0)
|
if (MaximumTerrainHeight == 0)
|
||||||
return new[] { (PPos)uv };
|
return new[] { (PPos)uv };
|
||||||
|
|
||||||
|
if (!initializedCellProjection)
|
||||||
|
InitializeCellProjection();
|
||||||
|
|
||||||
if (!cellProjection.Contains(uv))
|
if (!cellProjection.Contains(uv))
|
||||||
return NoProjectedCells;
|
return NoProjectedCells;
|
||||||
|
|
||||||
@@ -827,6 +843,9 @@ namespace OpenRA
|
|||||||
if (MaximumTerrainHeight == 0)
|
if (MaximumTerrainHeight == 0)
|
||||||
return new[] { uv };
|
return new[] { uv };
|
||||||
|
|
||||||
|
if (!initializedCellProjection)
|
||||||
|
InitializeCellProjection();
|
||||||
|
|
||||||
if (!inverseCellProjection.Contains(uv))
|
if (!inverseCellProjection.Contains(uv))
|
||||||
return new MPos[0];
|
return new MPos[0];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user