0

edge-lines and nether primitives in working order

This commit is contained in:
Aaron Griffith
2012-02-21 15:05:00 -05:00
parent a8c298fe4e
commit c5f2077d51
2 changed files with 36 additions and 37 deletions

View File

@@ -34,10 +34,10 @@ 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
@@ -45,36 +45,19 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
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);
/* +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);
}
} 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);
}
}
// 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);
/* -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);
}
} 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);
}
}
}
}

View File

@@ -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)
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;
}
if (!missing_section && get_data(state, BLOCKS, x, y, z) == 0)
{
return 0;
break;
}
z++;
y++;
}
return 1;
}