Skip to content

Commit

Permalink
added rendercheck mode 3, the identity function of rendercheck modes!
Browse files Browse the repository at this point in the history
  • Loading branch information
agrif committed May 1, 2014
1 parent 7d87d25 commit 7c23d6e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
8 changes: 8 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,14 @@ values. The valid configuration keys are listed below.
'forcerender': True,
}

``renderchecks``
This is an integer, and functions as a more complex form of
``forcerender``. Setting it to 1 enables :option:`--check-tiles`
mode, setting it to 2 enables :option:`--forcerender`, and 3 tells
Overviewer to keep this particular render in the output, but
otherwise don't update it. It defaults to 0, which is the usual
update checking mode.

``changelist``
This is a string. It names a file where it will write out, one per line, the
path to tiles that have been updated. You can specify the same file for
Expand Down
17 changes: 11 additions & 6 deletions overviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,24 @@ def main():
"--check-tiles, and --no-tile-checks. These options conflict.")
parser.print_help()
return 1

def set_renderchecks(checkname, num):
for name, render in config['renders'].iteritems():
if render.get('renderchecks', 0) == 3:
logging.warning(checkname + " ignoring render " + repr(name) + " since it's marked as \"don't render\".")
else:
render['renderchecks'] = num

if options.forcerender:
logging.info("Forcerender mode activated. ALL tiles will be rendered")
for render in config['renders'].itervalues():
render['renderchecks'] = 2
set_renderchecks("forcerender", 2)
elif options.checktiles:
logging.info("Checking all tiles for updates manually.")
for render in config['renders'].itervalues():
render['renderchecks'] = 1
set_renderchecks("checktiles", 1)
elif options.notilechecks:
logging.info("Disabling all tile mtime checks. Only rendering tiles "+
"that need updating since last render")
for render in config['renders'].itervalues():
render['renderchecks'] = 0
set_renderchecks("notilechecks", 0)

if not config['renders']:
logging.error("You must specify at least one render in your config file. See the docs if you're having trouble")
Expand Down
36 changes: 33 additions & 3 deletions overviewer_core/tileset.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ def iterate_base4(d):
# slowest, but SHOULD be specified if this is the first render because
# the scan will forgo tile stat calls. It's also useful for changing
# texture packs or other options that effect the output.

# 3
# A very special mode. Using this will not actually render
# anything, but will leave this tileset in the resulting
# map. Useful for renders that you want to keep, but not
# update. Since this mode is so simple, it's left out of the
# rest of this discussion.

#
# For 0 our caller has explicitly requested not to check mtimes on disk to
# speed things up. So the mode 0 chunk scan only looks at chunk mtimes and the
Expand Down Expand Up @@ -238,6 +246,13 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
useful for changing texture packs or other options that effect
the output.
3
A very special mode. Using this will not actually render
anything, but will leave this tileset in the resulting
map. Useful for renders that you want to keep, but not
update. Since this mode is so simple, it's left out of the
rest of this discussion.
imgformat
A string indicating the output format. Must be one of 'png' or
'jpeg'
Expand Down Expand Up @@ -390,6 +405,11 @@ def do_preprocessing(self):
attribute for later use in iterate_work_items()
"""

# skip if we're told to
if self.options['renderchecks'] == 3:
return

# REMEMBER THAT ATTRIBUTES ASSIGNED IN THIS METHOD ARE NOT AVAILABLE IN
# THE do_work() METHOD (because this is only called in the main process
# not the workers)
Expand All @@ -416,15 +436,16 @@ def get_num_phases(self):
return 1

def get_phase_length(self, phase):
"""Returns the number of work items in a given phase, or None if there
is no good estimate.
"""Returns the number of work items in a given phase.
"""
# Yeah functional programming!
# and by functional we mean a bastardized python switch statement
return {
0: lambda: self.dirtytree.count_all(),
#there is no good way to guess this so just give total count
1: lambda: (4**(self.treedepth+1)-1)/3,
2: lambda: self.dirtytree.count_all(),
3: lambda: 0,
}[self.options['renderchecks']]()

def iterate_work_items(self, phase):
Expand All @@ -434,6 +455,10 @@ def iterate_work_items(self, phase):
This method returns an iterator over (obj, [dependencies, ...])
"""

# skip if asked to
if self.options['renderchecks'] == 3:
return

# The following block of code implementes the changelist functionality.
fd = self.options.get("changelist", None)
if fd:
Expand Down Expand Up @@ -536,6 +561,11 @@ def get_persistent_data(self):
def bgcolorformat(color):
return "#%02x%02x%02x" % color[0:3]
isOverlay = self.options.get("overlay") or (not any(isinstance(x, rendermodes.Base) for x in self.options.get("rendermode")))

# don't update last render time if we're leaving this alone
last_rendertime = self.last_rendertime
if self.options['renderchecks'] != 3:
last_rendertime = self.max_chunk_mtime

d = dict(name = self.options.get('title'),
zoomLevels = self.treedepth,
Expand All @@ -546,7 +576,7 @@ def bgcolorformat(color):
bgcolor = bgcolorformat(self.options.get('bgcolor')),
world = self.options.get('worldname_orig') +
(" - " + self.options.get('dimension')[0] if self.options.get('dimension')[1] != 0 else ''),
last_rendertime = self.max_chunk_mtime,
last_rendertime = last_rendertime,
imgextension = self.imgextension,
isOverlay = isOverlay,
poititle = self.options.get("poititle"),
Expand Down

0 comments on commit 7c23d6e

Please sign in to comment.