summaryrefslogtreecommitdiff
path: root/src/mapgen/mapgen.cpp
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2019-06-01 20:50:43 +0100
committerGitHub <noreply@github.com>2019-06-01 20:50:43 +0100
commit7379aa74cf98c7e4c7aa5325ef1531d412a0abac (patch)
tree45a3c608dce1fd03182f4f84f1968439dbfa4dbc /src/mapgen/mapgen.cpp
parenta1459a9eac4eeb35a6c578a8b8f96393f87ed53d (diff)
downloadminetest-7379aa74cf98c7e4c7aa5325ef1531d412a0abac.tar.gz
minetest-7379aa74cf98c7e4c7aa5325ef1531d412a0abac.tar.bz2
minetest-7379aa74cf98c7e4c7aa5325ef1531d412a0abac.zip
Dungeons: Settable density noise, move number calculation to mapgens (#8473)
Add user-settable noise parameters for dungeon density to each mapgen, except V6 which hardcodes this noise parameter. Move the calculation of number of dungeons generated in a mapchunk out of dungeongen.cpp and into mapgen code, to allow mapgens to generate any desired number of dungeons in a mapchunk, instead of being forced to have number of dungeons determined by a density noise. This is more flexible and allows mapgens to use dungeon generation to create custom structures, such as occasional mega-dungeons.
Diffstat (limited to 'src/mapgen/mapgen.cpp')
-rw-r--r--src/mapgen/mapgen.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp
index bdbbc01f7..c4aaff00d 100644
--- a/src/mapgen/mapgen.cpp
+++ b/src/mapgen/mapgen.cpp
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <cmath>
#include "mapgen.h"
#include "voxel.h"
#include "noise.h"
@@ -889,6 +890,11 @@ void MapgenBasic::generateDungeons(s16 max_stone_y)
if (max_stone_y < node_min.Y)
return;
+ u16 num_dungeons = std::fmax(std::floor(
+ NoisePerlin3D(&np_dungeons, node_min.X, node_min.Y, node_min.Z, seed)), 0.0f);
+ if (num_dungeons == 0)
+ return;
+
// Get biome at mapchunk midpoint
v3s16 chunk_mid = node_min + (node_max - node_min) / v3s16(2, 2, 2);
Biome *biome = (Biome *)biomegen->getBiomeAtPoint(chunk_mid);
@@ -902,8 +908,8 @@ void MapgenBasic::generateDungeons(s16 max_stone_y)
dp.rooms_min = 2;
dp.rooms_max = 16;
- dp.np_density = nparams_dungeon_density;
- dp.np_alt_wall = nparams_dungeon_alt_wall;
+ dp.np_alt_wall =
+ NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
// Biome-defined dungeon nodes
if (biome->c_dungeon != CONTENT_IGNORE) {
@@ -980,7 +986,7 @@ void MapgenBasic::generateDungeons(s16 max_stone_y)
}
DungeonGen dgen(ndef, &gennotify, &dp);
- dgen.generate(vm, blockseed, full_node_min, full_node_max);
+ dgen.generate(vm, blockseed, full_node_min, full_node_max, num_dungeons);
}