overlay mode now only considers blocks where overlays make sense
This commit is contained in:
@@ -30,6 +30,9 @@ rendermode_overlay_start(void *data, RenderState *state) {
|
|||||||
|
|
||||||
self->white_color = PyObject_GetAttrString(state->chunk, "white_color");
|
self->white_color = PyObject_GetAttrString(state->chunk, "white_color");
|
||||||
|
|
||||||
|
self->solid_blocks = PyObject_GetAttrString(state->chunk, "solid_blocks");
|
||||||
|
self->fluid_blocks = PyObject_GetAttrString(state->chunk, "fluid_blocks");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +40,10 @@ static void
|
|||||||
rendermode_overlay_finish(void *data, RenderState *state) {
|
rendermode_overlay_finish(void *data, RenderState *state) {
|
||||||
RenderModeOverlay *self = (RenderModeOverlay *)data;
|
RenderModeOverlay *self = (RenderModeOverlay *)data;
|
||||||
|
|
||||||
Py_XDECREF(self->facemask_top);
|
Py_DECREF(self->facemask_top);
|
||||||
Py_XDECREF(self->white_color);
|
Py_DECREF(self->white_color);
|
||||||
|
Py_DECREF(self->solid_blocks);
|
||||||
|
Py_DECREF(self->fluid_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -62,6 +67,36 @@ rendermode_overlay_draw(void *data, RenderState *state, PyObject *src, PyObject
|
|||||||
/* clear the draw space -- set alpha to 0 within mask */
|
/* 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);
|
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);
|
||||||
|
if (!is_transparent(top_block)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check to be sure this block is solid/fluid */
|
||||||
|
PyObject *top_block_py = PyInt_FromLong(top_block);
|
||||||
|
if (PySequence_Contains(self->solid_blocks, top_block_py) ||
|
||||||
|
PySequence_Contains(self->fluid_blocks, top_block_py)) {
|
||||||
|
|
||||||
|
/* top block is fluid or solid, skip drawing */
|
||||||
|
Py_DECREF(top_block_py);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Py_DECREF(top_block_py);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check to be sure this block is solid/fluid */
|
||||||
|
PyObject *block_py = PyInt_FromLong(state->block);
|
||||||
|
if (!PySequence_Contains(self->solid_blocks, block_py) &&
|
||||||
|
!PySequence_Contains(self->fluid_blocks, block_py)) {
|
||||||
|
|
||||||
|
/* not fluid or solid, skip drawing the overlay */
|
||||||
|
Py_DECREF(block_py);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Py_DECREF(block_py);
|
||||||
|
|
||||||
/* do the overlay */
|
/* do the overlay */
|
||||||
alpha_over_full(state->img, self->white_color, self->facemask_top, 0.5, state->imgx, state->imgy, 0, 0);
|
alpha_over_full(state->img, self->white_color, self->facemask_top, 0.5, state->imgx, state->imgy, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ extern RenderModeInterface rendermode_normal;
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/* top facemask and white color image, for drawing overlays */
|
/* top facemask and white color image, for drawing overlays */
|
||||||
PyObject *facemask_top, *white_color;
|
PyObject *facemask_top, *white_color;
|
||||||
|
/* only show overlay on top of solid or fluid blocks */
|
||||||
|
PyObject *solid_blocks, *fluid_blocks;
|
||||||
} RenderModeOverlay;
|
} RenderModeOverlay;
|
||||||
extern RenderModeInterface rendermode_overlay;
|
extern RenderModeInterface rendermode_overlay;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user