broke out background-clearing code from base overlay primitive
This commit is contained in:
@@ -146,6 +146,9 @@ class Lighting(RenderPrimitive):
|
|||||||
class SmoothLighting(Lighting):
|
class SmoothLighting(Lighting):
|
||||||
name = "smooth-lighting"
|
name = "smooth-lighting"
|
||||||
|
|
||||||
|
class ClearBase(RenderPrimitive):
|
||||||
|
name = "clear-base"
|
||||||
|
|
||||||
class Overlay(RenderPrimitive):
|
class Overlay(RenderPrimitive):
|
||||||
name = "overlay"
|
name = "overlay"
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// increment this value if you've made a change to the c extesion
|
// increment this value if you've made a change to the c extesion
|
||||||
// and want to force users to rebuild
|
// and want to force users to rebuild
|
||||||
#define OVERVIEWER_EXTENSION_VERSION 21
|
#define OVERVIEWER_EXTENSION_VERSION 22
|
||||||
|
|
||||||
/* Python PIL, and numpy headers */
|
/* Python PIL, and numpy headers */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|||||||
49
overviewer_core/src/primitives/clear-base.c
Normal file
49
overviewer_core/src/primitives/clear-base.c
Normal 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,
|
||||||
|
};
|
||||||
@@ -144,7 +144,7 @@ RenderPrimitiveInterface primitive_overlay_mineral = {
|
|||||||
sizeof(RenderPrimitiveMineral),
|
sizeof(RenderPrimitiveMineral),
|
||||||
overlay_mineral_start,
|
overlay_mineral_start,
|
||||||
overlay_mineral_finish,
|
overlay_mineral_finish,
|
||||||
overlay_occluded,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
overlay_draw,
|
overlay_draw,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ RenderPrimitiveInterface primitive_overlay_spawn = {
|
|||||||
sizeof(RenderPrimitiveSpawn),
|
sizeof(RenderPrimitiveSpawn),
|
||||||
overlay_spawn_start,
|
overlay_spawn_start,
|
||||||
overlay_spawn_finish,
|
overlay_spawn_finish,
|
||||||
overlay_occluded,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
overlay_draw,
|
overlay_draw,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,21 +45,6 @@ overlay_finish(void *data, RenderState *state) {
|
|||||||
Py_DECREF(self->white_color);
|
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
|
void
|
||||||
overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
||||||
RenderPrimitiveOverlay *self = (RenderPrimitiveOverlay *)data;
|
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
|
else if (state->block == 78) // snow
|
||||||
increment=9;
|
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 */
|
/* skip rendering the overlay if we can't see it */
|
||||||
if (state->z != 127) {
|
if (state->z != 127) {
|
||||||
unsigned char top_block = getArrayByte3D(state->blocks, state->x, state->y, state->z+1);
|
unsigned char top_block = getArrayByte3D(state->blocks, state->x, state->y, state->z+1);
|
||||||
@@ -112,7 +94,7 @@ RenderPrimitiveInterface primitive_overlay = {
|
|||||||
sizeof(RenderPrimitiveOverlay),
|
sizeof(RenderPrimitiveOverlay),
|
||||||
overlay_start,
|
overlay_start,
|
||||||
overlay_finish,
|
overlay_finish,
|
||||||
overlay_occluded,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
overlay_draw,
|
overlay_draw,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,4 +29,3 @@ typedef struct {
|
|||||||
extern RenderPrimitiveInterface primitive_overlay;
|
extern RenderPrimitiveInterface primitive_overlay;
|
||||||
|
|
||||||
void overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light);
|
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);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user