From c5f2077d511fe6e5ab7c705e7d18ab6249a80b55 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Tue, 21 Feb 2012 15:05:00 -0500 Subject: [PATCH] edge-lines and nether primitives in working order --- overviewer_core/src/primitives/edge-lines.c | 43 +++++++-------------- overviewer_core/src/primitives/nether.c | 30 ++++++++++---- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/overviewer_core/src/primitives/edge-lines.c b/overviewer_core/src/primitives/edge-lines.c index f30d2a6..f708369 100644 --- a/overviewer_core/src/primitives/edge-lines.c +++ b/overviewer_core/src/primitives/edge-lines.c @@ -34,46 +34,29 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P PrimitiveEdgeLines *self = (PrimitiveEdgeLines *)data; /* Draw some edge lines! */ - // draw.line(((imgx+12,imgy+increment), (imgx+22,imgy+5+increment)), fill=(0,0,0), width=1) if (state->block == 44 || state->block == 78 || !is_transparent(state->block)) { Imaging img_i = imaging_python_to_c(state->img); unsigned char ink[] = {0, 0, 0, 255 * self->opacity}; + unsigned short side_block; int increment=0; if (state->block == 44) // half-step increment=6; else if ((state->block == 78) || (state->block == 93) || (state->block == 94)) // snow, redstone repeaters (on and off) increment=9; - - if ((state->x == 15) && (state->up_right_blocks != NULL)) { - unsigned char side_block = getArrayByte3D(state->up_right_blocks, 0, state->y, state->z); - if (side_block != state->block && is_transparent(side_block)) { - ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1); - ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1); - } - } else if (state->x != 15) { - unsigned char side_block = getArrayByte3D(state->blocks, state->x+1, state->y, state->z); - if (side_block != state->block && is_transparent(side_block)) { - ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1); - ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1); - } + + /* +X side */ + side_block = get_data(state, BLOCKS, state->x+1, state->y, state->z); + if (side_block != state->block && is_transparent(side_block)) { + ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1); + ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1); } - // if y != 0 and blocks[x,y-1,z] == 0 - - // chunk boundries are annoying - if ((state->y == 0) && (state->up_left_blocks != NULL)) { - unsigned char side_block = getArrayByte3D(state->up_left_blocks, state->x, 15, state->z); - if (side_block != state->block && is_transparent(side_block)) { - ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1); - ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1); - } - } else if (state->y != 0) { - unsigned char side_block = getArrayByte3D(state->blocks, state->x, state->y-1, state->z); - if (side_block != state->block && is_transparent(side_block)) { - // draw.line(((imgx,imgy+6+increment), (imgx+12,imgy+increment)), fill=(0,0,0), width=1) - ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1); - ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1); - } + + /* -Z side */ + side_block = get_data(state, BLOCKS, state->x, state->y, state->z-1); + if (side_block != state->block && is_transparent(side_block)) { + ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1); + ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1); } } } diff --git a/overviewer_core/src/primitives/nether.c b/overviewer_core/src/primitives/nether.c index 3844d1c..50f7c8f 100644 --- a/overviewer_core/src/primitives/nether.c +++ b/overviewer_core/src/primitives/nether.c @@ -19,15 +19,31 @@ static int nether_hidden(void *data, RenderState *state, int x, int y, int z) { - /* hide all blocks above all air blocks */ - while (z < 128) + /* hide all blocks above all air blocks + + due to how the nether is currently generated, this will also count + empty sections as 'solid' + */ + unsigned char missing_section = 0; + while (y < (SECTIONS_PER_CHUNK - state->chunky) * 16) { - if (getArrayByte3D(state->blocks, x, y, z) == 0) - { - return 0; - break; + if (state->chunks[1][1].sections[state->chunky + (y / 16)].blocks == NULL) { + missing_section = 1; + y += 16; + continue; + } else { + /* if we passed through a missing section, but now are back in, + that counts as air */ + if (missing_section) + return 0; + missing_section = 0; } - z++; + + if (!missing_section && get_data(state, BLOCKS, x, y, z) == 0) + { + return 0; + } + y++; } return 1; }