Viewport map: Improve handling of sloped tile rendering
This commit is contained in:
@@ -2912,17 +2912,22 @@ uint32 ViewportMapGetColour(const Viewport * const vp, uint x, uint y, const uin
|
|||||||
/* Very approximative but fast way to get the tile when taking Z into account. */
|
/* Very approximative but fast way to get the tile when taking Z into account. */
|
||||||
const TileIndex tile_tmp = TileVirtXY(x, y);
|
const TileIndex tile_tmp = TileVirtXY(x, y);
|
||||||
const uint z = TileHeight(tile_tmp) * 4;
|
const uint z = TileHeight(tile_tmp) * 4;
|
||||||
|
if (x + z >= MapSizeX() << 4) {
|
||||||
|
/* Wrapping of tile X coordinate causes a graphic glitch below south west border. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
TileIndex tile = TileVirtXY(x + z, y + z);
|
TileIndex tile = TileVirtXY(x + z, y + z);
|
||||||
if (tile >= MapSize()) return 0;
|
if (tile >= MapSize()) return 0;
|
||||||
if (_settings_game.construction.freeform_edges) {
|
const uint z2 = TileHeight(tile) * 4;
|
||||||
/* tile_tmp and tile must be from the same side,
|
if (unlikely(z2 != z)) {
|
||||||
* otherwise it's an approximation erroneous case
|
const uint approx_z = (z + z2) / 2;
|
||||||
* that leads to a graphic glitch below south west border.
|
if (x + approx_z >= MapSizeX() << 4) {
|
||||||
*/
|
/* Wrapping of tile X coordinate causes a graphic glitch below south west border. */
|
||||||
if (TileX(tile_tmp) > (MapSizeX() - (MapSizeX() / 8)))
|
|
||||||
if ((TileX(tile_tmp) < (MapSizeX() / 2)) != (TileX(tile) < (MapSizeX() / 2)))
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
tile = TileVirtXY(x + approx_z, y + approx_z);
|
||||||
|
if (tile >= MapSize()) return 0;
|
||||||
|
}
|
||||||
TileType tile_type = MP_VOID;
|
TileType tile_type = MP_VOID;
|
||||||
tile = ViewportMapGetMostSignificantTileType(vp, tile, &tile_type);
|
tile = ViewportMapGetMostSignificantTileType(vp, tile, &tile_type);
|
||||||
if (tile_type == MP_VOID) return 0;
|
if (tile_type == MP_VOID) return 0;
|
||||||
|
Reference in New Issue
Block a user