0

moved rendermode_normal into a separate file, like rendermode_lighting

This commit is contained in:
Aaron Griffith
2011-03-22 23:09:12 -04:00
parent a885568d4e
commit 24950f6024
3 changed files with 59 additions and 40 deletions

View File

@@ -44,7 +44,8 @@ except AttributeError:
numpy_include = numpy.get_numpy_include() numpy_include = numpy.get_numpy_include()
c_overviewer_files = ['src/main.c', 'src/composite.c', 'src/iterate.c', 'src/rendermodes.c', 'src/rendermode-lighting.c'] c_overviewer_files = ['src/main.c', 'src/composite.c', 'src/iterate.c']
c_overviewer_files += ['src/rendermodes.c', 'src/rendermode-normal.c', 'src/rendermode-lighting.c']
setup_kwargs['ext_modules'].append(Extension('c_overviewer', c_overviewer_files, include_dirs=['.', numpy_include], extra_link_args=["/MANIFEST"] if platform.system() == "Windows" else [])) setup_kwargs['ext_modules'].append(Extension('c_overviewer', c_overviewer_files, include_dirs=['.', numpy_include], extra_link_args=["/MANIFEST"] if platform.system() == "Windows" else []))
# tell build_ext to build the extension in-place # tell build_ext to build the extension in-place
# (NOT in build/) # (NOT in build/)

56
src/rendermode-normal.c Normal file
View File

@@ -0,0 +1,56 @@
/*
* This file is part of the Minecraft Overviewer.
*
* Minecraft Overviewer is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Minecraft Overviewer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "overviewer.h"
static int
rendermode_normal_start(void *data, RenderState *state) {
/* do nothing */
return 0;
}
static void
rendermode_normal_finish(void *data, RenderState *state) {
/* do nothing */
}
static int
rendermode_normal_occluded(void *data, RenderState *state) {
int x = state->x, y = state->y, z = state->z;
if ( (x != 0) && (y != 15) && (z != 127) &&
!is_transparent(getArrayByte3D(state->blocks, x-1, y, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y+1, z))) {
return 1;
}
return 0;
}
static void
rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *mask) {
alpha_over(state->img, src, mask, state->imgx, state->imgy, 0, 0);
}
RenderModeInterface rendermode_normal = {
sizeof(RenderModeNormal),
rendermode_normal_start,
rendermode_normal_finish,
rendermode_normal_occluded,
rendermode_normal_draw,
};

View File

@@ -17,45 +17,7 @@
#include "overviewer.h" #include "overviewer.h"
static int /* decides which render mode to use */
rendermode_normal_start(void *data, RenderState *state) {
/* do nothing */
return 0;
}
static void
rendermode_normal_finish(void *data, RenderState *state) {
/* do nothing */
}
static int
rendermode_normal_occluded(void *data, RenderState *state) {
int x = state->x, y = state->y, z = state->z;
if ( (x != 0) && (y != 15) && (z != 127) &&
!is_transparent(getArrayByte3D(state->blocks, x-1, y, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y+1, z))) {
return 1;
}
return 0;
}
static void
rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *mask) {
alpha_over(state->img, src, mask, state->imgx, state->imgy, 0, 0);
}
RenderModeInterface rendermode_normal = {
sizeof(RenderModeNormal),
rendermode_normal_start,
rendermode_normal_finish,
rendermode_normal_occluded,
rendermode_normal_draw,
};
/* putting it all together */
RenderModeInterface *get_render_mode(RenderState *state) { RenderModeInterface *get_render_mode(RenderState *state) {
/* default: normal */ /* default: normal */
RenderModeInterface *iface = &rendermode_normal; RenderModeInterface *iface = &rendermode_normal;