1
0
Fork 0

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.
mutilcraft-mt53
Paramat 2018-06-08 23:24:36 +01:00 committed by GitHub
parent 9ca37d86a3
commit 0b23253447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 20 deletions

View File

@ -1282,7 +1282,7 @@ mapgen_limit (Map generation limit) int 31000 0 31000
# and junglegrass, in all other mapgens this flag controls all decorations. # and junglegrass, in all other mapgens this flag controls all decorations.
# Flags that are not enabled are not modified from the default. # Flags that are not enabled are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them. # 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. # Whether dungeons occasionally project from the terrain.
projecting_dungeons (Projecting dungeons) bool true projecting_dungeons (Projecting dungeons) bool true

View File

@ -56,7 +56,8 @@ FlagDesc flagdesc_mapgen[] = {
{"dungeons", MG_DUNGEONS}, {"dungeons", MG_DUNGEONS},
{"light", MG_LIGHT}, {"light", MG_LIGHT},
{"decorations", MG_DECORATIONS}, {"decorations", MG_DECORATIONS},
{NULL, 0} {"biomes", MG_BIOMES},
{NULL, 0}
}; };
FlagDesc flagdesc_gennotify[] = { FlagDesc flagdesc_gennotify[] = {

View File

@ -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_FLAT 0x08 // Deprecated. Moved into mgv6 flags
#define MG_LIGHT 0x10 #define MG_LIGHT 0x10
#define MG_DECORATIONS 0x20 #define MG_DECORATIONS 0x20
#define MG_BIOMES 0x40
typedef u8 biome_t; // copy from mg_biome.h to avoid an unnecessary include typedef u8 biome_t; // copy from mg_biome.h to avoid an unnecessary include
@ -122,7 +123,7 @@ struct MapgenParams {
u64 seed = 0; u64 seed = 0;
s16 water_level = 1; s16 water_level = 1;
s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT; 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; BiomeParams *bparams = nullptr;

View File

@ -247,8 +247,10 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max); updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap // Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min); if (flags & MG_BIOMES) {
generateBiomes(); biomegen->calcBiomeNoise(node_min);
generateBiomes();
}
// Generate tunnels, caverns and large randomwalk caves // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -284,7 +286,8 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); if (flags & MG_BIOMES)
dustTopNodes();
// Update liquids // Update liquids
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max); updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);

View File

@ -195,8 +195,10 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max); updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap // Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min); if (flags & MG_BIOMES) {
generateBiomes(); biomegen->calcBiomeNoise(node_min);
generateBiomes();
}
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
// Generate tunnels // Generate tunnels
@ -217,7 +219,8 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); if (flags & MG_BIOMES)
dustTopNodes();
//printf("makeChunk: %dms\n", t.stop()); //printf("makeChunk: %dms\n", t.stop());

View File

@ -206,8 +206,10 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max); updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap // Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min); if (flags & MG_BIOMES) {
generateBiomes(); biomegen->calcBiomeNoise(node_min);
generateBiomes();
}
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
// Generate tunnels // Generate tunnels
@ -228,7 +230,8 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); if (flags & MG_BIOMES)
dustTopNodes();
//printf("makeChunk: %dms\n", t.stop()); //printf("makeChunk: %dms\n", t.stop());

View File

@ -206,8 +206,10 @@ void MapgenV5::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max); updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap // Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min); if (flags & MG_BIOMES) {
generateBiomes(); biomegen->calcBiomeNoise(node_min);
generateBiomes();
}
// Generate tunnels, caverns and large randomwalk caves // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -243,7 +245,8 @@ void MapgenV5::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); if (flags & MG_BIOMES)
dustTopNodes();
//printf("makeChunk: %dms\n", t.stop()); //printf("makeChunk: %dms\n", t.stop());

View File

@ -326,8 +326,10 @@ void MapgenV7::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max); updateHeightmap(node_min, node_max);
// Init biome generator, place biome-specific nodes, and build biomemap // Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min); if (flags & MG_BIOMES) {
generateBiomes(); biomegen->calcBiomeNoise(node_min);
generateBiomes();
}
// Generate tunnels, caverns and large randomwalk caves // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -363,7 +365,8 @@ void MapgenV7::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); if (flags & MG_BIOMES)
dustTopNodes();
// Update liquids // Update liquids
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max); updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);

View File

@ -231,7 +231,8 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max); updateHeightmap(node_min, node_max);
// Place biome-specific nodes and build biomemap // Place biome-specific nodes and build biomemap
generateBiomes(); if (flags & MG_BIOMES)
generateBiomes();
// Generate tunnels, caverns and large randomwalk caves // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -265,7 +266,8 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
// Sprinkle some dust on top after everything else was generated // 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); updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);

View File

@ -192,7 +192,12 @@ BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr,
heatmap = noise_heat->result; heatmap = noise_heat->result;
humidmap = noise_humidity->result; humidmap = noise_humidity->result;
biomemap = new biome_t[m_csize.X * m_csize.Z]; 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() BiomeGenOriginal::~BiomeGenOriginal()