diff --git a/chunk.py b/chunk.py index 99019b6..38c4e7e 100644 --- a/chunk.py +++ b/chunk.py @@ -177,8 +177,8 @@ class ChunkRenderer(object): self.queue = queue self.regionfile = worldobj.get_region_path(*chunkcoords) - if not os.path.exists(self.regionfile): - raise ValueError("Could not find regionfile: %s" % self.regionfile) + #if not os.path.exists(self.regionfile): + # raise ValueError("Could not find regionfile: %s" % self.regionfile) ## TODO TODO all of this class @@ -187,7 +187,7 @@ class ChunkRenderer(object): #chunkcoords = filename_split[1:3] #self.coords = map(world.base36decode, chunkcoords) - self.blockid = "%d.%d" % chunkcoords + #self.blockid = "%d.%d" % chunkcoords # chunk coordinates (useful to converting local block coords to # global block coords) @@ -197,12 +197,6 @@ class ChunkRenderer(object): self.world = worldobj self.rendermode = rendermode - if self.world.useBiomeData: - # make sure we've at least *tried* to load the color arrays in this process... - textures.prepareBiomeData(self.world.worlddir) - if not textures.grasscolor or not textures.foliagecolor: - raise Exception("Can't find grasscolor.png or foliagecolor.png") - def _load_level(self): """Loads and returns the level structure""" if not hasattr(self, "_level"): diff --git a/quadtree.py b/quadtree.py index b64333a..2437b33 100644 --- a/quadtree.py +++ b/quadtree.py @@ -434,6 +434,8 @@ class QuadtreeGen(object): # Compile this image tileimg = Image.new("RGBA", (width, height), (38,92,255,0)) + world = self.world + rendermode = self.rendermode # col colstart will get drawn on the image starting at x coordinates -(384/2) # row rowstart will get drawn on the image starting at y coordinates -(192/2) for col, row, chunkx, chunky, regionfile in chunks: @@ -441,8 +443,10 @@ class QuadtreeGen(object): ypos = -96 + (row-rowstart)*96 # draw the chunk! - # TODO POI queue - chunk.render_to_image((chunkx, chunky), tileimg, (xpos, ypos), self, False, poi_queue) + a = chunk.ChunkRenderer((chunkx, chunky), world, rendermode, poi_queue) + a.chunk_render(tileimg, xpos, ypos, None) +# chunk.render_to_image((chunkx, chunky), tileimg, (xpos, ypos), self, False, None) + # Save them tileimg.save(imgpath) diff --git a/rendernode.py b/rendernode.py index 43b175d..006c820 100644 --- a/rendernode.py +++ b/rendernode.py @@ -60,7 +60,13 @@ def pool_initializer(rendernode): #stash the quadtree objects in a global variable after fork() for windows compat. global child_rendernode child_rendernode = rendernode - + for quadtree in rendernode.quadtrees: + if quadtree.world.useBiomeData: + # make sure we've at least *tried* to load the color arrays in this process... + textures.prepareBiomeData(quadtree.world.worlddir) + if not textures.grasscolor or not textures.foliagecolor: + raise Exception("Can't find grasscolor.png or foliagecolor.png") + #http://docs.python.org/library/itertools.html def roundrobin(iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" @@ -119,8 +125,7 @@ class RenderNode(object): # Create a pool if procs == 1: pool = FakePool() - global child_rendernode - child_rendernode = self + pool_initializer(self) else: pool = multiprocessing.Pool(processes=procs,initializer=pool_initializer,initargs=(self,)) #warm up the pool so it reports all the worker id's