0

Tall grass is now biome tinted.

This commit is contained in:
Alejandro Aguilera
2011-05-31 18:21:47 +02:00
parent fcd29234ff
commit d95ae73286
5 changed files with 33 additions and 7 deletions

View File

@@ -293,7 +293,6 @@ PyObject*
chunk_render(PyObject *self, PyObject *args) { chunk_render(PyObject *self, PyObject *args) {
RenderState state; RenderState state;
PyObject *blockdata_expanded;
int xoff, yoff; int xoff, yoff;
PyObject *imgsize, *imgsize0_py, *imgsize1_py; PyObject *imgsize, *imgsize0_py, *imgsize1_py;
@@ -311,7 +310,7 @@ chunk_render(PyObject *self, PyObject *args) {
PyObject *t = NULL; PyObject *t = NULL;
if (!PyArg_ParseTuple(args, "OOiiO", &state.self, &state.img, &xoff, &yoff, &blockdata_expanded)) if (!PyArg_ParseTuple(args, "OOiiO", &state.self, &state.img, &xoff, &yoff, &state.blockdata_expanded))
return NULL; return NULL;
/* fill in important modules */ /* fill in important modules */
@@ -402,7 +401,7 @@ chunk_render(PyObject *self, PyObject *args) {
} else { } else {
PyObject *tmp; PyObject *tmp;
unsigned char ancilData = getArrayByte3D(blockdata_expanded, state.x, state.y, state.z); unsigned char ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z);
if ((state.block == 85) || (state.block == 9) || (state.block == 55) || (state.block == 54) || (state.block == 2) || (state.block == 90)) { if ((state.block == 85) || (state.block == 9) || (state.block == 55) || (state.block == 54) || (state.block == 2) || (state.block == 90)) {
ancilData = generate_pseudo_data(&state, ancilData); ancilData = generate_pseudo_data(&state, ancilData);
} }

View File

@@ -70,6 +70,7 @@ typedef struct {
/* the block position and type, and the block array */ /* the block position and type, and the block array */
int x, y, z; int x, y, z;
unsigned char block; unsigned char block;
PyObject *blockdata_expanded;
PyObject *blocks; PyObject *blocks;
PyObject *up_left_blocks; PyObject *up_left_blocks;
PyObject *up_right_blocks; PyObject *up_right_blocks;

View File

@@ -56,6 +56,7 @@ rendermode_normal_start(void *data, RenderState *state) {
self->leaf_texture = NULL; self->leaf_texture = NULL;
self->grass_texture = NULL; self->grass_texture = NULL;
self->tall_grass_texture = NULL;
self->facemask_top = NULL; self->facemask_top = NULL;
} else { } else {
@@ -64,6 +65,7 @@ rendermode_normal_start(void *data, RenderState *state) {
self->leaf_texture = PyObject_GetAttrString(state->textures, "biome_leaf_texture"); self->leaf_texture = PyObject_GetAttrString(state->textures, "biome_leaf_texture");
self->grass_texture = PyObject_GetAttrString(state->textures, "biome_grass_texture"); self->grass_texture = PyObject_GetAttrString(state->textures, "biome_grass_texture");
self->tall_grass_texture = PyObject_GetAttrString(state->textures, "biome_tall_grass_texture");
facemasks_py = PyObject_GetAttrString(state->chunk, "facemasks"); facemasks_py = PyObject_GetAttrString(state->chunk, "facemasks");
/* borrowed reference, needs to be incref'd if we keep it */ /* borrowed reference, needs to be incref'd if we keep it */
@@ -78,6 +80,7 @@ rendermode_normal_start(void *data, RenderState *state) {
self->leaf_texture = NULL; self->leaf_texture = NULL;
self->grass_texture = NULL; self->grass_texture = NULL;
self->tall_grass_texture = NULL;
self->facemask_top = NULL; self->facemask_top = NULL;
} }
@@ -98,6 +101,7 @@ rendermode_normal_finish(void *data, RenderState *state) {
Py_XDECREF(self->grasscolor); Py_XDECREF(self->grasscolor);
Py_XDECREF(self->leaf_texture); Py_XDECREF(self->leaf_texture);
Py_XDECREF(self->grass_texture); Py_XDECREF(self->grass_texture);
Py_XDECREF(self->tall_grass_texture);
Py_XDECREF(self->facemask_top); Py_XDECREF(self->facemask_top);
} }
@@ -120,8 +124,17 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
RenderModeNormal *self = (RenderModeNormal *)data; RenderModeNormal *self = (RenderModeNormal *)data;
/* first, check to see if we should use biome-compatible src, mask */ /* first, check to see if we should use biome-compatible src, mask */
if (self->biome_data && state->block == 18) { if (self->biome_data) {
src = mask = self->leaf_texture; if (state->block == 18) {
src = mask = self->leaf_texture;
} else if (state->block == 31) {
unsigned char data = getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z);
if (data == 1) {
src = mask = self->tall_grass_texture;
} else if (data == 2) {
src = mask = self->tall_fern_texture;
}
}
} }
/* draw the block! */ /* draw the block! */
@@ -150,6 +163,15 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
color = PySequence_GetItem(self->foliagecolor, index); color = PySequence_GetItem(self->foliagecolor, index);
facemask = mask; facemask = mask;
break; break;
case 31:
/* tall grass */
if ( getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z) != 0 )
{ /* do not tint dead shrubs */
color = PySequence_GetItem(self->grasscolor, index);
facemask = mask;
break;
}
break;
default: default:
break; break;
}; };

View File

@@ -79,7 +79,7 @@ typedef struct {
/* grasscolor and foliagecolor lookup tables */ /* grasscolor and foliagecolor lookup tables */
PyObject *grasscolor, *foliagecolor; PyObject *grasscolor, *foliagecolor;
/* biome-compatible grass/leaf textures */ /* biome-compatible grass/leaf textures */
PyObject *grass_texture, *leaf_texture; PyObject *grass_texture, *leaf_texture, *tall_grass_texture, *tall_fern_texture;
/* top facemask for grass biome tinting */ /* top facemask for grass biome tinting */
PyObject *facemask_top; PyObject *facemask_top;
} RenderModeNormal; } RenderModeNormal;

View File

@@ -1659,6 +1659,8 @@ special_map[31] = range(3) # tall grass, dead shrub, fern and tall grass itself
terrain_images = None terrain_images = None
blockmap = None blockmap = None
biome_grass_texture = None biome_grass_texture = None
biome_tall_grass_texture = None
biome_tall_fern_texture = None
biome_leaf_texture = None biome_leaf_texture = None
specialblockmap = None specialblockmap = None
@@ -1676,9 +1678,11 @@ def generate(path=None):
load_water() load_water()
# generate biome (still grayscale) leaf, grass textures # generate biome (still grayscale) leaf, grass textures
global biome_grass_texture, biome_leaf_texture global biome_grass_texture, biome_leaf_texture, biome_tall_grass_texture
biome_grass_texture = _build_block(terrain_images[0], terrain_images[38], 2) biome_grass_texture = _build_block(terrain_images[0], terrain_images[38], 2)
biome_leaf_texture = _build_block(terrain_images[52], terrain_images[52], 18) biome_leaf_texture = _build_block(terrain_images[52], terrain_images[52], 18)
biome_tall_grass_texture = _build_block(terrain_images[39], terrain_images[39], 31)
biome_tall_fern_texture = _build_block(terrain_images[56], terrain_images[56], 31)
# generate the special blocks # generate the special blocks
global specialblockmap, special_blocks global specialblockmap, special_blocks