From f4a1c32d1a83dc824fd9ef91d51ba8f4c20c3221 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Tue, 5 Jun 2012 01:09:47 -0400 Subject: [PATCH] added sealevel option to HeightFading primitive --- docs/config.rst | 7 +++++++ overviewer_core/rendermodes.py | 4 ++++ overviewer_core/src/overviewer.h | 2 +- overviewer_core/src/primitives/height-fading.c | 6 +++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 45db947..c4496f6 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -619,6 +619,13 @@ Nether HeightFading Draws a colored overlay on the blocks that fades them out according to their height. + + **Options** + + sealevel + sealevel of the word you're rendering. Note that the default, + 128, is usually *incorrect* for most worlds. You should + probably set this to 64. Default: 128 Depth Only renders blocks between the specified min and max heights. diff --git a/overviewer_core/rendermodes.py b/overviewer_core/rendermodes.py index 382630a..5de04e6 100644 --- a/overviewer_core/rendermodes.py +++ b/overviewer_core/rendermodes.py @@ -52,6 +52,10 @@ class Nether(RenderPrimitive): class HeightFading(RenderPrimitive): name = "height-fading" + options = { + # 128 is *WRONG*, it should be 64. but we're grandfathered in for now + "sealevel": ("target sea level", 128), + } black_color = Image.new("RGB", (24,24), (0,0,0)) white_color = Image.new("RGB", (24,24), (255,255,255)) diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index af15a4d..0bca02d 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -26,7 +26,7 @@ // increment this value if you've made a change to the c extesion // and want to force users to rebuild -#define OVERVIEWER_EXTENSION_VERSION 34 +#define OVERVIEWER_EXTENSION_VERSION 35 /* Python PIL, and numpy headers */ #include diff --git a/overviewer_core/src/primitives/height-fading.c b/overviewer_core/src/primitives/height-fading.c index ae7f85b..e177492 100644 --- a/overviewer_core/src/primitives/height-fading.c +++ b/overviewer_core/src/primitives/height-fading.c @@ -20,12 +20,16 @@ typedef struct { PyObject *black_color; PyObject *white_color; + unsigned int sealevel; } PrimitiveHeightFading; static int height_fading_start(void *data, RenderState *state, PyObject *support) { PrimitiveHeightFading *self = (PrimitiveHeightFading *)data; + if (!render_mode_parse_option(support, "sealevel", "I", &(self->sealevel))) + return 1; + self->black_color = PyObject_GetAttrString(support, "black_color"); self->white_color = PyObject_GetAttrString(support, "white_color"); @@ -50,7 +54,7 @@ height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask PyObject *height_color = self->white_color; /* current formula requires y to be between 0 and 127, so scale it */ - y = (y * 128) / (16 * SECTIONS_PER_CHUNK); + y = (y * 128) / (2 * self->sealevel); /* negative alpha => darkness, positive => light */ alpha = (1.0 / (1 + expf((70 - y) / 11.0))) * 0.6 - 0.55;