static void lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) { RenderPrimitiveLighting* self; int x, y, z; self = (RenderPrimitiveLighting *)data; x = state->x, y = state->y, z = state->z; if ((state->block == 9) || (state->block == 79)) { /* special case for water and ice */ /* looks like we need a new case for lighting, there are * blocks that are transparent for occlusion calculations and * need per-face shading if the face is drawn. */ if ((state->block_pdata & 16) == 16) { do_shading_with_mask(self, state, x, y+1, z, self->facemasks[0]); } if ((state->block_pdata & 2) == 2) { /* bottom left */ do_shading_with_mask(self, state, x-1, y, z, self->facemasks[1]); } if ((state->block_pdata & 4) == 4) { /* bottom right */ do_shading_with_mask(self, state, x, y, z+1, self->facemasks[2]); } /* leaves are transparent for occlusion calculations but they * per face-shading to look as in game */ } else if (is_transparent(state->block) && (state->block != 18)) { /* transparent: do shading on whole block */ do_shading_with_mask(self, state, x, y, z, mask_light); } else { /* opaque: do per-face shading */ do_shading_with_mask(self, state, x, y+1, z, self->facemasks[0]); do_shading_with_mask(self, state, x-1, y, z, self->facemasks[1]); do_shading_with_mask(self, state, x, y, z+1, self->facemasks[2]); } }
static void rendermode_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask) { RenderModeLighting* self; int x, y, z; /* first, chain up */ rendermode_normal.draw(data, state, src, mask); self = (RenderModeLighting *)data; x = state->x, y = state->y, z = state->z; if (is_transparent(state->block)) { /* transparent: do shading on whole block */ do_shading_with_mask(self, state, x, y, z, mask); } else { /* opaque: do per-face shading */ do_shading_with_mask(self, state, x, y, z+1, self->facemasks[0]); do_shading_with_mask(self, state, x-1, y, z, self->facemasks[1]); do_shading_with_mask(self, state, x, y+1, z, self->facemasks[2]); } }