diff options
author | ShadowNinja <shadowninja@minetest.net> | 2017-06-03 14:55:10 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2017-06-03 14:55:10 -0400 |
commit | caecdb681c428c1aab9c0f7eec2570c0460f995c (patch) | |
tree | e5115982ea59bbf2343ba9b35bc4a0cfbb56f407 /src/mapgen_v5.cpp | |
parent | 81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (diff) | |
parent | 80dc961d24e1964e25d57039ddb2ba639f9f4d22 (diff) | |
download | minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.gz minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.bz2 minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.zip |
Merge 0.4.16 into stable-0.4
Diffstat (limited to 'src/mapgen_v5.cpp')
-rw-r--r-- | src/mapgen_v5.cpp | 91 |
1 files changed, 49 insertions, 42 deletions
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index 9f189e253..932677e2a 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -1,7 +1,7 @@ /* Minetest -Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net> -Copyright (C) 2010-2015 paramat, Matt Gregory +Copyright (C) 2014-2017 paramat +Copyright (C) 2014-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net> 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 @@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "emerge.h" #include "dungeongen.h" #include "cavegen.h" -#include "treegen.h" #include "mg_biome.h" #include "mg_ore.h" #include "mg_decoration.h" @@ -41,15 +40,19 @@ with this program; if not, write to the Free Software Foundation, Inc., FlagDesc flagdesc_mapgen_v5[] = { - {NULL, 0} + {"caverns", MGV5_CAVERNS}, + {NULL, 0} }; MapgenV5::MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge) : MapgenBasic(mapgenid, params, emerge) { - this->spflags = params->spflags; - this->cave_width = params->cave_width; + this->spflags = params->spflags; + this->cave_width = params->cave_width; + this->cavern_limit = params->cavern_limit; + this->cavern_taper = params->cavern_taper; + this->cavern_threshold = params->cavern_threshold; // Terrain noise noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); @@ -59,9 +62,10 @@ MapgenV5::MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge) // 3D terrain noise // 1-up 1-down overgeneration noise_ground = new Noise(¶ms->np_ground, seed, csize.X, csize.Y + 2, csize.Z); - - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; + // 1 down overgeneration + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cavern = params->np_cavern; } @@ -76,47 +80,55 @@ MapgenV5::~MapgenV5() MapgenV5Params::MapgenV5Params() { - spflags = 0; - cave_width = 0.125; + spflags = MGV5_CAVERNS; + cave_width = 0.125; + cavern_limit = -256; + cavern_taper = 256; + cavern_threshold = 0.7; np_filler_depth = NoiseParams(0, 1, v3f(150, 150, 150), 261, 4, 0.7, 2.0); np_factor = NoiseParams(0, 1, v3f(250, 250, 250), 920381, 3, 0.45, 2.0); np_height = NoiseParams(0, 10, v3f(250, 250, 250), 84174, 4, 0.5, 2.0); + np_ground = NoiseParams(0, 40, v3f(80, 80, 80), 983240, 4, 0.55, 2.0, NOISE_FLAG_EASED); np_cave1 = NoiseParams(0, 12, v3f(50, 50, 50), 52534, 4, 0.5, 2.0); np_cave2 = NoiseParams(0, 12, v3f(50, 50, 50), 10325, 4, 0.5, 2.0); - np_ground = NoiseParams(0, 40, v3f(80, 80, 80), 983240, 4, 0.55, 2.0, NOISE_FLAG_EASED); + np_cavern = NoiseParams(0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0); } -//#define CAVE_NOISE_SCALE 12.0 -//#define CAVE_NOISE_THRESHOLD (1.5/CAVE_NOISE_SCALE) = 0.125 - - void MapgenV5Params::readParams(const Settings *settings) { - settings->getFlagStrNoEx("mgv5_spflags", spflags, flagdesc_mapgen_v5); - settings->getFloatNoEx("mgv5_cave_width", cave_width); + settings->getFlagStrNoEx("mgv5_spflags", spflags, flagdesc_mapgen_v5); + settings->getFloatNoEx("mgv5_cave_width", cave_width); + settings->getS16NoEx("mgv5_cavern_limit", cavern_limit); + settings->getS16NoEx("mgv5_cavern_taper", cavern_taper); + settings->getFloatNoEx("mgv5_cavern_threshold", cavern_threshold); settings->getNoiseParams("mgv5_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgv5_np_factor", np_factor); settings->getNoiseParams("mgv5_np_height", np_height); + settings->getNoiseParams("mgv5_np_ground", np_ground); settings->getNoiseParams("mgv5_np_cave1", np_cave1); settings->getNoiseParams("mgv5_np_cave2", np_cave2); - settings->getNoiseParams("mgv5_np_ground", np_ground); + settings->getNoiseParams("mgv5_np_cavern", np_cavern); } void MapgenV5Params::writeParams(Settings *settings) const { - settings->setFlagStr("mgv5_spflags", spflags, flagdesc_mapgen_v5, U32_MAX); - settings->setFloat("mgv5_cave_width", cave_width); + settings->setFlagStr("mgv5_spflags", spflags, flagdesc_mapgen_v5, U32_MAX); + settings->setFloat("mgv5_cave_width", cave_width); + settings->setS16("mgv5_cavern_limit", cavern_limit); + settings->setS16("mgv5_cavern_taper", cavern_taper); + settings->setFloat("mgv5_cavern_threshold", cavern_threshold); settings->setNoiseParams("mgv5_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgv5_np_factor", np_factor); settings->setNoiseParams("mgv5_np_height", np_height); + settings->setNoiseParams("mgv5_np_ground", np_ground); settings->setNoiseParams("mgv5_np_cave1", np_cave1); settings->setNoiseParams("mgv5_np_cave2", np_cave2); - settings->setNoiseParams("mgv5_np_ground", np_ground); + settings->setNoiseParams("mgv5_np_cavern", np_cavern); } @@ -190,9 +202,21 @@ void MapgenV5::makeChunk(BlockMakeData *data) biomegen->calcBiomeNoise(node_min); MgStoneType stone_type = generateBiomes(); - // Generate caves - if ((flags & MG_CAVES) && (stone_surface_max_y >= node_min.Y)) - generateCaves(stone_surface_max_y, MGV5_LARGE_CAVE_DEPTH); + // Generate caverns, tunnels and classic caves + if (flags & MG_CAVES) { + bool near_cavern = false; + // Generate caverns + if (spflags & MGV5_CAVERNS) + near_cavern = generateCaverns(stone_surface_max_y); + // Generate tunnels and classic caves + if (near_cavern) + // Disable classic caves in this mapchunk by setting + // 'large cave depth' to world base. Avoids excessive liquid in + // large caverns and floating blobs of overgenerated liquid. + generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT); + else + generateCaves(stone_surface_max_y, MGV5_LARGE_CAVE_DEPTH); + } // Generate dungeons and desert temples if (flags & MG_DUNGEONS) @@ -223,23 +247,6 @@ void MapgenV5::makeChunk(BlockMakeData *data) } -//bool is_cave(u32 index) { -// double d1 = contour(noise_cave1->result[index]); -// double d2 = contour(noise_cave2->result[index]); -// return d1*d2 > CAVE_NOISE_THRESHOLD; -//} - -//bool val_is_ground(v3s16 p, u32 index, u32 index2d) { -// double f = 0.55 + noise_factor->result[index2d]; -// if(f < 0.01) -// f = 0.01; -// else if(f >= 1.0) -// f *= 1.6; -// double h = WATER_LEVEL + 10 * noise_height->result[index2d]; -// return (noise_ground->result[index] * f > (double)p.Y - h); -//} - - int MapgenV5::generateBaseTerrain() { u32 index = 0; |