Removed filting chunks from render_worldtile since _get_chunks_in_range can do it trivially before constructing the list
This commit is contained in:
19
quadtree.py
19
quadtree.py
@@ -85,6 +85,9 @@ class QuadtreeGen(object):
|
|||||||
self.imgformat = imgformat
|
self.imgformat = imgformat
|
||||||
self.optimizeimg = optimizeimg
|
self.optimizeimg = optimizeimg
|
||||||
|
|
||||||
|
self.lighting = rendermode in ("lighting", "night", "spawn")
|
||||||
|
self.night = rendermode in ("night", "spawn")
|
||||||
|
self.spawn = rendermode in ("spawn",)
|
||||||
self.rendermode = rendermode
|
self.rendermode = rendermode
|
||||||
|
|
||||||
# Make the destination dir
|
# Make the destination dir
|
||||||
@@ -410,8 +413,8 @@ class QuadtreeGen(object):
|
|||||||
# return (col, row, chunkx, chunky, regionpath)
|
# return (col, row, chunkx, chunky, regionpath)
|
||||||
chunkx, chunky = unconvert_coords(col, row)
|
chunkx, chunky = unconvert_coords(col, row)
|
||||||
#c = get_region_path(chunkx, chunky)
|
#c = get_region_path(chunkx, chunky)
|
||||||
_, _, c = get_region((chunkx//32, chunky//32),(None,None,None));
|
_, _, c, mcr = get_region((chunkx//32, chunky//32),(None,None,None,None));
|
||||||
if c is not None:
|
if c is not None and mcr.chunkExists(chunkx,chunky):
|
||||||
chunklist.append((col, row, chunkx, chunky, c))
|
chunklist.append((col, row, chunkx, chunky, c))
|
||||||
return chunklist
|
return chunklist
|
||||||
|
|
||||||
@@ -561,16 +564,7 @@ def render_worldtile(quadtree, chunks, colstart, colend, rowstart, rowend, path)
|
|||||||
# anyways just in case). "chunks" should include up to rowstart-16
|
# anyways just in case). "chunks" should include up to rowstart-16
|
||||||
|
|
||||||
imgpath = path + "." + quadtree.imgformat
|
imgpath = path + "." + quadtree.imgformat
|
||||||
|
|
||||||
world = quadtree.world
|
world = quadtree.world
|
||||||
# first, remove chunks from `chunks` that don't actually exist in
|
|
||||||
# their region files
|
|
||||||
def chunk_exists(chunk):
|
|
||||||
_, _, chunkx, chunky, region = chunk
|
|
||||||
r = world.load_region(region)
|
|
||||||
return r.chunkExists(chunkx, chunky)
|
|
||||||
chunks = filter(chunk_exists, chunks)
|
|
||||||
|
|
||||||
#stat the file, we need to know if it exists or it's mtime
|
#stat the file, we need to know if it exists or it's mtime
|
||||||
try:
|
try:
|
||||||
tile_mtime = os.stat(imgpath)[stat.ST_MTIME];
|
tile_mtime = os.stat(imgpath)[stat.ST_MTIME];
|
||||||
@@ -602,12 +596,11 @@ def render_worldtile(quadtree, chunks, colstart, colend, rowstart, rowend, path)
|
|||||||
needs_rerender = False
|
needs_rerender = False
|
||||||
for col, row, chunkx, chunky, regionfile in chunks:
|
for col, row, chunkx, chunky, regionfile in chunks:
|
||||||
# check region file mtime first.
|
# check region file mtime first.
|
||||||
regionMtime = world.get_region_mtime(regionfile)
|
region,regionMtime = world.get_region_mtime(regionfile)
|
||||||
if regionMtime <= tile_mtime:
|
if regionMtime <= tile_mtime:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# checking chunk mtime
|
# checking chunk mtime
|
||||||
region = world.load_region(regionfile)
|
|
||||||
if region.get_chunk_timestamp(chunkx, chunky) > tile_mtime:
|
if region.get_chunk_timestamp(chunkx, chunky) > tile_mtime:
|
||||||
needs_rerender = True
|
needs_rerender = True
|
||||||
break
|
break
|
||||||
|
|||||||
6
world.py
6
world.py
@@ -80,7 +80,7 @@ class World(object):
|
|||||||
mcr = nbt.MCRFileReader(regionfile)
|
mcr = nbt.MCRFileReader(regionfile)
|
||||||
mcr.get_chunk_info()
|
mcr.get_chunk_info()
|
||||||
regions[regionfile] = (mcr,os.path.getmtime(regionfile))
|
regions[regionfile] = (mcr,os.path.getmtime(regionfile))
|
||||||
regionfiles[(x,y)] = (x,y,regionfile)
|
regionfiles[(x,y)] = (x,y,regionfile,mcr)
|
||||||
self.regionfiles = regionfiles
|
self.regionfiles = regionfiles
|
||||||
self.regions = regions
|
self.regions = regions
|
||||||
logging.debug("Done scanning regions")
|
logging.debug("Done scanning regions")
|
||||||
@@ -116,7 +116,7 @@ class World(object):
|
|||||||
def get_region_path(self, chunkX, chunkY):
|
def get_region_path(self, chunkX, chunkY):
|
||||||
"""Returns the path to the region that contains chunk (chunkX, chunkY)
|
"""Returns the path to the region that contains chunk (chunkX, chunkY)
|
||||||
"""
|
"""
|
||||||
_, _, regionfile = self.regionfiles.get((chunkX//32, chunkY//32),(None,None,None));
|
_, _, regionfile,_ = self.regionfiles.get((chunkX//32, chunkY//32),(None,None,None,None));
|
||||||
return regionfile
|
return regionfile
|
||||||
|
|
||||||
def load_from_region(self,filename, x, y):
|
def load_from_region(self,filename, x, y):
|
||||||
@@ -135,7 +135,7 @@ class World(object):
|
|||||||
return self.regions[filename][0]
|
return self.regions[filename][0]
|
||||||
|
|
||||||
def get_region_mtime(self,filename):
|
def get_region_mtime(self,filename):
|
||||||
return self.regions[filename][1]
|
return self.regions[filename]
|
||||||
|
|
||||||
def convert_coords(self, chunkx, chunky):
|
def convert_coords(self, chunkx, chunky):
|
||||||
"""Takes a coordinate (chunkx, chunky) where chunkx and chunky are
|
"""Takes a coordinate (chunkx, chunky) where chunkx and chunky are
|
||||||
|
|||||||
Reference in New Issue
Block a user