0

fixed chunk double-render bug and artifacts at the top of each tile

This commit is contained in:
Aaron Griffith
2011-03-01 20:22:22 -05:00
parent 16bab9be3b
commit 4293851fcc
2 changed files with 15 additions and 5 deletions

View File

@@ -575,12 +575,14 @@ class ChunkRenderer(object):
img = Image.new("RGBA", (384, 1728), (38,92,255,0))
for x,y,z,imgx,imgy in iterate_chunkblocks(xoff,yoff):
blockid = blocks[x,y,z]
# make sure we're drawing within the image boundaries
# 24 == approximate width, height of one block
if imgx >= img.size[0] + 24 or imgx <= -24:
continue
if imgy >= img.size[1] + 24 or imgy <= -24:
continue
if imgx > img.size[0] + 12 or imgx < -12:
continue
if imgy > img.size[1] + 12 or imgy < -12:
continue
blockid = blocks[x,y,z]
# the following blocks don't have textures that can be pre-computed from the blockid
# alone. additional data is required.

View File

@@ -430,6 +430,12 @@ class QuadtreeGen(object):
chunklist = []
for row in xrange(rowstart-16, rowend+1):
for col in xrange(colstart, colend+1):
# due to how chunks are arranged, we can only allow
# even row, even column or odd row, odd column
# otherwise, you end up with duplicates!
if row % 2 != col % 2:
continue
# return (col, row, chunkx, chunky, regionpath)
chunkx, chunky = self.world.unconvert_coords(col, row)
c = self.world.get_region_path(chunkx, chunky)
@@ -589,7 +595,9 @@ def render_worldtile(quadtree, chunks, colstart, colend, rowstart, rowend, path)
# their region files
def chunk_exists(chunk):
_, _, chunkx, chunky, region = chunk
return nbt.load_from_region(region, chunkx, chunky) != None
with open(region, 'rb') as region:
r = nbt.MCRFileReader(region)
return r.load_chunk(chunkx, chunky) != None
chunks = filter(chunk_exists, chunks)
if not chunks: