diff --git a/OpenRA.Game/Graphics/TerrainSpriteLayer.cs b/OpenRA.Game/Graphics/TerrainSpriteLayer.cs index 29492f93d1..78790cdb6a 100644 --- a/OpenRA.Game/Graphics/TerrainSpriteLayer.cs +++ b/OpenRA.Game/Graphics/TerrainSpriteLayer.cs @@ -114,7 +114,7 @@ namespace OpenRA.Graphics // transparent for isometric tiles var tl = worldRenderer.TerrainLighting; var pos = map.CenterOfCell(uv.ToCPos(map)); - var step = map.Grid.Type == MapGridType.RectangularIsometric ? 724 : 512; + var step = map.Grid.TileScale / 2; var weights = new[] { tl.TintAt(pos + new WVec(-step, -step, 0)), diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index a83b0ab1d1..53bd2b75e2 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -49,7 +49,7 @@ namespace OpenRA.Graphics { World = world; TileSize = World.Map.Grid.TileSize; - TileScale = World.Map.Grid.Type == MapGridType.RectangularIsometric ? 1448 : 1024; + TileScale = World.Map.Grid.TileScale; Viewport = new Viewport(this, world.Map); createPaletteReference = CreatePaletteReference; diff --git a/OpenRA.Game/Map/MapGrid.cs b/OpenRA.Game/Map/MapGrid.cs index 24e38090be..a806edb150 100644 --- a/OpenRA.Game/Map/MapGrid.cs +++ b/OpenRA.Game/Map/MapGrid.cs @@ -128,10 +128,14 @@ namespace OpenRA internal readonly CVec[][] TilesByDistance; + public int TileScale { get; } + public MapGrid(MiniYaml yaml) { FieldLoader.Load(this, yaml); + TileScale = Type == MapGridType.RectangularIsometric ? 1448 : 1024; + // The default subcell index defaults to the middle entry var defaultSubCellIndex = (byte)DefaultSubCell; if (defaultSubCellIndex == byte.MaxValue) diff --git a/OpenRA.Mods.Common/Graphics/ModelRenderable.cs b/OpenRA.Mods.Common/Graphics/ModelRenderable.cs index da7d8f14f7..1c33e0905a 100644 --- a/OpenRA.Mods.Common/Graphics/ModelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/ModelRenderable.cs @@ -137,9 +137,7 @@ namespace OpenRA.Mods.Common.Graphics { var map = wr.World.Map; var groundPos = model.Pos - new WVec(0, 0, map.DistanceAboveTerrain(model.Pos).Length); - var tileScale = map.Grid.Type == MapGridType.RectangularIsometric ? 1448f : 1024f; - - var groundZ = map.Grid.TileSize.Height * (groundPos.Z - model.Pos.Z) / tileScale; + var groundZ = (float)map.Grid.TileSize.Height * (groundPos.Z - model.Pos.Z) / map.Grid.TileScale; var pxOrigin = wr.Screen3DPosition(model.Pos); // HACK: We don't have enough texture channels to pass the depth data to the shader diff --git a/OpenRA.Mods.Common/Lint/CheckInteractable.cs b/OpenRA.Mods.Common/Lint/CheckInteractable.cs index 67e4c5551c..29356aeece 100644 --- a/OpenRA.Mods.Common/Lint/CheckInteractable.cs +++ b/OpenRA.Mods.Common/Lint/CheckInteractable.cs @@ -32,8 +32,6 @@ namespace OpenRA.Mods.Common.Lint { // As the map has not been created we need to get MapGrid info directly from manifest. var grid = modData.Manifest.Get(); - var tileScale = grid.Type == MapGridType.RectangularIsometric ? 1448 : 1024; - foreach (var actorInfo in rules.Actors) { // Catch TypeDictionary errors. @@ -43,10 +41,10 @@ namespace OpenRA.Mods.Common.Lint if (interactable == null) continue; - if (HasInvalidBounds(interactable.Bounds, grid.TileSize, tileScale)) + if (HasInvalidBounds(interactable.Bounds, grid.TileSize, grid.TileScale)) emitError($"{nameof(interactable.Bounds)} of actor {actorInfo.Key} are empty or negative."); - if (HasInvalidBounds(interactable.DecorationBounds, grid.TileSize, tileScale)) + if (HasInvalidBounds(interactable.DecorationBounds, grid.TileSize, grid.TileScale)) emitError($"{nameof(interactable.DecorationBounds)} of actor {actorInfo.Key} are empty or negative."); } catch (InvalidOperationException e) diff --git a/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs b/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs index 88c6627530..e57a74d98e 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs @@ -68,11 +68,11 @@ namespace OpenRA.Mods.Common.Traits map = world.Map; globalTint = new float3(info.RedTint, info.GreenTint, info.BlueTint); - var cellSize = map.Grid.Type == MapGridType.RectangularIsometric ? 1448 : 1024; + var tileScale = map.Grid.TileScale; partitionedLightSources = new SpatiallyPartitioned( - (map.MapSize.X + 1) * cellSize, - (map.MapSize.Y + 1) * cellSize, - info.BinSize * cellSize); + (map.MapSize.X + 1) * tileScale, + (map.MapSize.Y + 1) * tileScale, + info.BinSize * tileScale); } Rectangle Bounds(LightSource source) diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20210321/ConvertBoundsToWDist.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20210321/ConvertBoundsToWDist.cs index d8d9173159..23797ee2dc 100644 --- a/OpenRA.Mods.Common/UpdateRules/Rules/20210321/ConvertBoundsToWDist.cs +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20210321/ConvertBoundsToWDist.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules { var grid = modData.Manifest.Get(); var tileSize = grid.TileSize; - var tileScale = grid.Type == MapGridType.RectangularIsometric ? 1448 : 1024; + var tileScale = grid.TileScale; foreach (var trait in traits) {