0

Fix tile range error in chunk scan

The chunk scan should have been checking tile bounds using the treedepth
value, not the world boundary. This was causing some tiles near the edge
to not get rendered. In the old version, the row/col boundaries were set
to the treedepth calculated bounds, so this wasn't a problem there.
This commit is contained in:
Andrew Brown
2012-01-02 23:39:20 -05:00
parent c14cd1a66f
commit 4d0acc72fd

View File

@@ -272,8 +272,8 @@ class TileSet(object):
# not the workers) # not the workers)
# Calculate the min and max column over all the chunks. # Calculate the min and max column over all the chunks.
# This sets self.bounds to a Bounds namedtuple # This returns a Bounds namedtuple
self.bounds = self._find_chunk_range() bounds = self._find_chunk_range()
# Calculate the depth of the tree # Calculate the depth of the tree
for p in xrange(1,33): # max 32 for p in xrange(1,33): # max 32
@@ -285,14 +285,16 @@ class TileSet(object):
# Y has 4 times as many chunks as tiles, then halved since this is # Y has 4 times as many chunks as tiles, then halved since this is
# a radius # a radius
yradius = 2*2**p yradius = 2*2**p
if xradius >= self.bounds.maxcol and -xradius <= self.bounds.mincol and \ if xradius >= bounds.maxcol and -xradius <= bounds.mincol and \
yradius >= self.bounds.maxrow and -yradius <= self.bounds.minrow: yradius >= bounds.maxrow and -yradius <= bounds.minrow:
break break
if p >= 15: if p >= 15:
logging.warning("Just letting you know, your map requries %s zoom levels. This is REALLY big!", logging.warning("Just letting you know, your map requries %s zoom levels. This is REALLY big!",
p) p)
self.treedepth = p self.treedepth = p
self.xradius = xradius
self.yradius = yradius
# Do any tile re-arranging if necessary # Do any tile re-arranging if necessary
self._rearrange_tiles() self._rearrange_tiles()
@@ -300,7 +302,6 @@ class TileSet(object):
# Do the chunk scan here # Do the chunk scan here
self.dirtytree = self._chunk_scan() self.dirtytree = self._chunk_scan()
def get_num_phases(self): def get_num_phases(self):
"""Returns the number of levels in the quadtree, which is equal to the """Returns the number of levels in the quadtree, which is equal to the
number of phases of work that need to be done. number of phases of work that need to be done.
@@ -412,7 +413,6 @@ class TileSet(object):
maxrow = max(maxrow, row) maxrow = max(maxrow, row)
mincol = min(mincol, col) mincol = min(mincol, col)
maxcol = max(maxcol, col) maxcol = max(maxcol, col)
return Bounds(mincol, maxcol, minrow, maxrow) return Bounds(mincol, maxcol, minrow, maxrow)
def _rearrange_tiles(self): def _rearrange_tiles(self):
@@ -525,7 +525,10 @@ class TileSet(object):
# See note at the top of this file about the rendercheck modes for an # See note at the top of this file about the rendercheck modes for an
# explanation of what this method does in different situations. # explanation of what this method does in different situations.
# Local vars for slightly faster lookups
depth = self.treedepth depth = self.treedepth
xradius = self.xradius
yradius = self.yradius
dirty = RendertileSet(depth) dirty = RendertileSet(depth)
@@ -600,14 +603,15 @@ class TileSet(object):
c = tilecol - 2*i c = tilecol - 2*i
r = tilerow + 4*j r = tilerow + 4*j
# Make sure the tile is in the range according to the given # Make sure the tile is in the boundary we're rendering.
# depth. This won't happen unless the user has given -z to # This can happen when rendering at lower treedepth than
# render a smaller area of the map than everything # can contain the entire map, but shouldn't happen if the
# treedepth is correctly calculated.
if ( if (
c < self.bounds.mincol or c < -xradius or
c >= self.bounds.maxcol or c >= xradius or
r < self.bounds.minrow or r < -yradius or
r >= self.bounds.maxrow r >= yradius
): ):
continue continue
@@ -649,7 +653,7 @@ class TileSet(object):
return dirty return dirty
def __str__(self): def __str__(self):
return "<TileSet for %s>" % os.basename(self.outputdir) return "<TileSet for %s>" % os.path.basename(self.outputdir)
def _render_compositetile(self, dest, name): def _render_compositetile(self, dest, name):
""" """