0

broke out background-clearing code from base overlay primitive

This commit is contained in:
Aaron Griffith
2012-02-26 11:52:43 -05:00
parent 2b7af1886a
commit 5d50f35ac1
7 changed files with 56 additions and 23 deletions

View File

@@ -146,6 +146,9 @@ class Lighting(RenderPrimitive):
class SmoothLighting(Lighting):
name = "smooth-lighting"
class ClearBase(RenderPrimitive):
name = "clear-base"
class Overlay(RenderPrimitive):
name = "overlay"

View File

@@ -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 21
#define OVERVIEWER_EXTENSION_VERSION 22
/* Python PIL, and numpy headers */
#include <Python.h>

View File

@@ -0,0 +1,49 @@
/*
* This file is part of the Minecraft Overviewer.
*
* Minecraft Overviewer is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Minecraft Overviewer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../overviewer.h"
static int
clear_base_occluded(void *data, RenderState *state, int x, int y, int z) {
if ( (x != 0) && (y != 15) && (z != 127) &&
!render_mode_hidden(state->rendermode, x-1, y, z) &&
!render_mode_hidden(state->rendermode, x, y, z+1) &&
!render_mode_hidden(state->rendermode, x, y+1, z) &&
!is_transparent(getArrayByte3D(state->blocks, x-1, y, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y+1, z))) {
return 1;
}
return 0;
}
static void
clear_base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
/* clear the draw space -- set alpha to 0 within mask */
tint_with_mask(state->img, 255, 255, 255, 0, mask, state->imgx, state->imgy, 0, 0);
}
RenderPrimitiveInterface primitive_clear_base = {
"clear-base",
0,
NULL,
NULL,
clear_base_occluded,
NULL,
clear_base_draw,
};

View File

@@ -144,7 +144,7 @@ RenderPrimitiveInterface primitive_overlay_mineral = {
sizeof(RenderPrimitiveMineral),
overlay_mineral_start,
overlay_mineral_finish,
overlay_occluded,
NULL,
NULL,
overlay_draw,
};

View File

@@ -102,7 +102,7 @@ RenderPrimitiveInterface primitive_overlay_spawn = {
sizeof(RenderPrimitiveSpawn),
overlay_spawn_start,
overlay_spawn_finish,
overlay_occluded,
NULL,
NULL,
overlay_draw,
};

View File

@@ -45,21 +45,6 @@ overlay_finish(void *data, RenderState *state) {
Py_DECREF(self->white_color);
}
int
overlay_occluded(void *data, RenderState *state, int x, int y, int z) {
if ( (x != 0) && (y != 15) && (z != 127) &&
!render_mode_hidden(state->rendermode, x-1, y, z) &&
!render_mode_hidden(state->rendermode, x, y, z+1) &&
!render_mode_hidden(state->rendermode, x, y+1, z) &&
!is_transparent(getArrayByte3D(state->blocks, x-1, y, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y+1, z))) {
return 1;
}
return 0;
}
void
overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
RenderPrimitiveOverlay *self = (RenderPrimitiveOverlay *)data;
@@ -72,9 +57,6 @@ overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyOb
else if (state->block == 78) // snow
increment=9;
/* clear the draw space -- set alpha to 0 within mask */
tint_with_mask(state->img, 255, 255, 255, 0, mask, state->imgx, state->imgy, 0, 0);
/* skip rendering the overlay if we can't see it */
if (state->z != 127) {
unsigned char top_block = getArrayByte3D(state->blocks, state->x, state->y, state->z+1);
@@ -112,7 +94,7 @@ RenderPrimitiveInterface primitive_overlay = {
sizeof(RenderPrimitiveOverlay),
overlay_start,
overlay_finish,
overlay_occluded,
NULL,
NULL,
overlay_draw,
};

View File

@@ -29,4 +29,3 @@ typedef struct {
extern RenderPrimitiveInterface primitive_overlay;
void overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light);
int overlay_occluded(void *data, RenderState *state, int x, int y, int z);