0

Load the 4 adjacent blocks in iterate.c

This commit is contained in:
Alejandro Aguilera
2011-03-24 23:40:01 +01:00
parent 7daa1bac9d
commit 4da53b4f9c
2 changed files with 23 additions and 4 deletions

View File

@@ -70,6 +70,10 @@ chunk_render(PyObject *self, PyObject *args) {
int imgsize0, imgsize1; int imgsize0, imgsize1;
PyObject *blocks_py; PyObject *blocks_py;
PyObject *left_blocks_py;
PyObject *right_blocks_py;
PyObject *up_left_blocks_py;
PyObject *up_right_blocks_py;
RenderModeInterface *rendermode; RenderModeInterface *rendermode;
@@ -109,10 +113,17 @@ chunk_render(PyObject *self, PyObject *args) {
blocks_py = PyObject_GetAttrString(state.self, "blocks"); blocks_py = PyObject_GetAttrString(state.self, "blocks");
state.blocks = blocks_py; state.blocks = blocks_py;
/* left_blocks_py = PyObject_GetAttrString(state.self, "left_blocks");
PyObject *left_blocks = PyObject_GetAttrString(chunk, "left_blocks"); state.left_blocks = left_blocks_py;
PyObject *right_blocks = PyObject_GetAttrString(chunk, "right_blocks");
*/ right_blocks_py = PyObject_GetAttrString(state.self, "right_blocks");
state.right_blocks = right_blocks_py;
up_left_blocks_py = PyObject_GetAttrString(state.self, "up_left_blocks");
state.up_left_blocks = up_left_blocks_py;
up_right_blocks_py = PyObject_GetAttrString(state.self, "up_right_blocks");
state.up_right_blocks = up_right_blocks_py;
for (state.x = 15; state.x > -1; state.x--) { for (state.x = 15; state.x > -1; state.x--) {
for (state.y = 0; state.y < 16; state.y++) { for (state.y = 0; state.y < 16; state.y++) {
@@ -203,6 +214,10 @@ chunk_render(PyObject *self, PyObject *args) {
free(rm_data); free(rm_data);
Py_DECREF(blocks_py); Py_DECREF(blocks_py);
Py_XDECREF(left_blocks_py);
Py_XDECREF(right_blocks_py);
Py_XDECREF(up_left_blocks_py);
Py_XDECREF(up_right_blocks_py);
return Py_BuildValue("i",2); return Py_BuildValue("i",2);
} }

View File

@@ -62,6 +62,10 @@ typedef struct {
int x, y, z; int x, y, z;
unsigned char block; unsigned char block;
PyObject *blocks; PyObject *blocks;
PyObject *up_left_blocks;
PyObject *up_right_blocks;
PyObject *left_blocks;
PyObject *right_blocks;
} RenderState; } RenderState;
int init_chunk_render(void); int init_chunk_render(void);
int is_transparent(unsigned char b); int is_transparent(unsigned char b);