From aa0506224eacb793abd399362fda7720e1be7c47 Mon Sep 17 00:00:00 2001 From: Martijn Versteegh Date: Tue, 27 Nov 2018 10:51:17 +0100 Subject: [PATCH] Put the origin of the world in the corner of tile 0,0. Negative x/z will be put into negative tiles, so you can easily determine the tile location by dividing the x or z by 16*tileSize. This means the same area of the world will always end up in the same tile, independent of how much of the world is generated. --- TileGenerator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TileGenerator.cpp b/TileGenerator.cpp index ece4936..0da7689 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -264,6 +264,10 @@ void TileGenerator::generate(const std::string &input, const std::string &output if (m_tileW < INT_MAX || m_tileH < INT_MAX) { + m_xMin = round_multiple_nosign(m_xMin, m_tileW); + m_zMin = round_multiple_nosign(m_zMin, m_tileH); + int minTileX = m_xMin / m_tileW; + int minTileY = m_zMin / m_tileH; sortPositionsIntoTiles(); @@ -295,7 +299,7 @@ void TileGenerator::generate(const std::string &input, const std::string &output renderPlayers(input_path); } ostringstream fn; - fn << x << '_' << y << '_' << output; + fn << (x + minTileX) << '_' << (y + minTileY) << '_' << output; writeImage(fn.str()); } }