aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2018-06-08 23:24:36 +0100
committerGitHub <noreply@github.com>2018-06-08 23:24:36 +0100
commit0b23253447623cadf1c394984ce0eee977d54b9b (patch)
tree6417d00f8d850eeb9e9fbda0b7dcf94705763efe
parent9ca37d86a3f8fd35150880e3c64cb81796430d68 (diff)
downloadminetest-0b23253447623cadf1c394984ce0eee977d54b9b.tar.gz
minetest-0b23253447623cadf1c394984ce0eee977d54b9b.tar.bz2
minetest-0b23253447623cadf1c394984ce0eee977d54b9b.zip
Mapgen flags: Add 'biomes' global mapgen flag (#7355)
Previously the only way to disable biomes was to 'clear' the registered biomes in a mod, but this method causes large amounts of unnecessary processing: 1. Calculation of 4 2D noises. 2. Looping through all nodes of a mapchunk replacing nodes with identical nodes. The new flag disables those operations.
-rw-r--r--builtin/settingtypes.txt2
-rw-r--r--src/mapgen/mapgen.cpp3
-rw-r--r--src/mapgen/mapgen.h3
-rw-r--r--src/mapgen/mapgen_carpathian.cpp9
-rw-r--r--src/mapgen/mapgen_flat.cpp9
-rw-r--r--src/mapgen/mapgen_fractal.cpp9
-rw-r--r--src/mapgen/mapgen_v5.cpp9
-rw-r--r--src/mapgen/mapgen_v7.cpp9
-rw-r--r--src/mapgen/mapgen_valleys.cpp6
-rw-r--r--src/mapgen/mg_biome.cpp5
10 files changed, 44 insertions, 20 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 8e42fe29a..653ca0e2f 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -1282,7 +1282,7 @@ mapgen_limit (Map generation limit) int 31000 0 31000
# and junglegrass, in all other mapgens this flag controls all decorations.
# Flags that are not enabled are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
-mg_flags (Mapgen flags) flags caves,dungeons,light,decorations caves,dungeons,light,decorations,nocaves,nodungeons,nolight,nodecorations
+mg_flags (Mapgen flags) flags caves,dungeons,light,decorations,biomes caves,dungeons,light,decorations,biomes,nocaves,nodungeons,nolight,nodecorations,nobiomes
# Whether dungeons occasionally project from the terrain.
projecting_dungeons (Projecting dungeons) bool true
diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp
index dcdaf82c2..360afd897 100644
--- a/src/mapgen/mapgen.cpp
+++ b/src/mapgen/mapgen.cpp
@@ -56,7 +56,8 @@ FlagDesc flagdesc_mapgen[] = {
{"dungeons", MG_DUNGEONS},
{"light", MG_LIGHT},
{"decorations", MG_DECORATIONS},
- {NULL, 0}
+ {"biomes", MG_BIOMES},
+ {NULL, 0}
};
FlagDesc flagdesc_gennotify[] = {
diff --git a/src/mapgen/mapgen.h b/src/mapgen/mapgen.h
index abac79016..b60aea57e 100644
--- a/src/mapgen/mapgen.h
+++ b/src/mapgen/mapgen.h
@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MG_FLAT 0x08 // Deprecated. Moved into mgv6 flags
#define MG_LIGHT 0x10
#define MG_DECORATIONS 0x20
+#define MG_BIOMES 0x40
typedef u8 biome_t; // copy from mg_biome.h to avoid an unnecessary include
@@ -122,7 +123,7 @@ struct MapgenParams {
u64 seed = 0;
s16 water_level = 1;
s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT;
- u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS;
+ u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS | MG_BIOMES;
BiomeParams *bparams = nullptr;
diff --git a/src/mapgen/mapgen_carpathian.cpp b/src/mapgen/mapgen_carpathian.cpp
index 4347f8479..c1e07030c 100644
--- a/src/mapgen/mapgen_carpathian.cpp
+++ b/src/mapgen/mapgen_carpathian.cpp
@@ -247,8 +247,10 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap
- biomegen->calcBiomeNoise(node_min);
- generateBiomes();
+ if (flags & MG_BIOMES) {
+ biomegen->calcBiomeNoise(node_min);
+ generateBiomes();
+ }
// Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
@@ -284,7 +286,8 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated
- dustTopNodes();
+ if (flags & MG_BIOMES)
+ dustTopNodes();
// Update liquids
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
diff --git a/src/mapgen/mapgen_flat.cpp b/src/mapgen/mapgen_flat.cpp
index dbe0bd5bb..e2bc42918 100644
--- a/src/mapgen/mapgen_flat.cpp
+++ b/src/mapgen/mapgen_flat.cpp
@@ -195,8 +195,10 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap
- biomegen->calcBiomeNoise(node_min);
- generateBiomes();
+ if (flags & MG_BIOMES) {
+ biomegen->calcBiomeNoise(node_min);
+ generateBiomes();
+ }
if (flags & MG_CAVES) {
// Generate tunnels
@@ -217,7 +219,8 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated
- dustTopNodes();
+ if (flags & MG_BIOMES)
+ dustTopNodes();
//printf("makeChunk: %dms\n", t.stop());
diff --git a/src/mapgen/mapgen_fractal.cpp b/src/mapgen/mapgen_fractal.cpp
index a1d425cd0..b915cd8f9 100644
--- a/src/mapgen/mapgen_fractal.cpp
+++ b/src/mapgen/mapgen_fractal.cpp
@@ -206,8 +206,10 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap
- biomegen->calcBiomeNoise(node_min);
- generateBiomes();
+ if (flags & MG_BIOMES) {
+ biomegen->calcBiomeNoise(node_min);
+ generateBiomes();
+ }
if (flags & MG_CAVES) {
// Generate tunnels
@@ -228,7 +230,8 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated
- dustTopNodes();
+ if (flags & MG_BIOMES)
+ dustTopNodes();
//printf("makeChunk: %dms\n", t.stop());
diff --git a/src/mapgen/mapgen_v5.cpp b/src/mapgen/mapgen_v5.cpp
index fc0970363..3be704cca 100644
--- a/src/mapgen/mapgen_v5.cpp
+++ b/src/mapgen/mapgen_v5.cpp
@@ -206,8 +206,10 @@ void MapgenV5::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap
- biomegen->calcBiomeNoise(node_min);
- generateBiomes();
+ if (flags & MG_BIOMES) {
+ biomegen->calcBiomeNoise(node_min);
+ generateBiomes();
+ }
// Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
@@ -243,7 +245,8 @@ void MapgenV5::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated
- dustTopNodes();
+ if (flags & MG_BIOMES)
+ dustTopNodes();
//printf("makeChunk: %dms\n", t.stop());
diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp
index 610de4623..e266e29c8 100644
--- a/src/mapgen/mapgen_v7.cpp
+++ b/src/mapgen/mapgen_v7.cpp
@@ -326,8 +326,10 @@ void MapgenV7::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap
- biomegen->calcBiomeNoise(node_min);
- generateBiomes();
+ if (flags & MG_BIOMES) {
+ biomegen->calcBiomeNoise(node_min);
+ generateBiomes();
+ }
// Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
@@ -363,7 +365,8 @@ void MapgenV7::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated
- dustTopNodes();
+ if (flags & MG_BIOMES)
+ dustTopNodes();
// Update liquids
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
diff --git a/src/mapgen/mapgen_valleys.cpp b/src/mapgen/mapgen_valleys.cpp
index 843acb690..341ce3137 100644
--- a/src/mapgen/mapgen_valleys.cpp
+++ b/src/mapgen/mapgen_valleys.cpp
@@ -231,7 +231,8 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Place biome-specific nodes and build biomemap
- generateBiomes();
+ if (flags & MG_BIOMES)
+ generateBiomes();
// Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
@@ -265,7 +266,8 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated
- dustTopNodes();
+ if (flags & MG_BIOMES)
+ dustTopNodes();
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
diff --git a/src/mapgen/mg_biome.cpp b/src/mapgen/mg_biome.cpp
index 42f762709..e02eee703 100644
--- a/src/mapgen/mg_biome.cpp
+++ b/src/mapgen/mg_biome.cpp
@@ -192,7 +192,12 @@ BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr,
heatmap = noise_heat->result;
humidmap = noise_humidity->result;
+
biomemap = new biome_t[m_csize.X * m_csize.Z];
+ // Initialise with the ID of the default biome so that cavegen can get
+ // biomes when biome generation (which calculates the biomemap IDs) is
+ // disabled.
+ memset(biomemap, 0, sizeof(biome_t) * m_csize.X * m_csize.Z);
}
BiomeGenOriginal::~BiomeGenOriginal()