Move TileScale to MapGrid
This commit is contained in:
@@ -114,7 +114,7 @@ namespace OpenRA.Graphics
|
|||||||
// transparent for isometric tiles
|
// transparent for isometric tiles
|
||||||
var tl = worldRenderer.TerrainLighting;
|
var tl = worldRenderer.TerrainLighting;
|
||||||
var pos = map.CenterOfCell(uv.ToCPos(map));
|
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[]
|
var weights = new[]
|
||||||
{
|
{
|
||||||
tl.TintAt(pos + new WVec(-step, -step, 0)),
|
tl.TintAt(pos + new WVec(-step, -step, 0)),
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
World = world;
|
World = world;
|
||||||
TileSize = World.Map.Grid.TileSize;
|
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);
|
Viewport = new Viewport(this, world.Map);
|
||||||
|
|
||||||
createPaletteReference = CreatePaletteReference;
|
createPaletteReference = CreatePaletteReference;
|
||||||
|
|||||||
@@ -128,10 +128,14 @@ namespace OpenRA
|
|||||||
|
|
||||||
internal readonly CVec[][] TilesByDistance;
|
internal readonly CVec[][] TilesByDistance;
|
||||||
|
|
||||||
|
public int TileScale { get; }
|
||||||
|
|
||||||
public MapGrid(MiniYaml yaml)
|
public MapGrid(MiniYaml yaml)
|
||||||
{
|
{
|
||||||
FieldLoader.Load(this, yaml);
|
FieldLoader.Load(this, yaml);
|
||||||
|
|
||||||
|
TileScale = Type == MapGridType.RectangularIsometric ? 1448 : 1024;
|
||||||
|
|
||||||
// The default subcell index defaults to the middle entry
|
// The default subcell index defaults to the middle entry
|
||||||
var defaultSubCellIndex = (byte)DefaultSubCell;
|
var defaultSubCellIndex = (byte)DefaultSubCell;
|
||||||
if (defaultSubCellIndex == byte.MaxValue)
|
if (defaultSubCellIndex == byte.MaxValue)
|
||||||
|
|||||||
@@ -137,9 +137,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
{
|
{
|
||||||
var map = wr.World.Map;
|
var map = wr.World.Map;
|
||||||
var groundPos = model.Pos - new WVec(0, 0, map.DistanceAboveTerrain(model.Pos).Length);
|
var groundPos = model.Pos - new WVec(0, 0, map.DistanceAboveTerrain(model.Pos).Length);
|
||||||
var tileScale = map.Grid.Type == MapGridType.RectangularIsometric ? 1448f : 1024f;
|
var groundZ = (float)map.Grid.TileSize.Height * (groundPos.Z - model.Pos.Z) / map.Grid.TileScale;
|
||||||
|
|
||||||
var groundZ = map.Grid.TileSize.Height * (groundPos.Z - model.Pos.Z) / tileScale;
|
|
||||||
var pxOrigin = wr.Screen3DPosition(model.Pos);
|
var pxOrigin = wr.Screen3DPosition(model.Pos);
|
||||||
|
|
||||||
// HACK: We don't have enough texture channels to pass the depth data to the shader
|
// HACK: We don't have enough texture channels to pass the depth data to the shader
|
||||||
|
|||||||
@@ -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.
|
// As the map has not been created we need to get MapGrid info directly from manifest.
|
||||||
var grid = modData.Manifest.Get<MapGrid>();
|
var grid = modData.Manifest.Get<MapGrid>();
|
||||||
var tileScale = grid.Type == MapGridType.RectangularIsometric ? 1448 : 1024;
|
|
||||||
|
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors.
|
// Catch TypeDictionary errors.
|
||||||
@@ -43,10 +41,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (interactable == null)
|
if (interactable == null)
|
||||||
continue;
|
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.");
|
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.");
|
emitError($"{nameof(interactable.DecorationBounds)} of actor {actorInfo.Key} are empty or negative.");
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException e)
|
catch (InvalidOperationException e)
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
map = world.Map;
|
map = world.Map;
|
||||||
globalTint = new float3(info.RedTint, info.GreenTint, info.BlueTint);
|
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<LightSource>(
|
partitionedLightSources = new SpatiallyPartitioned<LightSource>(
|
||||||
(map.MapSize.X + 1) * cellSize,
|
(map.MapSize.X + 1) * tileScale,
|
||||||
(map.MapSize.Y + 1) * cellSize,
|
(map.MapSize.Y + 1) * tileScale,
|
||||||
info.BinSize * cellSize);
|
info.BinSize * tileScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle Bounds(LightSource source)
|
Rectangle Bounds(LightSource source)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|||||||
{
|
{
|
||||||
var grid = modData.Manifest.Get<MapGrid>();
|
var grid = modData.Manifest.Get<MapGrid>();
|
||||||
var tileSize = grid.TileSize;
|
var tileSize = grid.TileSize;
|
||||||
var tileScale = grid.Type == MapGridType.RectangularIsometric ? 1448 : 1024;
|
var tileScale = grid.TileScale;
|
||||||
|
|
||||||
foreach (var trait in traits)
|
foreach (var trait in traits)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user