From 350596b94f3d886812cb453e05540a16c3db5e5b Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 5 Mar 2013 17:23:03 -0500 Subject: Add cloud menu background by Krisi, configurable with the menu_clouds option. Also add a menuheader, menusplash, menufooter_clouds, and allow HD menu footers. And finally don't git-ignore textures/base/. --- minetest.conf.example | 2 ++ 1 file changed, 2 insertions(+) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 1f2a764f2..daca1616d 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -125,6 +125,8 @@ #farmesh_distance = 40 # Enable/disable clouds #enable_clouds = true +# Use a cloud animation for the main menu background +#menu_clouds = true # Path for screenshots #screenshot_path = . # Amount of view bobbing (0 = no view bobbing, 1.0 = normal, 2.0 = double) -- cgit v1.2.3 From f5ab056b388b856a70bca7a028b58a258532716f Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 13 Mar 2013 01:18:45 +0400 Subject: 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(-) (limited to 'minetest.conf.example') 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(); -- cgit v1.2.3 From 6823ce99a7deabe410dd8b143b688cd364490cec Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 16 Mar 2013 17:06:11 -0400 Subject: Re-add jungles, apple trees --- minetest.conf.example | 9 ++++-- src/content_abm.cpp | 18 ++++++++--- src/defaultsettings.cpp | 6 ++-- src/mapgen.cpp | 13 +++++--- src/mapgen.h | 2 +- src/mapgen_v6.cpp | 81 +++++++++++++++++++++++++++++++++++-------------- src/mapgen_v6.h | 22 ++++++++++---- src/treegen.cpp | 11 +++++-- 8 files changed, 118 insertions(+), 44 deletions(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 41a691b1a..649717ee8 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -314,22 +314,25 @@ #water_level = 1 # Size of chunks to be generated. #chunksize = 5 -# Map generation attributes. Currently supported: trees, caves, flat, v6_biome_blend +# Map generation attributes. Currently supported: trees, caves, flat, v6_biome_blend, v6_jungles #mg_flags = trees, caves, v6_biome_blend # How large deserts and beaches are #mgv6_freq_desert = 0.45 #mgv6_freq_beach = 0.15 # Perlin noise attributes for different map generation parameters # Offset, scale, spread factor, seed offset, number of octaves, persistence -#mgv6_np_terrain_base = -4, 20, (250.0, 250, 250), 82341, 5, 0.6 +#mgv6_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6 #mgv6_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6 #mgv6_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7 #mgv6_np_height_select = 0.5, 1, (250, 250, 250), 4213, 5, 0.69 -#mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66 #mgv6_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55 #mgv6_np_beach = 0, 1, (250, 250, 250), 59420, 3, 0.50 #mgv6_np_biome = 0, 1, (250, 250, 250), 9130, 3, 0.50 #mgv6_np_cave = 6, 6, (250, 250, 250), 34329, 3, 0.50 +#mgv6_np_humidity = 0.5, 0.5, (500, 500, 500), 72384, 4, 0.66 +#mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66 +#mgv6_np_apple_trees = 0, 1, (100, 100, 100), 342902, 3, 0.45 + #mgv7_np_terrain = 10, 12, (350, 350, 350), 82341, 5, 0.6 #mgv7_np_bgroup = 0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6 #mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0 diff --git a/src/content_abm.cpp b/src/content_abm.cpp index a88450095..e50edddd7 100644 --- a/src/content_abm.cpp +++ b/src/content_abm.cpp @@ -99,6 +99,7 @@ public: { std::set s; s.insert("sapling"); + s.insert("junglesapling"); return s; } virtual float getTriggerInterval() @@ -111,16 +112,25 @@ public: INodeDefManager *ndef = env->getGameDef()->ndef(); ServerMap *map = &env->getServerMap(); - actionstream<<"A sapling grows into a tree at " - <getId("junglesapling"); + + actionstream <<"A " << (is_jungle_tree ? "jungle " : "") + << "sapling grows into a tree at " + << PP(p) << std::endl; std::map modified_blocks; v3s16 tree_p = p; ManualMapVoxelManipulator vmanip(map); v3s16 tree_blockp = getNodeBlockPos(tree_p); vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1)); - bool is_apple_tree = myrand()%4 == 0; - treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand()); + + if (is_jungle_tree) { + treegen::make_jungletree(vmanip, tree_p, ndef, myrand()); + } else { + bool is_apple_tree = myrand() % 4 == 0; + treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand()); + } + vmanip.blitBackAll(&modified_blocks); // update lighting diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 8f878648a..f7724fa11 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -219,15 +219,17 @@ void set_default_settings(Settings *settings) settings->setDefault("mgv6_freq_desert", "0.45"); settings->setDefault("mgv6_freq_beach", "0.15"); - settings->setDefault("mgv6_np_terrain_base", "-4, 20, (250.0, 250, 250), 82341, 5, 0.6"); + settings->setDefault("mgv6_np_terrain_base", "-4, 20, (250, 250, 250), 82341, 5, 0.6"); settings->setDefault("mgv6_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6"); settings->setDefault("mgv6_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7"); settings->setDefault("mgv6_np_height_select", "0.5, 1, (250, 250, 250), 4213, 5, 0.69"); - settings->setDefault("mgv6_np_trees", "0, 1, (125, 125, 125), 2, 4, 0.66"); settings->setDefault("mgv6_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55"); settings->setDefault("mgv6_np_beach", "0, 1, (250, 250, 250), 59420, 3, 0.50"); settings->setDefault("mgv6_np_biome", "0, 1, (250, 250, 250), 9130, 3, 0.50"); settings->setDefault("mgv6_np_cave", "6, 6, (250, 250, 250), 34329, 3, 0.50"); + settings->setDefault("mgv6_np_humidity", "0.5, 0.5, (500, 500, 500), 72384, 4, 0.66"); + settings->setDefault("mgv6_np_trees", "0, 1, (125, 125, 125), 2, 4, 0.66"); + settings->setDefault("mgv6_np_apple_trees", "0, 1, (100, 100, 100), 342902, 3, 0.45"); settings->setDefault("mgv7_np_terrain", "10, 12, (350, 350, 350), 82341, 5, 0.6"); settings->setDefault("mgv7_np_bgroup", "0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6"); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 699b51789..4316be6fe 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -39,7 +39,7 @@ FlagDesc flagdesc_mapgen[] = { {"trees", MG_TREES}, {"caves", MG_CAVES}, {"dungeons", MG_DUNGEONS}, - {"v6_forests", MGV6_FORESTS}, + {"v6_jungles", MGV6_JUNGLES}, {"v6_biome_blend", MGV6_BIOME_BLEND}, {"flat", MG_FLAT}, {NULL, 0} @@ -209,16 +209,19 @@ bool MapgenV6Params::readParams(Settings *settings) { np_terrain_higher = settings->getNoiseParams("mgv6_np_terrain_higher"); np_steepness = settings->getNoiseParams("mgv6_np_steepness"); np_height_select = settings->getNoiseParams("mgv6_np_height_select"); - np_trees = settings->getNoiseParams("mgv6_np_trees"); np_mud = settings->getNoiseParams("mgv6_np_mud"); np_beach = settings->getNoiseParams("mgv6_np_beach"); np_biome = settings->getNoiseParams("mgv6_np_biome"); np_cave = settings->getNoiseParams("mgv6_np_cave"); + np_humidity = settings->getNoiseParams("mgv6_np_humidity"); + np_trees = settings->getNoiseParams("mgv6_np_trees"); + np_apple_trees = settings->getNoiseParams("mgv6_np_apple_trees"); bool success = np_terrain_base && np_terrain_higher && np_steepness && np_height_select && np_trees && np_mud && - np_beach && np_biome && np_cave; + np_beach && np_biome && np_cave && + np_humidity && np_apple_trees; return success; } @@ -231,11 +234,13 @@ void MapgenV6Params::writeParams(Settings *settings) { settings->setNoiseParams("mgv6_np_terrain_higher", np_terrain_higher); settings->setNoiseParams("mgv6_np_steepness", np_steepness); settings->setNoiseParams("mgv6_np_height_select", np_height_select); - settings->setNoiseParams("mgv6_np_trees", np_trees); settings->setNoiseParams("mgv6_np_mud", np_mud); settings->setNoiseParams("mgv6_np_beach", np_beach); settings->setNoiseParams("mgv6_np_biome", np_biome); settings->setNoiseParams("mgv6_np_cave", np_cave); + settings->setNoiseParams("mgv6_np_humidity", np_humidity); + settings->setNoiseParams("mgv6_np_trees", np_trees); + settings->setNoiseParams("mgv6_np_apple_trees", np_apple_trees); } diff --git a/src/mapgen.h b/src/mapgen.h index e5b0b6399..3f3cd424d 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MG_TREES 0x01 #define MG_CAVES 0x02 #define MG_DUNGEONS 0x04 -#define MGV6_FORESTS 0x08 +#define MGV6_JUNGLES 0x08 #define MGV6_BIOME_BLEND 0x10 #define MG_FLAT 0x20 diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index b60758310..dca4e5353 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -45,8 +45,6 @@ NoiseParams nparams_v6_def_steepness = {0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7}; NoiseParams nparams_v6_def_height_select = {0.5, 1.0, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69}; -NoiseParams nparams_v6_def_trees = - {0.0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66}; NoiseParams nparams_v6_def_mud = {AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55}; NoiseParams nparams_v6_def_beach = @@ -55,6 +53,12 @@ NoiseParams nparams_v6_def_biome = {0.0, 1.0, v3f(250.0, 250.0, 250.0), 9130, 3, 0.50}; NoiseParams nparams_v6_def_cave = {6.0, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50}; +NoiseParams nparams_v6_def_humidity = + {0.5, 0.5, v3f(500.0, 500.0, 500.0), 72384, 4, 0.66}; +NoiseParams nparams_v6_def_trees = + {0.0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66}; +NoiseParams nparams_v6_def_apple_trees = + {0.0, 1.0, v3f(100.0, 100.0, 100.0), 342902, 3, 0.45}; /////////////////////////////////////////////////////////////////////////////// @@ -74,13 +78,15 @@ MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params) { this->ystride = csize.X; //////fix this - np_cave = params->np_cave; + np_cave = params->np_cave; + np_humidity = params->np_humidity; + np_trees = params->np_trees; + np_apple_trees = params->np_apple_trees; noise_terrain_base = new Noise(params->np_terrain_base, seed, csize.X, csize.Y); noise_terrain_higher = new Noise(params->np_terrain_higher, seed, csize.X, csize.Y); noise_steepness = new Noise(params->np_steepness, seed, csize.X, csize.Y); noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y); - noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y); noise_mud = new Noise(params->np_mud, seed, csize.X, csize.Y); noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y); noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y); @@ -92,7 +98,6 @@ MapgenV6::~MapgenV6() { delete noise_terrain_higher; delete noise_steepness; delete noise_height_select; - delete noise_trees; delete noise_mud; delete noise_beach; delete noise_biome; @@ -234,12 +239,6 @@ int MapgenV6::getGroundLevelAtPoint(v2s16 p) { //////////////////////// Noise functions -float MapgenV6::getTreeAmount(v2s16 p) { - int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X); - return getTreeAmount(index); -} - - float MapgenV6::getMudAmount(v2s16 p) { int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X); return getMudAmount(index); @@ -258,13 +257,30 @@ BiomeType MapgenV6::getBiome(v2s16 p) { } -float MapgenV6::getTreeAmount(int index) +float MapgenV6::getHumidity(v2s16 p) +{ + /*double noise = noise2d_perlin( + 0.5+(float)p.X/500, 0.5+(float)p.Y/500, + seed+72384, 4, 0.66); + noise = (noise + 1.0)/2.0;*/ + + float noise = NoisePerlin2D(np_humidity, p.X, p.Y, seed); + + if (noise < 0.0) + noise = 0.0; + if (noise > 1.0) + noise = 1.0; + return noise; +} + + +float MapgenV6::getTreeAmount(v2s16 p) { /*double noise = noise2d_perlin( 0.5+(float)p.X/125, 0.5+(float)p.Y/125, seed+2, 4, 0.66);*/ - float noise = noise_trees->result[index]; + float noise = NoisePerlin2D(np_trees, p.X, p.Y, seed); float zeroval = -0.39; if (noise < zeroval) return 0; @@ -273,6 +289,18 @@ float MapgenV6::getTreeAmount(int index) } +bool MapgenV6::getHaveAppleTree(v2s16 p) +{ + /*is_apple_tree = noise2d_perlin( + 0.5+(float)p.X/100, 0.5+(float)p.Z/100, + data->seed+342902, 3, 0.45) > 0.2;*/ + + float noise = NoisePerlin2D(np_apple_trees, p.X, p.Y, seed); + + return noise > 0.2; +} + + float MapgenV6::getMudAmount(int index) { if (flags & MG_FLAT) @@ -465,12 +493,6 @@ void MapgenV6::calculateNoise() { x + 0.5 * noise_height_select->np->spread.X, z + 0.5 * noise_height_select->np->spread.Z); } - - if (flags & MG_TREES) { - noise_trees->perlinMap2D( - x + 0.5 * noise_trees->np->spread.X, - z + 0.5 * noise_trees->np->spread.Z); - } if (!(flags & MG_FLAT)) { noise_mud->perlinMap2D( @@ -762,6 +784,8 @@ void MapgenV6::addDirtGravelBlobs() { void MapgenV6::placeTrees() { + //TimeTaker t("placeTrees"); + // Divide area into parts s16 div = 8; s16 sidelen = central_area_size.X / div; @@ -784,8 +808,13 @@ void MapgenV6::placeTrees() { node_min.X + sidelen + sidelen * x0 - 1, node_min.Z + sidelen + sidelen * z0 - 1 ); - // Amount of trees - u32 tree_count = area * getTreeAmount(p2d_center); /////////////optimize this! + + // Amount of trees, jungle area + u32 tree_count = area * getTreeAmount(p2d_center); + bool is_jungle = (flags & MGV6_JUNGLES) && (getHumidity(p2d_center) > 0.75); + if (is_jungle) + tree_count *= 4; + // Put trees in random places on part of division for (u32 i = 0; i < tree_count; i++) { s16 x = myrand_range(p2d_min.X, p2d_max.X); @@ -806,10 +835,18 @@ void MapgenV6::placeTrees() { continue; } p.Y++; + // Make a tree - treegen::make_tree(*vm, p, false, ndef, myrand()); + if (is_jungle) { + treegen::make_jungletree(*vm, p, ndef, myrand()); + } else { + bool is_apple_tree = (myrand_range(0, 3) == 0) && + getHaveAppleTree(v2s16(x, z)); + treegen::make_tree(*vm, p, is_apple_tree, ndef, myrand()); + } } } + //printf("placeTrees: %dms\n", t.stop()); } diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 7b1e31020..89d72300a 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -35,11 +35,13 @@ extern NoiseParams nparams_v6_def_terrain_base; extern NoiseParams nparams_v6_def_terrain_higher; extern NoiseParams nparams_v6_def_steepness; extern NoiseParams nparams_v6_def_height_select; -extern NoiseParams nparams_v6_def_trees; extern NoiseParams nparams_v6_def_mud; extern NoiseParams nparams_v6_def_beach; extern NoiseParams nparams_v6_def_biome; extern NoiseParams nparams_v6_def_cave; +extern NoiseParams nparams_v6_def_humidity; +extern NoiseParams nparams_v6_def_trees; +extern NoiseParams nparams_v6_def_apple_trees; struct MapgenV6Params : public MapgenParams { float freq_desert; @@ -48,12 +50,14 @@ struct MapgenV6Params : public MapgenParams { NoiseParams *np_terrain_higher; NoiseParams *np_steepness; NoiseParams *np_height_select; - NoiseParams *np_trees; NoiseParams *np_mud; NoiseParams *np_beach; NoiseParams *np_biome; NoiseParams *np_cave; - + NoiseParams *np_humidity; + NoiseParams *np_trees; + NoiseParams *np_apple_trees; + MapgenV6Params() { freq_desert = 0.45; freq_beach = 0.15; @@ -61,11 +65,14 @@ struct MapgenV6Params : public MapgenParams { np_terrain_higher = &nparams_v6_def_terrain_higher; np_steepness = &nparams_v6_def_steepness; np_height_select = &nparams_v6_def_height_select; - np_trees = &nparams_v6_def_trees; np_mud = &nparams_v6_def_mud; np_beach = &nparams_v6_def_beach; np_biome = &nparams_v6_def_biome; np_cave = &nparams_v6_def_cave; + np_humidity = &nparams_v6_def_humidity; + np_trees = &nparams_v6_def_trees; + np_apple_trees = &nparams_v6_def_apple_trees; + } bool readParams(Settings *settings); @@ -90,11 +97,13 @@ public: Noise *noise_terrain_higher; Noise *noise_steepness; Noise *noise_height_select; - Noise *noise_trees; Noise *noise_mud; Noise *noise_beach; Noise *noise_biome; NoiseParams *np_cave; + NoiseParams *np_humidity; + NoiseParams *np_trees; + NoiseParams *np_apple_trees; float freq_desert; float freq_beach; @@ -126,8 +135,9 @@ public: bool block_is_underground(u64 seed, v3s16 blockpos); s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision); + float getHumidity(v2s16 p); float getTreeAmount(v2s16 p); - float getTreeAmount(int index); + bool getHaveAppleTree(v2s16 p); float getMudAmount(v2s16 p); float getMudAmount(int index); bool getHaveBeach(v2s16 p); diff --git a/src/treegen.cpp b/src/treegen.cpp index 5ddf1132d..9df528a21 100644 --- a/src/treegen.cpp +++ b/src/treegen.cpp @@ -510,8 +510,15 @@ v3f transposeMatrix(irr::core::matrix4 M, v3f v) void make_jungletree(VoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef, int seed) { - MapNode treenode(ndef->getId("mapgen_jungletree")); - MapNode leavesnode(ndef->getId("mapgen_leaves")); + content_t c_tree = ndef->getId("mapgen_jungletree"); + content_t c_leaves = ndef->getId("mapgen_jungleleaves"); + if (c_tree == CONTENT_IGNORE) + c_tree = ndef->getId("mapgen_tree"); + if (c_leaves == CONTENT_IGNORE) + c_leaves = ndef->getId("mapgen_leaves"); + + MapNode treenode(c_tree); + MapNode leavesnode(c_leaves); PseudoRandom pr(seed); for(s16 x=-1; x<=1; x++) -- cgit v1.2.3 From 165498cecfc11f3471d84855f4d019be9b353621 Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 13 Mar 2013 00:41:14 +0400 Subject: initial mapgen indev version with farscale feature and huge caves --- minetest.conf.example | 8 +- src/CMakeLists.txt | 1 + src/defaultsettings.cpp | 6 ++ src/emerge.cpp | 2 + src/map.cpp | 1 + src/mapgen_indev.cpp | 246 ++++++++++++++++++++++++++++++++++++++++++++++++ src/mapgen_indev.h | 135 ++++++++++++++++++++++++++ src/mapgen_v6.cpp | 72 +++++++------- src/mapgen_v6.h | 21 ++++- src/noise.cpp | 1 + src/noise.h | 2 +- src/settings.h | 2 +- 12 files changed, 456 insertions(+), 41 deletions(-) create mode 100644 src/mapgen_indev.cpp create mode 100644 src/mapgen_indev.h (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 649717ee8..6a227487a 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -308,7 +308,7 @@ # Mapgen stuff # -# Name of map generator to be used. Currently only v6 is supported. +# Name of map generator to be used. Currently v6 and indev are supported. #mg_name = v6 # Water level of map. #water_level = 1 @@ -337,3 +337,9 @@ #mgv7_np_bgroup = 0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6 #mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0 #mgv7_np_humidity = 50, 31.25, (750, 750, 750), 12094, 2, 0.6 + +# Offset, scale, spread factor, seed offset, number of octaves, persistence, farscale +#mgindev_np_terrain_base = -4, 20, (250.0, 250, 250), 82341, 5, 0.6, 10 +#mgindev_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6, 10 +#mgindev_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 10 +#mgindev_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55, 1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 60e2b1d88..0f8396c02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -225,6 +225,7 @@ set(common_SRCS emerge.cpp mapgen.cpp mapgen_v6.cpp + mapgen_indev.cpp treegen.cpp dungeongen.cpp content_nodemeta.cpp diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f7724fa11..b0ae271ce 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -235,5 +235,11 @@ void set_default_settings(Settings *settings) settings->setDefault("mgv7_np_bgroup", "0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6"); settings->setDefault("mgv7_np_heat", "25, 50, (500, 500, 500), 35293, 1, 0"); settings->setDefault("mgv7_np_humidity", "50, 31.25, (750, 750, 750), 12094, 2, 0.6"); + + settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250.0, 250, 250), 82341, 5, 0.6, 10"); + settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10"); + settings->setDefault("mgindev_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 10"); + settings->setDefault("mgindev_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55, 1"); + } diff --git a/src/emerge.cpp b/src/emerge.cpp index 8a060d107..5311c1210 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "biome.h" #include "emerge.h" #include "mapgen_v6.h" +#include "mapgen_indev.h" /////////////////////////////// Emerge Manager //////////////////////////////// @@ -46,6 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc., EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) { //register built-in mapgens registerMapgen("v6", new MapgenFactoryV6()); + registerMapgen("indev", new MapgenFactoryIndev()); this->biomedef = bdef ? bdef : new BiomeDefManager(gamedef); this->params = NULL; diff --git a/src/map.cpp b/src/map.cpp index 6103b9017..3d36675a8 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "rollback_interface.h" #include "emerge.h" #include "mapgen_v6.h" +#include "mapgen_indev.h" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" diff --git a/src/mapgen_indev.cpp b/src/mapgen_indev.cpp new file mode 100644 index 000000000..e9ab36ae9 --- /dev/null +++ b/src/mapgen_indev.cpp @@ -0,0 +1,246 @@ +/* +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "mapgen_indev.h" +#include "constants.h" +#include "log.h" + +/////////////////// Mapgen Indev perlin noise default values + +NoiseIndevParams nparams_indev_def_terrain_base + (-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_terrain_higher + (20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_steepness + (0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 1); +NoiseIndevParams nparams_indev_def_mud + (AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55, 1); + +/////////////////////////////////////////////////////////////////////////////// + +void NoiseIndev::init(NoiseIndevParams *np, int seed, int sx, int sy, int sz) { + Noise::init((NoiseParams*)np, seed, sx, sy, sz); + this->npindev = np; +} + + +NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy) : Noise(np, seed, sx, sy) { + init(np, seed, sx, sy, 1); +} + + +NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz) : Noise(np, seed, sx, sy, sz) { + init(np, seed, sx, sy, sz); +} + + +float farscale(float scale, float x, float y, float z) { + return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 3 - (fabs(x) + fabs(y) + fabs(z)) ) / (MAP_GENERATION_LIMIT * 3) ) * (scale - 1) ); +} + +void NoiseIndev::transformNoiseMapFarScale(float xx, float yy, float zz) { + // more correct use distantion from 0,0,0 via pow, but + is faster + //float farscale = ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 3 - (fabs(xx) + fabs(yy) + fabs(zz)) ) / (MAP_GENERATION_LIMIT * 3) ) * ((npindev)->farscale - 1) ); + // dstream << "TNM rs=" << farscale << " from=" << (npindev)->farscale << " x=" << xx << " y=" << yy <<" z=" << zz << std::endl; + int i = 0; + for (int z = 0; z != sz; z++) { + for (int y = 0; y != sy; y++) { + for (int x = 0; x != sx; x++) { + //result[i] = result[i] * npindev->scale * farscale + npindev->offset; + result[i] = result[i] * npindev->scale * farscale(npindev->farscale,xx,yy,zz) + npindev->offset; + i++; + } + } + } +} + +MapgenIndev::MapgenIndev(int mapgenid, MapgenIndevParams *params) : MapgenV6(mapgenid, params) { + noiseindev_terrain_base = new NoiseIndev(params->npindev_terrain_base, seed, csize.X, csize.Y); + noiseindev_terrain_higher = new NoiseIndev(params->npindev_terrain_higher, seed, csize.X, csize.Y); + noiseindev_steepness = new NoiseIndev(params->npindev_steepness, seed, csize.X, csize.Y); +// noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y); +// noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y); + noiseindev_mud = new NoiseIndev(params->npindev_mud, seed, csize.X, csize.Y); +// noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y); +// noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y); +} + +MapgenIndev::~MapgenIndev() { + delete noiseindev_terrain_base; + delete noiseindev_terrain_higher; + delete noiseindev_steepness; + //delete noise_height_select; + //delete noise_trees; + delete noiseindev_mud; + //delete noise_beach; + //delete noise_biome; +} + + +void MapgenIndev::calculateNoise() { + int x = node_min.X; + int y = node_min.Y; + int z = node_min.Z; + // Need to adjust for the original implementation's +.5 offset... + if (!(flags & MG_FLAT)) { + noiseindev_terrain_base->perlinMap2D( + x + 0.5 * noiseindev_terrain_base->npindev->spread.X, + z + 0.5 * noiseindev_terrain_base->npindev->spread.Z); + noiseindev_terrain_base->transformNoiseMapFarScale(x, y, z); + //noise_terrain_base->transformNoiseMap(); + + noiseindev_terrain_higher->perlinMap2D( + x + 0.5 * noiseindev_terrain_higher->npindev->spread.X, + z + 0.5 * noiseindev_terrain_higher->npindev->spread.Z); + noiseindev_terrain_higher->transformNoiseMapFarScale(x, y, z); + //noise_terrain_higher->transformNoiseMap(); + + noiseindev_steepness->perlinMap2D( + x + 0.5 * noiseindev_steepness->npindev->spread.X, + z + 0.5 * noiseindev_steepness->npindev->spread.Z); + noiseindev_steepness->transformNoiseMapFarScale(x, y, z); + + noise_height_select->perlinMap2D( + x + 0.5 * noise_height_select->np->spread.X, + z + 0.5 * noise_height_select->np->spread.Z); + } + + if (!(flags & MG_FLAT)) { + noiseindev_mud->perlinMap2D( + x + 0.5 * noiseindev_mud->npindev->spread.X, + z + 0.5 * noiseindev_mud->npindev->spread.Z); + noiseindev_mud->transformNoiseMapFarScale(x, y, z); + } + noise_beach->perlinMap2D( + x + 0.2 * noise_beach->np->spread.X, + z + 0.7 * noise_beach->np->spread.Z); + + noise_biome->perlinMap2D( + x + 0.6 * noise_biome->np->spread.X, + z + 0.2 * noise_biome->np->spread.Z); +} + +bool MapgenIndevParams::readParams(Settings *settings) { + freq_desert = settings->getFloat("mgv6_freq_desert"); + freq_beach = settings->getFloat("mgv6_freq_beach"); + + npindev_terrain_base = settings->getNoiseIndevParams("mgindev_np_terrain_base"); + npindev_terrain_higher = settings->getNoiseIndevParams("mgindev_np_terrain_higher"); + npindev_steepness = settings->getNoiseIndevParams("mgindev_np_steepness"); + np_height_select = settings->getNoiseParams("mgv6_np_height_select"); + np_trees = settings->getNoiseParams("mgv6_np_trees"); + npindev_mud = settings->getNoiseIndevParams("mgindev_np_mud"); + np_beach = settings->getNoiseParams("mgv6_np_beach"); + np_biome = settings->getNoiseParams("mgv6_np_biome"); + np_cave = settings->getNoiseParams("mgv6_np_cave"); + + bool success = + npindev_terrain_base && npindev_terrain_higher && npindev_steepness && + np_height_select && np_trees && npindev_mud && + np_beach && np_biome && np_cave; + return success; +} + + +void MapgenIndevParams::writeParams(Settings *settings) { + settings->setFloat("mgv6_freq_desert", freq_desert); + settings->setFloat("mgv6_freq_beach", freq_beach); + + settings->setNoiseIndevParams("mgindev_np_terrain_base", npindev_terrain_base); + settings->setNoiseIndevParams("mgindev_np_terrain_higher", npindev_terrain_higher); + settings->setNoiseIndevParams("mgindev_np_steepness", npindev_steepness); + settings->setNoiseParams("mgv6_np_height_select", np_height_select); + settings->setNoiseParams("mgv6_np_trees", np_trees); + settings->setNoiseIndevParams("mgindev_np_mud", npindev_mud); + settings->setNoiseParams("mgv6_np_beach", np_beach); + settings->setNoiseParams("mgv6_np_biome", np_biome); + settings->setNoiseParams("mgv6_np_cave", np_cave); +} + + +float MapgenIndev::baseTerrainLevelFromNoise(v2s16 p) { + if (flags & MG_FLAT) + return water_level; + + float terrain_base = NoisePerlin2DPosOffset(noiseindev_terrain_base->npindev, + p.X, 0.5, p.Y, 0.5, seed); + float terrain_higher = NoisePerlin2DPosOffset(noiseindev_terrain_higher->npindev, + p.X, 0.5, p.Y, 0.5, seed); + float steepness = NoisePerlin2DPosOffset(noiseindev_steepness->npindev, + p.X, 0.5, p.Y, 0.5, seed); + float height_select = NoisePerlin2DNoTxfmPosOffset(noise_height_select->np, + p.X, 0.5, p.Y, 0.5, seed); + + return baseTerrainLevel(terrain_base, terrain_higher, + steepness, height_select); +} + +float MapgenIndev::baseTerrainLevelFromMap(int index) { + if (flags & MG_FLAT) + return water_level; + + float terrain_base = noiseindev_terrain_base->result[index]; + float terrain_higher = noiseindev_terrain_higher->result[index]; + float steepness = noiseindev_steepness->result[index]; + float height_select = noise_height_select->result[index]; + + return baseTerrainLevel(terrain_base, terrain_higher, + steepness, height_select); +} + +float MapgenIndev::getMudAmount(int index) +{ + if (flags & MG_FLAT) + return AVERAGE_MUD_AMOUNT; + + /*return ((float)AVERAGE_MUD_AMOUNT + 2.0 * noise2d_perlin( + 0.5+(float)p.X/200, 0.5+(float)p.Y/200, + seed+91013, 3, 0.55));*/ + + return noiseindev_mud->result[index]; +} + +void MapgenIndev::defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave) { + cave.min_tunnel_diameter = 2; + cave.max_tunnel_diameter = ps.range(2,6); + cave.dswitchint = ps.range(1,14); + //cave.tunnel_routepoints = 0; + //cave.part_max_length_rs = 0; + cave.flooded = large_cave && ps.range(0,4); + if(large_cave){ + cave.part_max_length_rs = ps.range(2,4); +//dstream<<"try:"< + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef MAPGENINDEV_HEADER +#define MAPGENINDEV_HEADER + +#include "mapgen.h" +#include "mapgen_v6.h" + +float farscale(float scale, float x, float y, float z); + +struct NoiseIndevParams : public NoiseParams { + float farscale; + + NoiseIndevParams(){} + NoiseIndevParams(float offset_, float scale_, v3f spread_, int seed_, int octaves_, float persist_, float farscale_) + //:NoiseParams(offset_, scale_, spread_, seed_, octaves_, persist_) + { + //NoiseParams(float offset_, float scale_, v3f spread_, int seed_, int octaves_, float persist_) { + offset = offset_; + scale = scale_; + spread = spread_; + seed = seed_; + octaves = octaves_; + persist = persist_; + //} + farscale = farscale_; + } + +}; + +#define getNoiseIndevParams(x) getStruct((x), "f,f,v3,s32,s32,f,f") +#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f", (y)) + +class NoiseIndev : public Noise { + public: + NoiseIndevParams *npindev; + + //NoiseIndev() {}; + NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy); + NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz); + void init(NoiseIndevParams *np, int seed, int sx, int sy, int sz); + void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0); +}; + +extern NoiseIndevParams nparams_indev_def_terrain_base; +extern NoiseIndevParams nparams_indev_def_terrain_higher; +extern NoiseIndevParams nparams_indev_def_steepness; +//extern NoiseIndevParams nparams_indev_def_height_select; +//extern NoiseIndevParams nparams_indev_def_trees; +extern NoiseIndevParams nparams_indev_def_mud; +//extern NoiseIndevParams nparams_indev_def_beach; +//extern NoiseIndevParams nparams_indev_def_biome; +//extern NoiseIndevParams nparams_indev_def_cave; + + +struct MapgenIndevParams : public MapgenV6Params { + NoiseIndevParams *npindev_terrain_base; + NoiseIndevParams *npindev_terrain_higher; + NoiseIndevParams *npindev_steepness; + //NoiseParams *np_height_select; + //NoiseParams *np_trees; + NoiseIndevParams *npindev_mud; + //NoiseParams *np_beach; + //NoiseParams *np_biome; + //NoiseParams *np_cave; + + MapgenIndevParams() { + //freq_desert = 0.45; + //freq_beach = 0.15; + npindev_terrain_base = &nparams_indev_def_terrain_base; + npindev_terrain_higher = &nparams_indev_def_terrain_higher; + npindev_steepness = &nparams_indev_def_steepness; + //np_height_select = &nparams_v6_def_height_select; + //np_trees = &nparams_v6_def_trees; + npindev_mud = &nparams_indev_def_mud; + //np_beach = &nparams_v6_def_beach; + //np_biome = &nparams_v6_def_biome; + //np_cave = &nparams_v6_def_cave; + } + + bool readParams(Settings *settings); + void writeParams(Settings *settings); +}; + +class MapgenIndev : public MapgenV6 { + public: + NoiseIndev *noiseindev_terrain_base; + NoiseIndev *noiseindev_terrain_higher; + NoiseIndev *noiseindev_steepness; + //NoiseIndev *noise_height_select; + //NoiseIndev *noise_trees; + NoiseIndev *noiseindev_mud; + //NoiseIndev *noise_beach; + //NoiseIndev *noise_biome; + //NoiseIndevParams *np_cave; + + MapgenIndev(int mapgenid, MapgenIndevParams *params); + ~MapgenIndev(); + void calculateNoise(); + + float baseTerrainLevelFromNoise(v2s16 p); + float baseTerrainLevelFromMap(int index); + float getMudAmount(int index); + void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave); +}; + +struct MapgenFactoryIndev : public MapgenFactoryV6 { + Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) { + return new MapgenIndev(mgid, (MapgenIndevParams *)params); + }; + + MapgenParams *createMapgenParams() { + return new MapgenIndevParams(); + }; +}; + + +#endif diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index dca4e5353..91947df84 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -878,6 +878,24 @@ void MapgenV6::growGrass() { } } +void MapgenV6::defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave) { + cave.min_tunnel_diameter = 2; + cave.max_tunnel_diameter = ps.range(2,6); + cave.dswitchint = ps.range(1,14); + //cave.tunnel_routepoints = 0; + //cave.part_max_length_rs = 0; + cave.flooded = large_cave && ps.range(0,4); + if(large_cave){ + cave.part_max_length_rs = ps.range(2,4); + cave.tunnel_routepoints = ps.range(5, ps.range(15,30)); + cave.min_tunnel_diameter = 5; + cave.max_tunnel_diameter = ps.range(7, ps.range(8,24)); + } else { + cave.part_max_length_rs = ps.range(2,9); + cave.tunnel_routepoints = ps.range(10, ps.range(15,30)); + } + cave.large_cave_is_flat = (ps.range(0,1) == 0); +}; void MapgenV6::generateCaves(int max_stone_y) { // 24ms @cs=8 @@ -911,21 +929,9 @@ void MapgenV6::generateCaves(int max_stone_y) { break;*/ bool large_cave = (jj >= caves_count); - s16 min_tunnel_diameter = 2; - s16 max_tunnel_diameter = ps.range(2,6); - int dswitchint = ps.range(1,14); - u16 tunnel_routepoints = 0; - int part_max_length_rs = 0; - if(large_cave){ - part_max_length_rs = ps.range(2,4); - tunnel_routepoints = ps.range(5, ps.range(15,30)); - min_tunnel_diameter = 5; - max_tunnel_diameter = ps.range(7, ps.range(8,24)); - } else { - part_max_length_rs = ps.range(2,9); - tunnel_routepoints = ps.range(10, ps.range(15,30)); - } - bool large_cave_is_flat = (ps.range(0,1) == 0); + + Cave cave; + defineCave(cave, ps, node_min, large_cave); v3f main_direction(0,0,0); @@ -938,13 +944,13 @@ void MapgenV6::generateCaves(int max_stone_y) { // Allow a bit more //(this should be more than the maximum radius of the tunnel) s16 insure = 10; - s16 more = max_spread_amount - max_tunnel_diameter / 2 - insure; + s16 more = max_spread_amount - cave.max_tunnel_diameter / 2 - insure; ar += v3s16(1,0,1) * more * 2; of -= v3s16(1,0,1) * more; s16 route_y_min = 0; // Allow half a diameter + 7 over stone surface - s16 route_y_max = -of.Y + max_stone_y + max_tunnel_diameter/2 + 7; + s16 route_y_max = -of.Y + max_stone_y + cave.max_tunnel_diameter/2 + 7; // Limit maximum to area route_y_max = rangelim(route_y_max, 0, ar.Y-1); @@ -954,10 +960,10 @@ void MapgenV6::generateCaves(int max_stone_y) { s16 min = 0; if(node_min.Y < water_level && node_max.Y > water_level) { - min = water_level - max_tunnel_diameter/3 - of.Y; - route_y_max = water_level + max_tunnel_diameter/3 - of.Y; + min = water_level - cave.max_tunnel_diameter/3 - of.Y; + route_y_max = water_level + cave.max_tunnel_diameter/3 - of.Y; } - route_y_min = ps.range(min, min + max_tunnel_diameter); + route_y_min = ps.range(min, min + cave.max_tunnel_diameter); route_y_min = rangelim(route_y_min, 0, route_y_max); } @@ -985,9 +991,9 @@ void MapgenV6::generateCaves(int max_stone_y) { Generate some tunnel starting from orp */ - for(u16 j=0; j 7 && abs(y0) >= rs/3) continue; @@ -1109,13 +1115,13 @@ void MapgenV6::generateCaves(int max_stone_y) { u32 i = vm->m_area.index(p); if(large_cave) { - if (full_node_min.Y < water_level && + if (cave.flooded && full_node_min.Y < water_level && full_node_max.Y > water_level) { if (p.Y <= water_level) vm->m_data[i] = waternode; else vm->m_data[i] = airnode; - } else if (full_node_max.Y < water_level) { + } else if (cave.flooded && full_node_max.Y < water_level) { if (p.Y < startp.Y - 2) vm->m_data[i] = lavanode; else diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 89d72300a..34de7c0ed 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -43,6 +43,16 @@ extern NoiseParams nparams_v6_def_humidity; extern NoiseParams nparams_v6_def_trees; extern NoiseParams nparams_v6_def_apple_trees; +struct Cave { + s16 min_tunnel_diameter; + s16 max_tunnel_diameter; + int dswitchint; + u16 tunnel_routepoints; + int part_max_length_rs; + bool large_cave_is_flat; + bool flooded; +}; + struct MapgenV6Params : public MapgenParams { float freq_desert; float freq_beach; @@ -126,9 +136,9 @@ public: float baseTerrainLevel(float terrain_base, float terrain_higher, float steepness, float height_select); - float baseTerrainLevelFromNoise(v2s16 p); - float baseTerrainLevelFromMap(v2s16 p); - float baseTerrainLevelFromMap(int index); + virtual float baseTerrainLevelFromNoise(v2s16 p); + virtual float baseTerrainLevelFromMap(v2s16 p); + virtual float baseTerrainLevelFromMap(int index); s16 find_ground_level(v2s16 p2d); s16 find_stone_level(v2s16 p2d); @@ -139,7 +149,7 @@ public: float getTreeAmount(v2s16 p); bool getHaveAppleTree(v2s16 p); float getMudAmount(v2s16 p); - float getMudAmount(int index); + virtual float getMudAmount(int index); bool getHaveBeach(v2s16 p); bool getHaveBeach(int index); BiomeType getBiome(v2s16 p); @@ -148,13 +158,14 @@ public: u32 get_blockseed(u64 seed, v3s16 p); - void calculateNoise(); + virtual void calculateNoise(); int generateGround(); void addMud(); void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos); void addDirtGravelBlobs(); void growGrass(); void placeTrees(); + virtual void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave); void generateCaves(int max_stone_y); }; diff --git a/src/noise.cpp b/src/noise.cpp index 49b5f7e58..ba7c30574 100644 --- a/src/noise.cpp +++ b/src/noise.cpp @@ -524,6 +524,7 @@ float *Noise::perlinMap2D(float x, float y) { for (j = 0; j != sy; j++) { for (i = 0; i != sx; i++) { result[index] += g * buf[index]; +//dstream << "pm2d i="< Date: Sun, 17 Mar 2013 13:07:53 +0100 Subject: Add missing settings to minetest.conf.example --- minetest.conf.example | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 6a227487a..331d3c232 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -80,6 +80,7 @@ # when set to higher number than 0 #fsaa = 0 #vsync = false +#fov = 72 # Address to connect to (#blank = start local server) #address = # Enable random user input, for testing @@ -127,6 +128,8 @@ #farmesh_distance = 40 # Enable/disable clouds #enable_clouds = true +#cloud_height = 120 +#enable_3d_clouds = true # Use a cloud animation for the main menu background #menu_clouds = true # Path for screenshots @@ -314,7 +317,7 @@ #water_level = 1 # Size of chunks to be generated. #chunksize = 5 -# Map generation attributes. Currently supported: trees, caves, flat, v6_biome_blend, v6_jungles +# Map generation attributes. Currently supported: trees, caves, flat, v6_biome_blend, v6_jungles, dungeons #mg_flags = trees, caves, v6_biome_blend # How large deserts and beaches are #mgv6_freq_desert = 0.45 -- cgit v1.2.3 From 34b185e95511983d0eb9f3e9b5c651f1eacf4561 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 22 Mar 2013 19:16:51 +0200 Subject: Add singlenode mapgen; generates solely the node 'mapgen_singlenode', defaults to air --- minetest.conf.example | 2 +- src/CMakeLists.txt | 1 + src/emerge.cpp | 2 + src/mapgen_singlenode.cpp | 96 +++++++++++++++++++++++++++++++++++++++++++++++ src/mapgen_singlenode.h | 53 ++++++++++++++++++++++++++ 5 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 src/mapgen_singlenode.cpp create mode 100644 src/mapgen_singlenode.h (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 331d3c232..5401f6aad 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -311,7 +311,7 @@ # Mapgen stuff # -# Name of map generator to be used. Currently v6 and indev are supported. +# Name of map generator to be used. Currently v6, indev and singlenode are supported. #mg_name = v6 # Water level of map. #water_level = 1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d91248cb6..8c2890f76 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -227,6 +227,7 @@ set(common_SRCS mapgen.cpp mapgen_v6.cpp mapgen_indev.cpp + mapgen_singlenode.cpp treegen.cpp dungeongen.cpp content_nodemeta.cpp diff --git a/src/emerge.cpp b/src/emerge.cpp index 5311c1210..e4bd997cb 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -40,6 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "emerge.h" #include "mapgen_v6.h" #include "mapgen_indev.h" +#include "mapgen_singlenode.h" /////////////////////////////// Emerge Manager //////////////////////////////// @@ -48,6 +49,7 @@ EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) { //register built-in mapgens registerMapgen("v6", new MapgenFactoryV6()); registerMapgen("indev", new MapgenFactoryIndev()); + registerMapgen("singlenode", new MapgenFactorySinglenode()); this->biomedef = bdef ? bdef : new BiomeDefManager(gamedef); this->params = NULL; diff --git a/src/mapgen_singlenode.cpp b/src/mapgen_singlenode.cpp new file mode 100644 index 000000000..04bf02bd1 --- /dev/null +++ b/src/mapgen_singlenode.cpp @@ -0,0 +1,96 @@ +/* +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "mapgen_singlenode.h" +#include "voxel.h" +#include "mapblock.h" +#include "mapnode.h" +#include "map.h" +#include "nodedef.h" +#include "voxelalgorithms.h" +#include "profiler.h" +#include "settings.h" // For g_settings +#include "main.h" // For g_profiler +#include "emerge.h" + +//////////////////////// Mapgen Singlenode parameter read/write + +bool MapgenSinglenodeParams::readParams(Settings *settings) { + return true; +} + + +void MapgenSinglenodeParams::writeParams(Settings *settings) { +} + +/////////////////////////////////////////////////////////////////////////////// + +MapgenSinglenode::MapgenSinglenode(int mapgenid, MapgenSinglenodeParams *params) { +} + + +MapgenSinglenode::~MapgenSinglenode() { +} + +//////////////////////// Map generator + +void MapgenSinglenode::makeChunk(BlockMakeData *data) { + assert(data->vmanip); + assert(data->nodedef); + assert(data->blockpos_requested.X >= data->blockpos_min.X && + data->blockpos_requested.Y >= data->blockpos_min.Y && + data->blockpos_requested.Z >= data->blockpos_min.Z); + assert(data->blockpos_requested.X <= data->blockpos_max.X && + data->blockpos_requested.Y <= data->blockpos_max.Y && + data->blockpos_requested.Z <= data->blockpos_max.Z); + + this->generating = true; + this->vm = data->vmanip; + this->ndef = data->nodedef; + + v3s16 blockpos_min = data->blockpos_min; + v3s16 blockpos_max = data->blockpos_max; + + // Area of central chunk + v3s16 node_min = blockpos_min*MAP_BLOCKSIZE; + v3s16 node_max = (blockpos_max+v3s16(1,1,1))*MAP_BLOCKSIZE-v3s16(1,1,1); + + content_t c_node = ndef->getId("mapgen_singlenode"); + if(c_node == CONTENT_IGNORE) + c_node = CONTENT_AIR; + for(s16 z=node_min.Z; z<=node_max.Z; z++) + for(s16 y=node_min.Y; y<=node_max.Y; y++) + for(s16 x=node_min.X; x<=node_max.X; x++) + { + data->vmanip->setNode(v3s16(x,y,z), MapNode(c_node)); + } + + // Add top and bottom side of water to transforming_liquid queue + updateLiquid(&data->transforming_liquid, node_min, node_max); + + // Calculate lighting + calcLighting(node_min, node_max); + + this->generating = false; +} + +int MapgenSinglenode::getGroundLevelAtPoint(v2s16 p) { + return 0; +} + diff --git a/src/mapgen_singlenode.h b/src/mapgen_singlenode.h new file mode 100644 index 000000000..b86c9a77f --- /dev/null +++ b/src/mapgen_singlenode.h @@ -0,0 +1,53 @@ +/* +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef MAPGEN_SINGLENODE_HEADER +#define MAPGEN_SINGLENODE_HEADER + +#include "mapgen.h" + +struct MapgenSinglenodeParams : public MapgenParams { + + MapgenSinglenodeParams() { + } + + bool readParams(Settings *settings); + void writeParams(Settings *settings); +}; + +class MapgenSinglenode : public Mapgen { +public: + MapgenSinglenode(int mapgenid, MapgenSinglenodeParams *params); + ~MapgenSinglenode(); + + void makeChunk(BlockMakeData *data); + int getGroundLevelAtPoint(v2s16 p); +}; + +struct MapgenFactorySinglenode : public MapgenFactory { + Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) { + return new MapgenSinglenode(mgid, (MapgenSinglenodeParams *)params); + }; + + MapgenParams *createMapgenParams() { + return new MapgenSinglenodeParams(); + }; +}; + +#endif -- cgit v1.2.3 From f70378f7f57f293a2a0afcf35aec8ee67180a6c0 Mon Sep 17 00:00:00 2001 From: proller Date: Sun, 24 Mar 2013 03:40:15 +0400 Subject: Mapgen indev: float islands, larger far biomes --- games/minimal/mods/default/mapgen.lua | 3 + minetest.conf.example | 17 ++- src/defaultsettings.cpp | 13 +- src/mapgen_indev.cpp | 226 ++++++++++++++++++++++++++-------- src/mapgen_indev.h | 49 +++++--- src/mapgen_v6.cpp | 2 + src/mapgen_v6.h | 1 + 7 files changed, 233 insertions(+), 78 deletions(-) (limited to 'minetest.conf.example') diff --git a/games/minimal/mods/default/mapgen.lua b/games/minimal/mods/default/mapgen.lua index 74fc398b2..de6632d13 100644 --- a/games/minimal/mods/default/mapgen.lua +++ b/games/minimal/mods/default/mapgen.lua @@ -74,6 +74,9 @@ minetest.register_on_generated(function(minp, maxp, seed) 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+4, 1/8/8/8, 5, 200, 31000 ) -- for float islands and far scaled mountains + generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+5, 1/9/9/9, 5, 200, 31000 ) + 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) diff --git a/minetest.conf.example b/minetest.conf.example index 5401f6aad..838987c33 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -341,8 +341,15 @@ #mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0 #mgv7_np_humidity = 50, 31.25, (750, 750, 750), 12094, 2, 0.6 -# Offset, scale, spread factor, seed offset, number of octaves, persistence, farscale -#mgindev_np_terrain_base = -4, 20, (250.0, 250, 250), 82341, 5, 0.6, 10 -#mgindev_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6, 10 -#mgindev_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 10 -#mgindev_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55, 1 +# Offset, scale, spread factor, seed offset, number of octaves, persistence, farscale, farspread +#mgindev_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6, 10, 10 +#mgindev_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6, 10, 10 +#mgindev_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2, 10 +#mgindev_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55, 1, 1 +#mgindev_np_float_islands1 = 0, 1, (64, 64, 64 ), 3683, 5, 0.5, 1, 1.5 +#mgindev_np_float_islands2 = 0, 1, (8, 8, 8 ), 9292, 2, 0.5, 1, 1.5 +#mgindev_np_float_islands3 = 0, 1, (256, 256, 256), 6412, 2, 0.5, 1, 0.5 +#mgindev_np_biome = 0, 1, (250, 250, 250), 9130, 3, 0.50, 1, 10 + +# Float islands starts from height, 0 to disable +#mgindev_float_islands = 500 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 25edffe32..592c6bcca 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -236,10 +236,15 @@ void set_default_settings(Settings *settings) settings->setDefault("mgv7_np_heat", "25, 50, (500, 500, 500), 35293, 1, 0"); settings->setDefault("mgv7_np_humidity", "50, 31.25, (750, 750, 750), 12094, 2, 0.6"); - settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250.0, 250, 250), 82341, 5, 0.6, 10"); - settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10"); - settings->setDefault("mgindev_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 10"); - settings->setDefault("mgindev_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55, 1"); + settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250, 250, 250), 82341, 5, 0.6, 10, 10"); + settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10, 10"); + settings->setDefault("mgindev_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2, 10"); + settings->setDefault("mgindev_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55, 1, 1"); + settings->setDefault("mgindev_np_float_islands1", "0, 1, (64, 64, 64 ), 3683, 5, 0.5, 1, 1.5"); + settings->setDefault("mgindev_np_float_islands2", "0, 1, (8, 8, 8 ), 9292, 2, 0.5, 1, 1.5"); + settings->setDefault("mgindev_np_float_islands3", "0, 1, (256, 256, 256), 6412, 2, 0.5, 1, 0.5"); + settings->setDefault("mgindev_np_biome", "0, 1, (250, 250, 250), 9130, 3, 0.50, 1, 10"); + settings->setDefault("mgindev_float_islands", "500"); } diff --git a/src/mapgen_indev.cpp b/src/mapgen_indev.cpp index 4de4fd55f..6956fc63f 100644 --- a/src/mapgen_indev.cpp +++ b/src/mapgen_indev.cpp @@ -19,18 +19,27 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapgen_indev.h" #include "constants.h" +#include "map.h" +#include "main.h" #include "log.h" -/////////////////// Mapgen Indev perlin noise default values +/////////////////// Mapgen Indev perlin noise (default values - not used, from config or defaultsettings) -NoiseIndevParams nparams_indev_def_terrain_base - (-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 1); -NoiseIndevParams nparams_indev_def_terrain_higher - (20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 1); -NoiseIndevParams nparams_indev_def_steepness - (0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 1); -NoiseIndevParams nparams_indev_def_mud - (AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55, 1); +NoiseIndevParams nparams_indev_def; + +/* +NoiseIndevParams nparams_indev_def_terrain_base; +// (-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_terrain_higher; +// (20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_steepness; +// (0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 1); +NoiseIndevParams nparams_indev_def_mud; +// (AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55, 1); +NoiseIndevParams nparams_indev_def_float_islands; +// (1, 10.0, v3f(500.0, 500.0, 500.0), 32451, 5, 0.6, 1); +NoiseIndevParams nparams_indev_def_biome; +*/ /////////////////////////////////////////////////////////////////////////////// @@ -39,31 +48,32 @@ void NoiseIndev::init(NoiseIndevParams *np, int seed, int sx, int sy, int sz) { this->npindev = np; } - NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy) : Noise(np, seed, sx, sy) { init(np, seed, sx, sy, 1); } - NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz) : Noise(np, seed, sx, sy, sz) { init(np, seed, sx, sy, sz); } +float farscale(float scale, float z) { + return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 1 - (fabs(z)) ) / (MAP_GENERATION_LIMIT * 1) ) * (scale - 1) ); +} + +float farscale(float scale, float x, float z) { + return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 2 - (fabs(x) + fabs(z)) ) / (MAP_GENERATION_LIMIT * 2) ) * (scale - 1) ); +} float farscale(float scale, float x, float y, float z) { return ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 3 - (fabs(x) + fabs(y) + fabs(z)) ) / (MAP_GENERATION_LIMIT * 3) ) * (scale - 1) ); } void NoiseIndev::transformNoiseMapFarScale(float xx, float yy, float zz) { - // more correct use distantion from 0,0,0 via pow, but + is faster - //float farscale = ( 1 + ( 1 - (MAP_GENERATION_LIMIT * 3 - (fabs(xx) + fabs(yy) + fabs(zz)) ) / (MAP_GENERATION_LIMIT * 3) ) * ((npindev)->farscale - 1) ); - // dstream << "TNM rs=" << farscale << " from=" << (npindev)->farscale << " x=" << xx << " y=" << yy <<" z=" << zz << std::endl; int i = 0; for (int z = 0; z != sz; z++) { for (int y = 0; y != sy; y++) { for (int x = 0; x != sx; x++) { - //result[i] = result[i] * npindev->scale * farscale + npindev->offset; - result[i] = result[i] * npindev->scale * farscale(npindev->farscale,xx,yy,zz) + npindev->offset; + result[i] = result[i] * npindev->scale * farscale(npindev->farscale, xx, yy, zz) + npindev->offset; i++; } } @@ -71,14 +81,17 @@ void NoiseIndev::transformNoiseMapFarScale(float xx, float yy, float zz) { } MapgenIndev::MapgenIndev(int mapgenid, MapgenIndevParams *params) : MapgenV6(mapgenid, params) { - noiseindev_terrain_base = new NoiseIndev(params->npindev_terrain_base, seed, csize.X, csize.Y); - noiseindev_terrain_higher = new NoiseIndev(params->npindev_terrain_higher, seed, csize.X, csize.Y); - noiseindev_steepness = new NoiseIndev(params->npindev_steepness, seed, csize.X, csize.Y); + noiseindev_terrain_base = new NoiseIndev(params->npindev_terrain_base, seed, csize.X, csize.Z); + noiseindev_terrain_higher = new NoiseIndev(params->npindev_terrain_higher, seed, csize.X, csize.Z); + noiseindev_steepness = new NoiseIndev(params->npindev_steepness, seed, csize.X, csize.Z); // noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y); // noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y); - noiseindev_mud = new NoiseIndev(params->npindev_mud, seed, csize.X, csize.Y); + noiseindev_mud = new NoiseIndev(params->npindev_mud, seed, csize.X, csize.Z); // noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y); -// noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y); + noiseindev_float_islands1 = new NoiseIndev(params->npindev_float_islands1, seed, csize.X, csize.Y, csize.Z); + noiseindev_float_islands2 = new NoiseIndev(params->npindev_float_islands2, seed, csize.X, csize.Y, csize.Z); + noiseindev_float_islands3 = new NoiseIndev(params->npindev_float_islands3, seed, csize.X, csize.Z); + noiseindev_biome = new NoiseIndev(params->npindev_biome, seed, csize.X, csize.Z); } MapgenIndev::~MapgenIndev() { @@ -89,10 +102,12 @@ MapgenIndev::~MapgenIndev() { //delete noise_trees; delete noiseindev_mud; //delete noise_beach; - //delete noise_biome; + delete noiseindev_float_islands1; + delete noiseindev_float_islands2; + delete noiseindev_float_islands3; + delete noiseindev_biome; } - void MapgenIndev::calculateNoise() { int x = node_min.X; int y = node_min.Y; @@ -100,31 +115,49 @@ void MapgenIndev::calculateNoise() { // Need to adjust for the original implementation's +.5 offset... if (!(flags & MG_FLAT)) { noiseindev_terrain_base->perlinMap2D( - x + 0.5 * noiseindev_terrain_base->npindev->spread.X, - z + 0.5 * noiseindev_terrain_base->npindev->spread.Z); + x + 0.5 * noiseindev_terrain_base->npindev->spread.X * farscale(noiseindev_terrain_base->npindev->farspread, x, z), + z + 0.5 * noiseindev_terrain_base->npindev->spread.Z * farscale(noiseindev_terrain_base->npindev->farspread, x, z)); noiseindev_terrain_base->transformNoiseMapFarScale(x, y, z); - //noise_terrain_base->transformNoiseMap(); noiseindev_terrain_higher->perlinMap2D( - x + 0.5 * noiseindev_terrain_higher->npindev->spread.X, - z + 0.5 * noiseindev_terrain_higher->npindev->spread.Z); + x + 0.5 * noiseindev_terrain_higher->npindev->spread.X * farscale(noiseindev_terrain_higher->npindev->farspread, x, z), + z + 0.5 * noiseindev_terrain_higher->npindev->spread.Z * farscale(noiseindev_terrain_higher->npindev->farspread, x, z)); noiseindev_terrain_higher->transformNoiseMapFarScale(x, y, z); - //noise_terrain_higher->transformNoiseMap(); noiseindev_steepness->perlinMap2D( - x + 0.5 * noiseindev_steepness->npindev->spread.X, - z + 0.5 * noiseindev_steepness->npindev->spread.Z); + x + 0.5 * noiseindev_steepness->npindev->spread.X * farscale(noiseindev_steepness->npindev->farspread, x, z), + z + 0.5 * noiseindev_steepness->npindev->spread.Z * farscale(noiseindev_steepness->npindev->farspread, x, z)); noiseindev_steepness->transformNoiseMapFarScale(x, y, z); noise_height_select->perlinMap2D( x + 0.5 * noise_height_select->np->spread.X, z + 0.5 * noise_height_select->np->spread.Z); + + noiseindev_float_islands1->perlinMap3D( + x + 0.33 * noiseindev_float_islands1->npindev->spread.X * farscale(noiseindev_float_islands1->npindev->farspread, x, y, z), + y + 0.33 * noiseindev_float_islands1->npindev->spread.Y * farscale(noiseindev_float_islands1->npindev->farspread, x, y, z), + z + 0.33 * noiseindev_float_islands1->npindev->spread.Z * farscale(noiseindev_float_islands1->npindev->farspread, x, y, z) + ); + noiseindev_float_islands1->transformNoiseMapFarScale(x, y, z); + + noiseindev_float_islands2->perlinMap3D( + x + 0.33 * noiseindev_float_islands2->npindev->spread.X * farscale(noiseindev_float_islands2->npindev->farspread, x, y, z), + y + 0.33 * noiseindev_float_islands2->npindev->spread.Y * farscale(noiseindev_float_islands2->npindev->farspread, x, y, z), + z + 0.33 * noiseindev_float_islands2->npindev->spread.Z * farscale(noiseindev_float_islands2->npindev->farspread, x, y, z) + ); + noiseindev_float_islands2->transformNoiseMapFarScale(x, y, z); + + noiseindev_float_islands3->perlinMap2D( + x + 0.5 * noiseindev_float_islands3->npindev->spread.X * farscale(noiseindev_float_islands3->npindev->farspread, x, z), + z + 0.5 * noiseindev_float_islands3->npindev->spread.Z * farscale(noiseindev_float_islands3->npindev->farspread, x, z)); + noiseindev_float_islands3->transformNoiseMapFarScale(x, y, z); + } if (!(flags & MG_FLAT)) { noiseindev_mud->perlinMap2D( - x + 0.5 * noiseindev_mud->npindev->spread.X, - z + 0.5 * noiseindev_mud->npindev->spread.Z); + x + 0.5 * noiseindev_mud->npindev->spread.X * farscale(noiseindev_mud->npindev->farspread, x, y, z), + z + 0.5 * noiseindev_mud->npindev->spread.Z * farscale(noiseindev_mud->npindev->farspread, x, y, z)); noiseindev_mud->transformNoiseMapFarScale(x, y, z); } noise_beach->perlinMap2D( @@ -132,8 +165,8 @@ void MapgenIndev::calculateNoise() { z + 0.7 * noise_beach->np->spread.Z); noise_biome->perlinMap2D( - x + 0.6 * noise_biome->np->spread.X, - z + 0.2 * noise_biome->np->spread.Z); + x + 0.6 * noiseindev_biome->npindev->spread.X * farscale(noiseindev_biome->npindev->farspread, x, z), + z + 0.2 * noiseindev_biome->npindev->spread.Z * farscale(noiseindev_biome->npindev->farspread, x, z)); } bool MapgenIndevParams::readParams(Settings *settings) { @@ -147,17 +180,20 @@ bool MapgenIndevParams::readParams(Settings *settings) { np_trees = settings->getNoiseParams("mgv6_np_trees"); npindev_mud = settings->getNoiseIndevParams("mgindev_np_mud"); np_beach = settings->getNoiseParams("mgv6_np_beach"); - np_biome = settings->getNoiseParams("mgv6_np_biome"); + npindev_biome = settings->getNoiseIndevParams("mgindev_np_biome"); np_cave = settings->getNoiseParams("mgv6_np_cave"); + npindev_float_islands1 = settings->getNoiseIndevParams("mgindev_np_float_islands1"); + npindev_float_islands2 = settings->getNoiseIndevParams("mgindev_np_float_islands2"); + npindev_float_islands3 = settings->getNoiseIndevParams("mgindev_np_float_islands3"); bool success = npindev_terrain_base && npindev_terrain_higher && npindev_steepness && np_height_select && np_trees && npindev_mud && - np_beach && np_biome && np_cave; + np_beach && np_biome && np_cave && + npindev_float_islands1 && npindev_float_islands2 && npindev_float_islands3; return success; } - void MapgenIndevParams::writeParams(Settings *settings) { settings->setFloat("mgv6_freq_desert", freq_desert); settings->setFloat("mgv6_freq_beach", freq_beach); @@ -169,8 +205,11 @@ void MapgenIndevParams::writeParams(Settings *settings) { settings->setNoiseParams("mgv6_np_trees", np_trees); settings->setNoiseIndevParams("mgindev_np_mud", npindev_mud); settings->setNoiseParams("mgv6_np_beach", np_beach); - settings->setNoiseParams("mgv6_np_biome", np_biome); + settings->setNoiseIndevParams("mgindev_np_biome", npindev_biome); settings->setNoiseParams("mgv6_np_cave", np_cave); + settings->setNoiseIndevParams("mgindev_np_float_islands1", npindev_float_islands1); + settings->setNoiseIndevParams("mgindev_np_float_islands2", npindev_float_islands2); + settings->setNoiseIndevParams("mgindev_np_float_islands3", npindev_float_islands3); } @@ -191,7 +230,6 @@ float MapgenIndev::baseTerrainLevelFromNoise(v2s16 p) { steepness, height_select); } - float MapgenIndev::baseTerrainLevelFromMap(int index) { if (flags & MG_FLAT) return water_level; @@ -205,9 +243,7 @@ float MapgenIndev::baseTerrainLevelFromMap(int index) { steepness, height_select); } - -float MapgenIndev::getMudAmount(int index) -{ +float MapgenIndev::getMudAmount(int index) { if (flags & MG_FLAT) return AVERAGE_MUD_AMOUNT; @@ -218,25 +254,19 @@ float MapgenIndev::getMudAmount(int index) return noiseindev_mud->result[index]; } - void MapgenIndev::defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave) { cave.min_tunnel_diameter = 2; cave.max_tunnel_diameter = ps.range(2,6); cave.dswitchint = ps.range(1,14); - //cave.tunnel_routepoints = 0; - //cave.part_max_length_rs = 0; cave.flooded = large_cave && ps.range(0,4); if(large_cave){ cave.part_max_length_rs = ps.range(2,4); -//dstream<<"try:"<setDefault("mgindev_np_float_islands1", "-9.5, 10, (20, 50, 50 ), 45123, 5, 0.6, 1.5, 5"); +void MapgenIndev::generateFloatIslands(int min_y) { + if (node_min.Y < min_y) return; + v3s16 p0(node_min.X, node_min.Y, node_min.Z); + MapNode n1(c_stone), n2(c_desert_stone); + int xl = node_max.X - node_min.X; + int yl = node_max.Y - node_min.Y; + int zl = node_max.Z - node_min.Z; + u32 index = 0; + for (int x1 = 0; x1 <= xl; x1++) + { + //int x = x1 + node_min.Y; + for (int z1 = 0; z1 <= zl; z1++) + { + //int z = z1 + node_min.Z; + for (int y1 = 0; y1 <= yl; y1++, index++) + { + //int y = y1 + node_min.Y; + float noise = noiseindev_float_islands1->result[index]; + //dstream << " y1="<((x), "f,f,v3,s32,s32,f,f") -#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f", (y)) +#define getNoiseIndevParams(x) getStruct((x), "f,f,v3,s32,s32,f,f,f") +#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", (y)) class NoiseIndev : public Noise { public: @@ -59,6 +61,8 @@ class NoiseIndev : public Noise { void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0); }; +extern NoiseIndevParams nparams_indev_def; +/* extern NoiseIndevParams nparams_indev_def_terrain_base; extern NoiseIndevParams nparams_indev_def_terrain_higher; extern NoiseIndevParams nparams_indev_def_steepness; @@ -66,9 +70,10 @@ extern NoiseIndevParams nparams_indev_def_steepness; //extern NoiseIndevParams nparams_indev_def_trees; extern NoiseIndevParams nparams_indev_def_mud; //extern NoiseIndevParams nparams_indev_def_beach; -//extern NoiseIndevParams nparams_indev_def_biome; +extern NoiseIndevParams nparams_indev_def_biome; //extern NoiseIndevParams nparams_indev_def_cave; - +extern NoiseIndevParams nparams_indev_def_float_islands; +*/ struct MapgenIndevParams : public MapgenV6Params { NoiseIndevParams *npindev_terrain_base; @@ -78,21 +83,28 @@ struct MapgenIndevParams : public MapgenV6Params { //NoiseParams *np_trees; NoiseIndevParams *npindev_mud; //NoiseParams *np_beach; - //NoiseParams *np_biome; + NoiseIndevParams *npindev_biome; //NoiseParams *np_cave; + NoiseIndevParams *npindev_float_islands1; + NoiseIndevParams *npindev_float_islands2; + NoiseIndevParams *npindev_float_islands3; MapgenIndevParams() { //freq_desert = 0.45; //freq_beach = 0.15; - npindev_terrain_base = &nparams_indev_def_terrain_base; - npindev_terrain_higher = &nparams_indev_def_terrain_higher; - npindev_steepness = &nparams_indev_def_steepness; + npindev_terrain_base = &nparams_indev_def; //&nparams_indev_def_terrain_base; + npindev_terrain_higher = &nparams_indev_def; //&nparams_indev_def_terrain_higher; + npindev_steepness = &nparams_indev_def; //&nparams_indev_def_steepness; //np_height_select = &nparams_v6_def_height_select; //np_trees = &nparams_v6_def_trees; - npindev_mud = &nparams_indev_def_mud; + npindev_mud = &nparams_indev_def; //&nparams_indev_def_mud; //np_beach = &nparams_v6_def_beach; - //np_biome = &nparams_v6_def_biome; + npindev_biome = &nparams_indev_def; //&nparams_indev_def_biome; //np_cave = &nparams_v6_def_cave; + npindev_float_islands1 = &nparams_indev_def; //&nparams_indev_def_float_islands; + npindev_float_islands2 = &nparams_indev_def; //&nparams_indev_def_float_islands; + npindev_float_islands3 = &nparams_indev_def; //&nparams_indev_def_float_islands; + } bool readParams(Settings *settings); @@ -108,8 +120,11 @@ class MapgenIndev : public MapgenV6 { //NoiseIndev *noise_trees; NoiseIndev *noiseindev_mud; //NoiseIndev *noise_beach; - //NoiseIndev *noise_biome; + NoiseIndev *noiseindev_biome; //NoiseIndevParams *np_cave; + NoiseIndev *noiseindev_float_islands1; + NoiseIndev *noiseindev_float_islands2; + NoiseIndev *noiseindev_float_islands3; MapgenIndev(int mapgenid, MapgenIndevParams *params); ~MapgenIndev(); @@ -119,6 +134,9 @@ class MapgenIndev : public MapgenV6 { float baseTerrainLevelFromMap(int index); float getMudAmount(int index); void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave); + void generateSomething(); + + void generateFloatIslands(int min_y); }; struct MapgenFactoryIndev : public MapgenFactoryV6 { @@ -131,5 +149,4 @@ struct MapgenFactoryIndev : public MapgenFactoryV6 { }; }; - #endif diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index 59a4d49fc..1efa3ad74 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -422,6 +422,8 @@ void MapgenV6::makeChunk(BlockMakeData *data) { // Generate general ground level to full area stone_surface_max_y = generateGround(); + generateSomething(); + const s16 max_spread_amount = MAP_BLOCKSIZE; // Limit dirt flow area by 1 because mud is flown into neighbors. s16 mudflow_minpos = -max_spread_amount + 1; diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 5b3ea9d27..89a3324cd 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -167,6 +167,7 @@ public: virtual void defineCave(Cave &cave, PseudoRandom ps, v3s16 node_min, bool large_cave); void generateCaves(int max_stone_y); + virtual void generateSomething() {}; //for next mapgen }; struct MapgenFactoryV6 : public MapgenFactory { -- cgit v1.2.3