From c3e79459d4b30af0139dc761328979df5471257f Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Wed, 15 Jun 2011 00:28:32 -0400 Subject: [PATCH 1/9] fix for running on PIL 1.1.5 and earlier --- textures.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/textures.py b/textures.py index 5171285..5e2db3b 100644 --- a/textures.py +++ b/textures.py @@ -493,13 +493,7 @@ def generate_opaque_mask(img): smallers than 50, and sets every other value to 255. """ alpha = img.split()[3] - pixel = alpha.load() - for x in range(img.size[0]): - for y in range(img.size[1]): - if pixel[x,y] > 25: - pixel[x,y] = 255 - - return alpha + return alpha.point(lambda a: int(min(a, 25.5) * 10)) def generate_texture_tuple(img, blockid): """ This takes an image and returns the needed tuple for the From 0bb484bdf7891e564157527d5426475d1ea48c8e Mon Sep 17 00:00:00 2001 From: Eric Carr Date: Wed, 15 Jun 2011 15:09:04 +0200 Subject: [PATCH 2/9] Added mouseover coords --- web_assets/overviewer.css | 2 +- web_assets/overviewer.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/web_assets/overviewer.css b/web_assets/overviewer.css index dc435fa..dbb3830 100644 --- a/web_assets/overviewer.css +++ b/web_assets/overviewer.css @@ -82,7 +82,7 @@ body { } -#link { +#link, #coordsDiv { background-color: #fff; /* fallback */ background-color: rgba(255,255,255,0.55); border: 1px solid rgb(0, 0, 0); diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index ceeb7dc..ea87a19 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -591,6 +591,17 @@ var overviewer = { overviewer.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv); } + // Coords box + var coordsDiv = document.createElement('DIV'); + coordsDiv.id = 'coordsDiv'; + coordsDiv.innerHTML = ''; + overviewer.map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(coordsDiv); + // Update coords on mousemove + google.maps.event.addListener(overviewer.map, 'mousemove', function (event) { + var worldcoords = overviewer.util.fromLatLngToWorld(event.latLng.lat(), event.latLng.lng()); + coordsDiv.innerHTML = "Coords: X " + Math.round(worldcoords.x) + ", Z " + Math.round(worldcoords.z); + }); + // only need to create the control if there are items in the list. // as defined in config.js if (overviewerConfig.objectGroups.signs.length > 0) { From 091a76fe60becbea77d757e602248c18c38ea9f1 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Wed, 15 Jun 2011 10:26:16 -0400 Subject: [PATCH 3/9] added sans-serif font styling to whole page, in line with other controls --- web_assets/overviewer.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web_assets/overviewer.css b/web_assets/overviewer.css index dbb3830..f4bdd98 100644 --- a/web_assets/overviewer.css +++ b/web_assets/overviewer.css @@ -7,6 +7,10 @@ body { margin: 0px; padding: 0px; background-color: #000; + + font-family: Arial, sans-serif; + font-size: 12px; + line-height: 160%; } #mcmap { From b1a386cae98560d4df2638880c02b96ef0d14099 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Thu, 16 Jun 2011 06:26:58 -0700 Subject: [PATCH 4/9] fixed sample.settings.py typo --- sample.settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample.settings.py b/sample.settings.py index 8c85a3e..3b6aed2 100644 --- a/sample.settings.py +++ b/sample.settings.py @@ -6,7 +6,7 @@ # provide examples of interesting things you can do with the settings file. Most # of the time, a simple 'setting_name = value' will work. -# This file is a python script, so you can import and python module you wish or +# This file is a python script, so you can import any python module you wish or # use any built-in python function, though this is not normally necessary # Lines that start with a hash mark are comments From 6cf0cc514715a4e79751489810231a1678857755 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Sat, 18 Jun 2011 11:51:13 -0400 Subject: [PATCH 5/9] Fixed regionlist regression --- quadtree.py | 9 +++++---- world.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/quadtree.py b/quadtree.py index f1c4b1d..fc00b01 100644 --- a/quadtree.py +++ b/quadtree.py @@ -426,9 +426,6 @@ class QuadtreeGen(object): needs_rerender = False get_region_mtime = world.get_region_mtime for col, row, chunkx, chunky, regionfile in chunks: - # don't even check if it's not in the regionlist - if self.world.regionlist and region._filename not in self.world.regionlist: - continue # bail early if forcerender is set if self.forcerender: @@ -439,7 +436,11 @@ class QuadtreeGen(object): region,regionMtime = get_region_mtime(regionfile) if regionMtime <= tile_mtime: continue - + + # don't even check if it's not in the regionlist + if self.world.regionlist and os.path.abspath(region._filename) not in self.world.regionlist: + continue + # checking chunk mtime if region.get_chunk_timestamp(chunkx, chunky) > tile_mtime: needs_rerender = True diff --git a/world.py b/world.py index 564d193..7d4ce0d 100644 --- a/world.py +++ b/world.py @@ -78,7 +78,7 @@ class World(object): logging.info("Scanning regions") regionfiles = {} self.regions = {} - self.regionlist = regionlist # a list of paths + self.regionlist = map(os.path.abspath, regionlist) # a list of paths for x, y, regionfile in self._iterate_regionfiles(): mcr = self.reload_region(regionfile) mcr.get_chunk_info() From 312624e96cc780ab4de9c3f1d7aef56d900ab9ae Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Sat, 18 Jun 2011 14:59:37 -0400 Subject: [PATCH 6/9] Fix regression introduced by regression fix --- world.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/world.py b/world.py index 7d4ce0d..1344d10 100644 --- a/world.py +++ b/world.py @@ -78,7 +78,10 @@ class World(object): logging.info("Scanning regions") regionfiles = {} self.regions = {} - self.regionlist = map(os.path.abspath, regionlist) # a list of paths + if regionlist: + self.regionlist = map(os.path.abspath, regionlist) # a list of paths + else: + self.regionlist = None for x, y, regionfile in self._iterate_regionfiles(): mcr = self.reload_region(regionfile) mcr.get_chunk_info() From fdadda0ea60133a5b89e37f59fcaadebe095fb1c Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Sun, 19 Jun 2011 01:10:03 +0200 Subject: [PATCH 7/9] Move the average lighting coeff to another function. Take the average over blockmap. Fixes problems with stairs in night and lighting rendermode. --- src/rendermode-lighting.c | 150 +++++++++++++++++++++++++++----------- src/rendermodes.h | 2 +- 2 files changed, 107 insertions(+), 45 deletions(-) diff --git a/src/rendermode-lighting.c b/src/rendermode-lighting.c index d0d4c64..35dc688 100644 --- a/src/rendermode-lighting.c +++ b/src/rendermode-lighting.c @@ -33,21 +33,106 @@ static float calculate_darkness(unsigned char skylight, unsigned char blocklight * was calculated correctly from available light data, it will be true. You * may (and probably should) pass NULL. */ + +inline unsigned char +estimate_blocklevel(RenderModeLighting *self, RenderState *state, + int x, int y, int z, int *authoratative) { + + /* placeholders for later data arrays, coordinates */ + PyObject *blocks = NULL; + PyObject *blocklight = NULL; + int local_x = x, local_y = y, local_z = z; + unsigned char block, blocklevel; + unsigned int average_count = 0, average_gather = 0, coeff = 0; + + /* defaults to "guess" until told otherwise */ + if (authoratative) + *authoratative = 0; + + /* find out what chunk we're in, and translate accordingly */ + if (x >= 0 && y < 16) { + blocks = state->blocks; + blocklight = self->blocklight; + } else if (x < 0) { + local_x += 16; + blocks = state->left_blocks; + blocklight = self->left_blocklight; + } else if (y >= 16) { + local_y -= 16; + blocks = state->right_blocks; + blocklight = self->right_blocklight; + } + + /* make sure we have correctly-ranged coordinates */ + if (!(local_x >= 0 && local_x < 16 && + local_y >= 0 && local_y < 16 && + local_z >= 0 && local_z < 128)) { + + return 0; + } + + /* also, make sure we have enough info to correctly calculate lighting */ + if (blocks == Py_None || blocks == NULL || + blocklight == Py_None || blocklight == NULL) { + + return 0; + } + + block = getArrayByte3D(blocks, local_x, local_y, local_z); + + if (authoratative == NULL) { + int auth; + + /* iterate through all surrounding blocks to take an average */ + int dx, dy, dz, local_block; + //~ printf("\n[Starting loop]\n"); + for (dx = -1; dx <= 1; dx += 2) { + for (dy = -1; dy <= 1; dy += 2) { + for (dz = -1; dz <= 1; dz += 2) { + coeff = estimate_blocklevel(self, state, x+dx, y+dy, z+dz, &auth); + local_block = getArrayByte3D(blocks, x+dx, y+dy, z+dz); + if (auth && is_transparent(local_block)) { + average_gather += coeff; + average_count++; + } + //~ printf(" [Inside the loop] Coeff = %d, average_gather = %d, average_count = %d, auth = %d, block = %d\n", coeff, average_gather, average_count, auth, local_block); + } + } + } + } + + /* only return the average if at least one was authoratative */ + if (average_count > 0) { + int result; + float resultf; + result = average_gather / average_count; + resultf = average_gather / average_count; + //~ printf("[Outside the loop] average_gather = %d, average_count = %d\n", average_gather, average_count); + //~ printf("[Outside the loop] result = %d, resultf = %f\n", result, resultf); + return average_gather / average_count; + } + + blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); + + /* no longer a guess */ + if (!(block == 44 || block == 53 || block == 67) && authoratative) { + *authoratative = 1; + } + + return blocklevel; +} + inline float get_lighting_coefficient(RenderModeLighting *self, RenderState *state, - int x, int y, int z, int *authoratative) { - + int x, int y, int z) { + /* placeholders for later data arrays, coordinates */ PyObject *blocks = NULL; PyObject *skylight = NULL; PyObject *blocklight = NULL; int local_x = x, local_y = y, local_z = z; unsigned char block, skylevel, blocklevel; - - /* defaults to "guess" until told otherwise */ - if (authoratative) - *authoratative = 0; - + /* find out what chunk we're in, and translate accordingly */ if (x >= 0 && y < 16) { blocks = state->blocks; @@ -64,7 +149,7 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, skylight = self->right_skylight; blocklight = self->right_blocklight; } - + /* make sure we have correctly-ranged coordinates */ if (!(local_x >= 0 && local_x < 16 && local_y >= 0 && local_y < 16 && @@ -72,7 +157,7 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, return self->calculate_darkness(15, 0); } - + /* also, make sure we have enough info to correctly calculate lighting */ if (blocks == Py_None || blocks == NULL || skylight == Py_None || skylight == NULL || @@ -89,13 +174,16 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, return self->calculate_darkness(15, 0); } + skylevel = getArrayByte3D(skylight, local_x, local_y, local_z); + blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); + //~ if (block == 0 && blocklevel != 0) { + //~ printf("Para este aire tenemos skylevel %d, blocklevel %d\n", skylevel, blocklevel); + //~ } + /* only do special half-step handling if no authoratative pointer was passed in, which is a sign that we're recursing */ - if ((block == 44 || block == 53 || block == 67) && authoratative == NULL) { - float average_gather = 0.0f; - unsigned int average_count = 0, upper_block; - int auth; - float coeff; + if (block == 44 || block == 53 || block == 67) { + unsigned int upper_block; if (local_z != 127) { /* stairs and half-blocks take the skylevel from the upper block if it's transparent */ upper_block = getArrayByte3D(blocks, local_x, local_y, local_z + 1); @@ -108,29 +196,10 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, skylevel = 15; blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); } + + /* use given coordinates, no local ones! */ + blocklevel = estimate_blocklevel(self, state, x, y, z, NULL); - if (skylevel) { /* if we have a good skylevel use it, if not iterate */ - return self->calculate_darkness(skylevel, blocklevel); - } else { - - /* iterate through all surrounding blocks to take an average */ - int dx, dy, dz; - for (dx = -1; dx <= 1; dx += 2) { - for (dy = -1; dy <= 1; dy += 2) { - for (dz = -1; dz <= 1; dz += 2) { - coeff = get_lighting_coefficient(self, state, x+dx, y+dy, z+dz, &auth); - if (auth) { - average_gather += coeff; - average_count++; - } - } - } - } - - /* only return the average if at least one was authoratative */ - if (average_count > 0) - return average_gather / average_count; - } } if (block == 10 || block == 11) { @@ -138,13 +207,6 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, return 0.0f; } - skylevel = getArrayByte3D(skylight, local_x, local_y, local_z); - blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); - - /* no longer a guess */ - if (authoratative) - *authoratative = 1; - return self->calculate_darkness(skylevel, blocklevel); } @@ -164,7 +226,7 @@ do_shading_with_mask(RenderModeLighting *self, RenderState *state, } } - black_coeff = get_lighting_coefficient(self, state, x, y, z, NULL); + black_coeff = get_lighting_coefficient(self, state, x, y, z); alpha_over_full(state->img, self->black_color, mask, black_coeff, state->imgx, state->imgy, 0, 0); } diff --git a/src/rendermodes.h b/src/rendermodes.h index 80126a4..bd8748a 100644 --- a/src/rendermodes.h +++ b/src/rendermodes.h @@ -118,7 +118,7 @@ typedef struct { } RenderModeLighting; extern RenderModeInterface rendermode_lighting; inline float get_lighting_coefficient(RenderModeLighting *self, RenderState *state, - int x, int y, int z, int *authoratative); + int x, int y, int z); /* NIGHT */ typedef struct { From 8eda22055fcfab3241a0d3fa4e0378aedf70115b Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Sun, 19 Jun 2011 01:25:41 +0200 Subject: [PATCH 8/9] Add comments. Delete printfs. --- src/rendermode-lighting.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/rendermode-lighting.c b/src/rendermode-lighting.c index 35dc688..e5f75bc 100644 --- a/src/rendermode-lighting.c +++ b/src/rendermode-lighting.c @@ -85,17 +85,17 @@ estimate_blocklevel(RenderModeLighting *self, RenderState *state, /* iterate through all surrounding blocks to take an average */ int dx, dy, dz, local_block; - //~ printf("\n[Starting loop]\n"); for (dx = -1; dx <= 1; dx += 2) { for (dy = -1; dy <= 1; dy += 2) { for (dz = -1; dz <= 1; dz += 2) { coeff = estimate_blocklevel(self, state, x+dx, y+dy, z+dz, &auth); local_block = getArrayByte3D(blocks, x+dx, y+dy, z+dz); + /* only add if the block is transparent, this seems to look better than + using every block */ if (auth && is_transparent(local_block)) { average_gather += coeff; average_count++; } - //~ printf(" [Inside the loop] Coeff = %d, average_gather = %d, average_count = %d, auth = %d, block = %d\n", coeff, average_gather, average_count, auth, local_block); } } } @@ -103,12 +103,6 @@ estimate_blocklevel(RenderModeLighting *self, RenderState *state, /* only return the average if at least one was authoratative */ if (average_count > 0) { - int result; - float resultf; - result = average_gather / average_count; - resultf = average_gather / average_count; - //~ printf("[Outside the loop] average_gather = %d, average_count = %d\n", average_gather, average_count); - //~ printf("[Outside the loop] result = %d, resultf = %f\n", result, resultf); return average_gather / average_count; } @@ -176,16 +170,13 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, skylevel = getArrayByte3D(skylight, local_x, local_y, local_z); blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); - //~ if (block == 0 && blocklevel != 0) { - //~ printf("Para este aire tenemos skylevel %d, blocklevel %d\n", skylevel, blocklevel); - //~ } - /* only do special half-step handling if no authoratative pointer was - passed in, which is a sign that we're recursing */ + /* special half-step handling */ if (block == 44 || block == 53 || block == 67) { unsigned int upper_block; - if (local_z != 127) { /* stairs and half-blocks take the skylevel from the upper block if it's transparent */ + /* stairs and half-blocks take the skylevel from the upper block if it's transparent */ + if (local_z != 127) { upper_block = getArrayByte3D(blocks, local_x, local_y, local_z + 1); if (is_transparent(upper_block)) { skylevel = getArrayByte3D(skylight, local_x, local_y, local_z + 1); @@ -197,6 +188,7 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); } + /* the block has a bad blocklevel, estimate it from neigborhood /* use given coordinates, no local ones! */ blocklevel = estimate_blocklevel(self, state, x, y, z, NULL); From 278eabbae312a7fbf021d9fe2ac0e1fd245995c4 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Sun, 19 Jun 2011 01:36:41 +0200 Subject: [PATCH 9/9] Remove unused access to blocklight array. --- src/rendermode-lighting.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rendermode-lighting.c b/src/rendermode-lighting.c index e5f75bc..0a92554 100644 --- a/src/rendermode-lighting.c +++ b/src/rendermode-lighting.c @@ -181,11 +181,9 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, if (is_transparent(upper_block)) { skylevel = getArrayByte3D(skylight, local_x, local_y, local_z + 1); } - blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); } else { upper_block = 0; skylevel = 15; - blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z); } /* the block has a bad blocklevel, estimate it from neigborhood