Fix computation of block number bounds (off-by-one)

The block numbers could be off by one due to incorrect rounding.

m_geom* now contain the minimum and maximum block numbers that
should be in the map.
This commit is contained in:
Rogier 2014-02-16 19:08:09 +01:00 committed by Sfan5
parent ec037dd924
commit a15bc30071

@ -187,13 +187,13 @@ void TileGenerator::setShading(bool shading)
void TileGenerator::setGeometry(int x, int y, int w, int h) void TileGenerator::setGeometry(int x, int y, int w, int h)
{ {
if (x > 0) { if (x > 0) {
m_geomX = (x + 15) / 16; m_geomX = x / 16;
} }
else { else {
m_geomX = (x - 15) / 16; m_geomX = (x - 15) / 16;
} }
if (y > 0) { if (y > 0) {
m_geomY = (y + 15) / 16; m_geomY = y / 16;
} }
else { else {
m_geomY = (y - 15) / 16; m_geomY = (y - 15) / 16;
@ -203,13 +203,13 @@ void TileGenerator::setGeometry(int x, int y, int w, int h)
int y2 = y + h; int y2 = y + h;
if (x2 > 0) { if (x2 > 0) {
m_geomX2 = (x2 + 15) / 16; m_geomX2 = x2 / 16;
} }
else { else {
m_geomX2 = (x2 - 15) / 16; m_geomX2 = (x2 - 15) / 16;
} }
if (y2 > 0) { if (y2 > 0) {
m_geomY2 = (y2 + 15) / 16; m_geomY2 = y2 / 16;
} }
else { else {
m_geomY2 = (y2 - 15) / 16; m_geomY2 = (y2 - 15) / 16;
@ -308,7 +308,7 @@ void TileGenerator::loadBlocks()
std::vector<int64_t> vec = m_db->getBlockPos(); std::vector<int64_t> vec = m_db->getBlockPos();
for(unsigned int i = 0; i < vec.size(); i++) { for(unsigned int i = 0; i < vec.size(); i++) {
BlockPos pos = decodeBlockPos(vec[i]); BlockPos pos = decodeBlockPos(vec[i]);
if (pos.x < m_geomX || pos.x >= m_geomX2 || pos.z < m_geomY || pos.z >= m_geomY2) { if (pos.x < m_geomX || pos.x > m_geomX2 || pos.z < m_geomY || pos.z > m_geomY2) {
continue; continue;
} }
if (pos.y < m_yMin * 16) { if (pos.y < m_yMin * 16) {