0

added biomes option to Base primitive (default: True)

fixes Issue #644
This commit is contained in:
Aaron Griffith
2012-03-15 04:54:20 -04:00
parent ab22724fc7
commit 9be414e540
2 changed files with 29 additions and 14 deletions

View File

@@ -43,6 +43,9 @@ class RenderPrimitive(object):
class Base(RenderPrimitive): class Base(RenderPrimitive):
name = "base" name = "base"
options = {
"biomes": ("whether or not to use biomes", True),
}
class Nether(RenderPrimitive): class Nether(RenderPrimitive):
name = "nether" name = "nether"

View File

@@ -17,7 +17,10 @@
#include "../overviewer.h" #include "../overviewer.h"
#define DEFAULT_BIOME 4 /* forest, nice and green */
typedef struct { typedef struct {
int use_biomes;
/* grasscolor and foliagecolor lookup tables */ /* grasscolor and foliagecolor lookup tables */
PyObject *grasscolor, *foliagecolor, *watercolor; PyObject *grasscolor, *foliagecolor, *watercolor;
/* biome-compatible grass/leaf textures */ /* biome-compatible grass/leaf textures */
@@ -74,6 +77,9 @@ static int
base_start(void *data, RenderState *state, PyObject *support) { base_start(void *data, RenderState *state, PyObject *support) {
PrimitiveBase *self = (PrimitiveBase *)data; PrimitiveBase *self = (PrimitiveBase *)data;
if (!render_mode_parse_option(support, "biomes", "i", &(self->use_biomes)))
return 1;
/* biome-compliant grass mask (includes sides!) */ /* biome-compliant grass mask (includes sides!) */
self->grass_texture = PyObject_GetAttrString(state->textures, "biome_grass_texture"); self->grass_texture = PyObject_GetAttrString(state->textures, "biome_grass_texture");
@@ -205,6 +211,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
float temp = 0.0, rain = 0.0; float temp = 0.0, rain = 0.0;
PyObject *color = NULL; PyObject *color = NULL;
if (self->use_biomes) {
/* average over all neighbors */ /* average over all neighbors */
for (dx = -1; dx <= 1; dx++) { for (dx = -1; dx <= 1; dx++) {
for (dz = -1; dz <= 1; dz += (dx == 0 ? 2 : 1)) { for (dz = -1; dz <= 1; dz += (dx == 0 ? 2 : 1)) {
@@ -213,7 +220,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
/* note -- biome 255 shows up on map borders. /* note -- biome 255 shows up on map borders.
who knows what it is? certainly not I. who knows what it is? certainly not I.
*/ */
biome = 4; /* forest -- reasonable default */ biome = DEFAULT_BIOME; /* forest -- reasonable default */
} }
temp += biome_table[biome].temperature; temp += biome_table[biome].temperature;
@@ -222,6 +229,11 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
} }
temp /= 8.0; temp /= 8.0;
rain /= 8.0; rain /= 8.0;
} else {
/* don't use biomes, just use the default */
temp = biome_table[DEFAULT_BIOME].temperature;
rain = biome_table[DEFAULT_BIOME].rainfall;
}
/* second coordinate is actually scaled to fit inside the triangle /* second coordinate is actually scaled to fit inside the triangle
so store it in rain */ so store it in rain */