Fix height calculations in custom terrain layers.
This commit is contained in:
@@ -784,6 +784,19 @@ namespace OpenRA
|
|||||||
return new WDist(delta.Z);
|
return new WDist(delta.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the map Height step in world units
|
||||||
|
/// </summary>
|
||||||
|
public WDist CellHeightStep
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// RectangularIsometric defines 1024 units along the diagonal axis,
|
||||||
|
// giving a half-tile height step of sqrt(2) * 512
|
||||||
|
return new WDist(Grid.Type == MapGridType.RectangularIsometric ? 724 : 512);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CPos CellContaining(WPos pos)
|
public CPos CellContaining(WPos pos)
|
||||||
{
|
{
|
||||||
if (Grid.Type == MapGridType.Rectangular)
|
if (Grid.Type == MapGridType.Rectangular)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public void WorldLoaded(World world, WorldRenderer wr)
|
public void WorldLoaded(World world, WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var domainIndex = world.WorldActor.Trait<DomainIndex>();
|
var domainIndex = world.WorldActor.Trait<DomainIndex>();
|
||||||
|
var cellHeight = world.Map.CellHeightStep.Length;
|
||||||
foreach (var tti in world.WorldActor.Info.TraitInfos<ElevatedBridgePlaceholderInfo>())
|
foreach (var tti in world.WorldActor.Info.TraitInfos<ElevatedBridgePlaceholderInfo>())
|
||||||
{
|
{
|
||||||
enabled = true;
|
enabled = true;
|
||||||
@@ -54,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
terrainIndices[uv] = terrain;
|
terrainIndices[uv] = terrain;
|
||||||
|
|
||||||
var pos = map.CenterOfCell(c);
|
var pos = map.CenterOfCell(c);
|
||||||
cellCenters[uv] = pos - new WVec(0, 0, pos.Z - 512 * tti.Height);
|
cellCenters[uv] = pos - new WVec(0, 0, pos.Z - cellHeight * tti.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
var end = tti.EndCells();
|
var end = tti.EndCells();
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
map = self.World.Map;
|
map = self.World.Map;
|
||||||
terrainIndex = self.World.Map.Rules.TileSet.GetTerrainIndex(info.TerrainType);
|
terrainIndex = self.World.Map.Rules.TileSet.GetTerrainIndex(info.TerrainType);
|
||||||
height = new CellLayer<int>(map);
|
height = new CellLayer<int>(map);
|
||||||
|
var cellHeight = self.World.Map.CellHeightStep.Length;
|
||||||
foreach (var c in map.AllCells)
|
foreach (var c in map.AllCells)
|
||||||
{
|
{
|
||||||
var neighbourCount = 0;
|
var neighbourCount = 0;
|
||||||
@@ -57,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
height[c] = info.HeightOffset.Length + neighbourHeight * 512 / neighbourCount;
|
height[c] = info.HeightOffset.Length + neighbourHeight * cellHeight / neighbourCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public void WorldLoaded(World world, WorldRenderer wr)
|
public void WorldLoaded(World world, WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var domainIndex = world.WorldActor.Trait<DomainIndex>();
|
var domainIndex = world.WorldActor.Trait<DomainIndex>();
|
||||||
|
var cellHeight = world.Map.CellHeightStep.Length;
|
||||||
foreach (var tti in world.WorldActor.Info.TraitInfos<TerrainTunnelInfo>())
|
foreach (var tti in world.WorldActor.Info.TraitInfos<TerrainTunnelInfo>())
|
||||||
{
|
{
|
||||||
enabled = true;
|
enabled = true;
|
||||||
@@ -53,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
terrainIndices[uv] = terrain;
|
terrainIndices[uv] = terrain;
|
||||||
|
|
||||||
var pos = map.CenterOfCell(c);
|
var pos = map.CenterOfCell(c);
|
||||||
cellCenters[uv] = pos - new WVec(0, 0, pos.Z - 512 * tti.Height);
|
cellCenters[uv] = pos - new WVec(0, 0, pos.Z - cellHeight * tti.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
var portal = tti.PortalCells();
|
var portal = tti.PortalCells();
|
||||||
|
|||||||
Reference in New Issue
Block a user