fixes to get lighting mode working again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "overviewer.h"
|
||||
|
||||
static PyObject *textures = NULL;
|
||||
static PyObject *support = NULL;
|
||||
|
||||
unsigned int max_blockid = 0;
|
||||
unsigned int max_data = 0;
|
||||
@@ -46,6 +47,11 @@ PyObject *init_chunk_render(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
support = PyImport_ImportModule("overviewer_core.rendermodes");
|
||||
if (!support) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmp = PyObject_GetAttrString(textures, "max_blockid");
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
@@ -96,7 +102,9 @@ PyObject *init_chunk_render(void) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject *get_chunk_data(PyObject *region_set, int x, int z, ChunkNeighborName neighbor, ChunkDataType type) {
|
||||
PyObject *get_chunk_data(RenderState *state, ChunkNeighborName neighbor, ChunkDataType type) {
|
||||
int x = state->chunkx;
|
||||
int z = state->chunkz;
|
||||
PyObject *chunk = NULL;
|
||||
PyObject *data = NULL;
|
||||
|
||||
@@ -117,7 +125,7 @@ PyObject *get_chunk_data(PyObject *region_set, int x, int z, ChunkNeighborName n
|
||||
break;
|
||||
}
|
||||
|
||||
chunk = PyObject_CallMethod(region_set, "get_chunk", "ii", x, z);
|
||||
chunk = PyObject_CallMethod(state->regionset, "get_chunk", "ii", x, z);
|
||||
if (chunk == NULL || chunk == Py_None)
|
||||
return chunk;
|
||||
|
||||
@@ -401,10 +409,8 @@ chunk_render(PyObject *self, PyObject *args) {
|
||||
if (!PyArg_ParseTuple(args, "OiiOiisO", &state.regionset, &state.chunkx, &state.chunkz, &state.img, &xoff, &yoff, &rendermode_name, &state.textures))
|
||||
return NULL;
|
||||
|
||||
/* conveniences */
|
||||
regionset = state.regionset;
|
||||
chunkx = state.chunkx;
|
||||
chunkz = state.chunkz;
|
||||
/* rendermode support */
|
||||
state.support = support;
|
||||
|
||||
/* set up the render mode */
|
||||
state.rendermode = rendermode = render_mode_create(rendermode_name, &state);
|
||||
@@ -435,25 +441,25 @@ chunk_render(PyObject *self, PyObject *args) {
|
||||
Py_DECREF(imgsize1_py);
|
||||
|
||||
/* get the block data directly from numpy: */
|
||||
blocks_py = get_chunk_data(regionset, chunkx, chunkz, CURRENT, BLOCKS);
|
||||
blocks_py = get_chunk_data(&state, CURRENT, BLOCKS);
|
||||
state.blocks = blocks_py;
|
||||
if (blocks_py == Py_None) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "chunk does not exist!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state.blockdatas = get_chunk_data(regionset, chunkx, chunkz, CURRENT, BLOCKDATA);
|
||||
state.blockdatas = get_chunk_data(&state, CURRENT, BLOCKDATA);
|
||||
|
||||
left_blocks_py = get_chunk_data(regionset, chunkx, chunkz, DOWN_LEFT, BLOCKS);
|
||||
left_blocks_py = get_chunk_data(&state, DOWN_LEFT, BLOCKS);
|
||||
state.left_blocks = left_blocks_py;
|
||||
|
||||
right_blocks_py = get_chunk_data(regionset, chunkx, chunkz, DOWN_RIGHT, BLOCKS);
|
||||
right_blocks_py = get_chunk_data(&state, DOWN_RIGHT, BLOCKS);
|
||||
state.right_blocks = right_blocks_py;
|
||||
|
||||
up_left_blocks_py = get_chunk_data(regionset, chunkx, chunkz, UP_LEFT, BLOCKS);
|
||||
up_left_blocks_py = get_chunk_data(&state, UP_LEFT, BLOCKS);
|
||||
state.up_left_blocks = up_left_blocks_py;
|
||||
|
||||
up_right_blocks_py = get_chunk_data(regionset, chunkx, chunkz, UP_RIGHT, BLOCKS);
|
||||
up_right_blocks_py = get_chunk_data(&state, UP_RIGHT, BLOCKS);
|
||||
state.up_right_blocks = up_right_blocks_py;
|
||||
|
||||
/* set up the random number generator again for each chunk
|
||||
|
||||
@@ -79,6 +79,9 @@ typedef struct {
|
||||
/* the Texture object */
|
||||
PyObject *textures;
|
||||
|
||||
/* the rendermode support module (rendermodes.py) */
|
||||
PyObject *support;
|
||||
|
||||
/* the block position and type, and the block array */
|
||||
int x, y, z;
|
||||
unsigned char block;
|
||||
@@ -137,7 +140,7 @@ typedef enum
|
||||
UP_RIGHT, /* +1, 0 */
|
||||
UP_LEFT, /* 0, -1 */
|
||||
} ChunkNeighborName;
|
||||
PyObject *get_chunk_data(PyObject *region_set, int x, int z, ChunkNeighborName neighbor, ChunkDataType type);
|
||||
PyObject *get_chunk_data(RenderState *state, ChunkNeighborName neighbor, ChunkDataType type);
|
||||
|
||||
/* pull in the rendermode info */
|
||||
#include "rendermodes.h"
|
||||
|
||||
@@ -360,22 +360,22 @@ rendermode_lighting_start(void *data, RenderState *state, PyObject *options) {
|
||||
if (!render_mode_parse_option(options, "color_light", "i", &(self->color_light)))
|
||||
return 1;
|
||||
|
||||
self->facemasks_py = PyObject_GetAttrString(state->chunk, "facemasks");
|
||||
self->facemasks_py = PyObject_GetAttrString(state->support, "facemasks");
|
||||
// borrowed references, don't need to be decref'd
|
||||
self->facemasks[0] = PyTuple_GetItem(self->facemasks_py, 0);
|
||||
self->facemasks[1] = PyTuple_GetItem(self->facemasks_py, 1);
|
||||
self->facemasks[2] = PyTuple_GetItem(self->facemasks_py, 2);
|
||||
|
||||
self->skylight = PyObject_GetAttrString(state->self, "skylight");
|
||||
self->blocklight = PyObject_GetAttrString(state->self, "blocklight");
|
||||
self->left_skylight = PyObject_GetAttrString(state->self, "left_skylight");
|
||||
self->left_blocklight = PyObject_GetAttrString(state->self, "left_blocklight");
|
||||
self->right_skylight = PyObject_GetAttrString(state->self, "right_skylight");
|
||||
self->right_blocklight = PyObject_GetAttrString(state->self, "right_blocklight");
|
||||
self->up_left_skylight = PyObject_GetAttrString(state->self, "up_left_skylight");
|
||||
self->up_left_blocklight = PyObject_GetAttrString(state->self, "up_left_blocklight");
|
||||
self->up_right_skylight = PyObject_GetAttrString(state->self, "up_right_skylight");
|
||||
self->up_right_blocklight = PyObject_GetAttrString(state->self, "up_right_blocklight");
|
||||
self->skylight = get_chunk_data(state, CURRENT, SKYLIGHT);
|
||||
self->blocklight = get_chunk_data(state, CURRENT, BLOCKLIGHT);
|
||||
self->left_skylight = get_chunk_data(state, DOWN_LEFT, SKYLIGHT);
|
||||
self->left_blocklight = get_chunk_data(state, DOWN_LEFT, BLOCKLIGHT);
|
||||
self->right_skylight = get_chunk_data(state, DOWN_RIGHT, SKYLIGHT);
|
||||
self->right_blocklight = get_chunk_data(state, DOWN_RIGHT, BLOCKLIGHT);
|
||||
self->up_left_skylight = get_chunk_data(state, UP_LEFT, SKYLIGHT);
|
||||
self->up_left_blocklight = get_chunk_data(state, UP_LEFT, BLOCKLIGHT);
|
||||
self->up_right_skylight = get_chunk_data(state, UP_RIGHT, SKYLIGHT);
|
||||
self->up_right_blocklight = get_chunk_data(state, UP_RIGHT, BLOCKLIGHT);
|
||||
|
||||
if (self->night) {
|
||||
self->calculate_light_color = calculate_light_color_night;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
that are only useful as a base for other modes. */
|
||||
static RenderModeInterface *render_modes[] = {
|
||||
&rendermode_normal,
|
||||
/*&rendermode_lighting,
|
||||
&rendermode_smooth_lighting,
|
||||
&rendermode_lighting,
|
||||
/*&rendermode_smooth_lighting,
|
||||
&rendermode_spawn,
|
||||
&rendermode_cave,
|
||||
&rendermode_mineral,*/
|
||||
|
||||
Reference in New Issue
Block a user