Skip to content

Commit

Permalink
Put the origin of the world in the corner of tile 0,0.
Browse files Browse the repository at this point in the history
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 hte same area of the world
will always end up in the same tile, independent of how much of the world is generated.
  • Loading branch information
Martijn Versteegh authored and Martijn Versteegh committed Nov 27, 2018
1 parent 961f659 commit 26a3caf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion TileGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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());
}
}
Expand Down

0 comments on commit 26a3caf

Please sign in to comment.