From f5ab056b388b856a70bca7a028b58a258532716f Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 13 Mar 2013 01:18:45 +0400 Subject: [PATCH] Liquid fine tuning --- games/minimal/mods/default/mapgen.lua | 23 +++-- minetest.conf.example | 6 +- src/content_mapblock.cpp | 2 +- src/defaultsettings.cpp | 7 +- src/map.cpp | 127 ++++++++++++++++++-------- 5 files changed, 112 insertions(+), 53 deletions(-) diff --git a/games/minimal/mods/default/mapgen.lua b/games/minimal/mods/default/mapgen.lua index 115bb1458..74fc398b2 100644 --- a/games/minimal/mods/default/mapgen.lua +++ b/games/minimal/mods/default/mapgen.lua @@ -69,10 +69,19 @@ local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, end minetest.register_on_generated(function(minp, maxp, seed) - generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5) - generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17) + generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64 ) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7 ) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5 ) + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17 ) + + if minetest.setting_getbool("underground_springs") then + generate_ore("default:water_source", "default:stone", minp, maxp, seed+4, 1/24/24/24, 12, -100, -11, 128) + generate_ore("default:water_source", "default:stone", minp, maxp, seed+5, 1/28/28/28, 8, -10000, -101, 128) + generate_ore("default:lava_source", "default:stone", minp, maxp, seed+6, 1/38/38/38, 6, -500, -101, 128) + generate_ore("default:lava_source", "default:stone", minp, maxp, seed+7, 1/30/30/30, 16, -5000, -501, 128) + generate_ore("default:lava_source", "default:stone", minp, maxp, seed+8, 1/24/24/24, 20, -31000, -5001, 128) + end + -- Generate clay if maxp.y >= 2 and minp.y <= 0 then -- Assume X and Z lengths are equal @@ -110,11 +119,5 @@ minetest.register_on_generated(function(minp, maxp, seed) end end end - if minetest.setting_get("liquid_finite") then - generate_ore("default:water_source", "default:stone", minp, maxp, seed+42, 1/24/24/24, 4, -100, -10, 128) - generate_ore("default:water_source", "default:stone", minp, maxp, seed+42, 1/28/28/28, 3, -10000, -101, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+43, 1/38/38/38, 2, -500, -100, 128) - generate_ore("default:lava_source", "default:stone", minp, maxp, seed+43, 1/30/30/30, 4, -31000, -501, 128) - end end) diff --git a/minetest.conf.example b/minetest.conf.example index daca1616d..41a691b1a 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -95,9 +95,11 @@ # Update liquids every .. recommend for finite: 0.2 #liquid_update = 1.0 # When finite liquid: relax flowing blocks to source if level near max and N nearby source blocks, more realistic, but not true constant. values: 0,1,2,3,4 : 0 - disable, 1 - most aggresive -#liquid_relax = 1 -# optimization: faster cave flood (and not true constant) +#liquid_relax = 2 +# Optimization: faster cave flood (and not true constant) #liquid_fast_flood = 1 +# Underground water and lava springs, its infnity sources if liquid_finite enabled +#underground_springs = 1 # Enable nice leaves; disable for speed #new_style_leaves = true # Enable smooth lighting with simple ambient occlusion; diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 3b001510e..ef447da6b 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -324,7 +324,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data, } } if(air_count >= 2) - cornerlevel = -0.5*BS+0.1; + cornerlevel = -0.5*BS+0.2; else if(valid_count > 0) cornerlevel /= valid_count; corner_levels[i] = cornerlevel; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 3ec0ad9fc..8f878648a 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -203,16 +203,17 @@ void set_default_settings(Settings *settings) settings->setDefault("movement_liquid_fluidity_smooth", "0.5"); settings->setDefault("movement_liquid_sink", "10"); settings->setDefault("movement_gravity", "9.81"); - + //liquid stuff settings->setDefault("liquid_finite", "false"); settings->setDefault("liquid_update", "1.0"); - settings->setDefault("liquid_relax", "1"); + settings->setDefault("liquid_relax", "2"); settings->setDefault("liquid_fast_flood", "1"); + settings->setDefault("underground_springs", "1"); //mapgen stuff settings->setDefault("mg_name", "v6"); - settings->setDefault("water_level", "1"); + settings->setDefault("water_level", "1"); settings->setDefault("chunksize", "5"); settings->setDefault("mg_flags", "trees, caves, v6_biome_blend"); settings->setDefault("mgv6_freq_desert", "0.45"); diff --git a/src/map.cpp b/src/map.cpp index 2439c7091..6103b9017 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1639,19 +1639,16 @@ void Map::transformLiquidsFinite(std::map & modified_blocks) bool fast_flood = g_settings->getS16("liquid_fast_flood"); int water_level = g_settings->getS16("water_level"); - /*if(initial_size != 0) - infostream<<"transformLiquids(): initial_size="< must_reflow, must_reflow_second; // List of MapBlocks that will require a lighting update (due to lava) std::map lighting_modified_blocks; - while(m_transforming_liquid.size() > 0) + while (m_transforming_liquid.size() > 0) { // This should be done here so that it is done when continue is used - if(loopcount >= initial_size || loopcount >= 1000) + if (loopcount >= initial_size || loopcount >= 1000) break; loopcount++; /* @@ -1659,9 +1656,12 @@ void Map::transformLiquidsFinite(std::map & modified_blocks) */ v3s16 p0 = m_transforming_liquid.pop_front(); u16 total_level = 0; - NodeNeighbor neighbors[7]; // surrounding flowing liquid nodes - s8 liquid_levels[7] = {-1, -1, -1, -1, -1, -1, -1}; // current level of every block - s8 liquid_levels_want[7] = {-1, -1, -1, -1, -1, -1, -1}; // target levels + // surrounding flowing liquid nodes + NodeNeighbor neighbors[7]; + // current level of every block + s8 liquid_levels[7] = {-1, -1, -1, -1, -1, -1, -1}; + // target levels + s8 liquid_levels_want[7] = {-1, -1, -1, -1, -1, -1, -1}; s8 can_liquid_same_level = 0; content_t liquid_kind = CONTENT_IGNORE; content_t liquid_kind_flowing = CONTENT_IGNORE; @@ -1696,9 +1696,11 @@ void Map::transformLiquidsFinite(std::map & modified_blocks) } break; case LIQUID_SOURCE: - // if this node is not (yet) of a liquid type, choose the first liquid type we encounter + // if this node is not (yet) of a liquid type, + // choose the first liquid type we encounter if (liquid_kind_flowing == CONTENT_IGNORE) - liquid_kind_flowing = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing); + liquid_kind_flowing = nodemgr->getId( + nodemgr->get(nb.n).liquid_alternative_flowing); if (liquid_kind == CONTENT_IGNORE) liquid_kind = nb.n.getContent(); if (nb.n.getContent() == liquid_kind) { @@ -1708,37 +1710,55 @@ void Map::transformLiquidsFinite(std::map & modified_blocks) } break; case LIQUID_FLOWING: - // if this node is not (yet) of a liquid type, choose the first liquid type we encounter + // if this node is not (yet) of a liquid type, + // choose the first liquid type we encounter if (liquid_kind_flowing == CONTENT_IGNORE) liquid_kind_flowing = nb.n.getContent(); if (liquid_kind == CONTENT_IGNORE) - liquid_kind = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_source); + liquid_kind = nodemgr->getId( + nodemgr->get(nb.n).liquid_alternative_source); if (nb.n.getContent() == liquid_kind_flowing) { liquid_levels[i] = (nb.n.param2 & LIQUID_LEVEL_MASK); nb.l = 1; } break; } - if (nb.l && nb.t == NEIGHBOR_SAME_LEVEL) ++can_liquid_same_level; - if (liquid_levels[i] > 0) total_level += liquid_levels[i]; + + if (nb.l && nb.t == NEIGHBOR_SAME_LEVEL) + ++can_liquid_same_level; + if (liquid_levels[i] > 0) + total_level += liquid_levels[i]; /* - infostream << "get node i=" <<(int)i<<" " << PP(npos) << " c="<getBool("liquid_finite")) + return Map::transformLiquidsFinite(modified_blocks); INodeDefManager *nodemgr = m_gamedef->ndef(); -- 2.25.1