Merge branch 'agrif-stochastic'
This commit is contained in:
@@ -303,6 +303,19 @@ Less Useful Options
|
||||
|
||||
Default: False
|
||||
|
||||
.. cmdoption:: --stochastic-render <probability>
|
||||
|
||||
Provides a probability that a non-updated tile will be rerendered
|
||||
anyway. Use this if there's a new rendering feature you want to
|
||||
use, but you don't want to rerender the entire map at once.
|
||||
|
||||
**Settings file:**
|
||||
Option name: ``stochastic_render``
|
||||
|
||||
Format: a floating-point number
|
||||
|
||||
Default: 0.0
|
||||
|
||||
.. cmdoption:: --textures-path <path>
|
||||
|
||||
Use this option to specify an alternate terrain.png to use for textures when
|
||||
|
||||
@@ -148,6 +148,7 @@ def main():
|
||||
parser.add_option("-z", "--zoom", dest="zoom", helptext="Sets the zoom level manually instead of calculating it. This can be useful if you have outlier chunks that make your world too big. This value will make the highest zoom level contain (2**ZOOM)^2 tiles", action="store", type="int", advanced=True)
|
||||
parser.add_option("--regionlist", dest="regionlist", helptext="A file containing, on each line, a path to a regionlist to update. Instead of scanning the world directory for regions, it will just use this list. Normal caching rules still apply.")
|
||||
parser.add_option("--forcerender", dest="forcerender", helptext="Force re-rendering the entire map (or the given regionlist). Useful for re-rendering without deleting it.", action="store_true")
|
||||
parser.add_option("--stochastic-render", dest="stochastic_render", helptext="Rerender a non-updated tile randomly, with the given probability (between 0 and 1). Useful for incrementally updating a map with a new mode.", type="float", advanced=True, default=0.0, metavar="PROBABILITY")
|
||||
parser.add_option("--rendermodes", dest="rendermode", helptext="Specifies the render types, separated by ',', ':', or '/'. Use --list-rendermodes to list them all.", type="choice", required=True, default=avail_rendermodes[0], listify=True)
|
||||
parser.add_option("--list-rendermodes", dest="list_rendermodes", action="store_true", helptext="List available render modes and exit.", commandLineOnly=True)
|
||||
parser.add_option("--rendermode-options", dest="rendermode_options", default={}, advanced=True, helptext="Used to specify options for different rendermodes. Only useful in a settings.py file")
|
||||
@@ -369,7 +370,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
# create the quadtrees
|
||||
# TODO chunklist
|
||||
q = []
|
||||
qtree_args = {'depth' : options.zoom, 'imgformat' : imgformat, 'imgquality' : options.imgquality, 'optimizeimg' : optimizeimg, 'bgcolor' : bgcolor, 'forcerender' : options.forcerender}
|
||||
qtree_args = {'depth' : options.zoom, 'imgformat' : imgformat, 'imgquality' : options.imgquality, 'optimizeimg' : optimizeimg, 'bgcolor' : bgcolor, 'forcerender' : options.forcerender, 'rerender_prob' : options.stochastic_render}
|
||||
for rendermode in options.rendermode:
|
||||
if rendermode == 'normal':
|
||||
qtree = quadtree.QuadtreeGen(w, destdir, rendermode=rendermode, tiledir='tiles', **qtree_args)
|
||||
|
||||
@@ -28,6 +28,7 @@ import cPickle
|
||||
import stat
|
||||
import errno
|
||||
import time
|
||||
import random
|
||||
from time import gmtime, strftime, sleep
|
||||
|
||||
from PIL import Image
|
||||
@@ -49,7 +50,7 @@ def iterate_base4(d):
|
||||
return itertools.product(xrange(4), repeat=d)
|
||||
|
||||
class QuadtreeGen(object):
|
||||
def __init__(self, worldobj, destdir, bgcolor, depth=None, tiledir=None, forcerender=False, imgformat=None, imgquality=95, optimizeimg=None, rendermode="normal"):
|
||||
def __init__(self, worldobj, destdir, bgcolor, depth=None, tiledir=None, forcerender=False, rerender_prob=0.0, imgformat=None, imgquality=95, optimizeimg=None, rendermode="normal"):
|
||||
"""Generates a quadtree from the world given into the
|
||||
given dest directory
|
||||
|
||||
@@ -61,6 +62,7 @@ class QuadtreeGen(object):
|
||||
"""
|
||||
assert(imgformat)
|
||||
self.forcerender = forcerender
|
||||
self.rerender_probability = rerender_prob
|
||||
self.imgformat = imgformat
|
||||
self.imgquality = imgquality
|
||||
self.optimizeimg = optimizeimg
|
||||
@@ -427,7 +429,16 @@ class QuadtreeGen(object):
|
||||
try:
|
||||
needs_rerender = False
|
||||
get_region_mtime = world.get_region_mtime
|
||||
|
||||
# stochastic render check
|
||||
if random.uniform(0, 1) < self.rerender_probability:
|
||||
needs_rerender = True
|
||||
|
||||
for col, row, chunkx, chunky, regionfile in chunks:
|
||||
# skip if we already know
|
||||
if needs_rerender:
|
||||
break
|
||||
|
||||
region, regionMtime = get_region_mtime(regionfile)
|
||||
|
||||
# don't even check if it's not in the regionlist
|
||||
|
||||
Reference in New Issue
Block a user