summaryrefslogtreecommitdiff
path: root/src/mapgen_v5.cpp
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-02-24 04:06:05 +0000
committerparamat <mat.gregory@virginmedia.com>2015-02-26 03:35:25 +0000
commit14f7df980b5be20339ab637a96bdc08ac907abf2 (patch)
tree1b6ceec8154071c8eff4dc115eb778e2dbbe6146 /src/mapgen_v5.cpp
parentd65a90a86bf5f1422a64ff190abefb8f7f199460 (diff)
downloadminetest-14f7df980b5be20339ab637a96bdc08ac907abf2.tar.gz
minetest-14f7df980b5be20339ab637a96bdc08ac907abf2.tar.bz2
minetest-14f7df980b5be20339ab637a96bdc08ac907abf2.zip
Biome API: Re-calculate biome at every surface in a mapchunk column
Diffstat (limited to 'src/mapgen_v5.cpp')
-rw-r--r--src/mapgen_v5.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp
index ed18f7d0b..e3624c2bd 100644
--- a/src/mapgen_v5.cpp
+++ b/src/mapgen_v5.cpp
@@ -228,14 +228,16 @@ void MapgenV5::makeChunk(BlockMakeData *data)
// Generate base terrain
s16 stone_surface_max_y = generateBaseTerrain();
+
+ // Create heightmap
updateHeightmap(node_min, node_max);
- // Calculate biomes
+ // Create biomemap at heightmap surface
bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result,
noise_humidity->result, heightmap, biomemap);
// Actually place the biome-specific nodes
- generateBiomes();
+ generateBiomes(noise_heat->result, noise_humidity->result);
// Generate caves
if ((flags & MG_CAVES) && (stone_surface_max_y >= node_min.Y))
@@ -354,7 +356,7 @@ int MapgenV5::generateBaseTerrain()
}
-void MapgenV5::generateBiomes()
+void MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
{
if (node_max.Y < water_level)
return;
@@ -368,12 +370,11 @@ void MapgenV5::generateBiomes()
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
- Biome *biome = (Biome *)bmgr->get(biomemap[index]);
- s16 dfiller = biome->depth_filler + noise_filler_depth->result[index];
- s16 y0_top = biome->depth_top;
- s16 y0_filler = biome->depth_top + dfiller;
- s16 shore_max = water_level + biome->height_shore;
- s16 depth_water_top = biome->depth_water_top;
+ Biome *biome = NULL;
+ s16 dfiller = 0;
+ s16 y0_top = 0;
+ s16 y0_filler = 0;
+ s16 depth_water_top = 0;
s16 nplaced = 0;
u32 i = vm->m_area.index(x, node_max.Y, z);
@@ -384,25 +385,23 @@ void MapgenV5::generateBiomes()
for (s16 y = node_max.Y; y >= node_min.Y; y--) {
content_t c = vm->m_data[i].getContent();
+ if (c != CONTENT_IGNORE && c != CONTENT_AIR && (y == node_max.Y || have_air)) {
+ biome = bmgr->getBiome(heat_map[index], humidity_map[index], y);
+ dfiller = biome->depth_filler + noise_filler_depth->result[index];
+ y0_top = biome->depth_top;
+ y0_filler = biome->depth_top + dfiller;
+ depth_water_top = biome->depth_water_top;
+ }
+
if (c == c_stone && have_air) {
content_t c_below = vm->m_data[i - em.X].getContent();
if (c_below != CONTENT_AIR) {
if (nplaced < y0_top) {
- if(y < water_level)
- vm->m_data[i] = MapNode(biome->c_underwater);
- else if(y <= shore_max)
- vm->m_data[i] = MapNode(biome->c_shore_top);
- else
- vm->m_data[i] = MapNode(biome->c_top);
+ vm->m_data[i] = MapNode(biome->c_top);
nplaced++;
} else if (nplaced < y0_filler && nplaced >= y0_top) {
- if(y < water_level)
- vm->m_data[i] = MapNode(biome->c_underwater);
- else if(y <= shore_max)
- vm->m_data[i] = MapNode(biome->c_shore_filler);
- else
- vm->m_data[i] = MapNode(biome->c_filler);
+ vm->m_data[i] = MapNode(biome->c_filler);
nplaced++;
} else if (c == c_stone) {
have_air = false;