Biome API: Revert biomes, decos, ores being relative to water level

Feature is unnecessary and would greatly complicate future development,
it would also make 'get biome at pos' extremely complex.
Mgv7: Revert option to repeat surface biomes in floatlands, which
depended on the above.
This commit is contained in:
paramat 2017-09-17 00:26:20 +01:00 committed by paramat
parent 76817fdf98
commit 27144b4716
16 changed files with 42 additions and 99 deletions

@ -1346,10 +1346,9 @@ mgv6_np_apple_trees (Apple trees noise) noise_params 0, 1, (100, 100, 100), 3429
# Map generation attributes specific to Mapgen v7. # Map generation attributes specific to Mapgen v7.
# 'ridges' enables the rivers. # 'ridges' enables the rivers.
# 'biomerepeat' causes surface biomes to repeat in the floatlands.
# Flags that are not specified in the flag string are not modified from the default. # Flags that are not specified in the flag string 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.
mgv7_spflags (Mapgen V7 specific flags) flags mountains,ridges,nofloatlands,caverns,biomerepeat mountains,ridges,floatlands,caverns,biomerepeat,nomountains,noridges,nofloatlands,nocaverns,nobiomerepeat mgv7_spflags (Mapgen V7 specific flags) flags mountains,ridges,nofloatlands,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns
# Y of mountain density gradient zero level. Used to shift mountains vertically. # Y of mountain density gradient zero level. Used to shift mountains vertically.
mgv7_mount_zero_level (Mountain zero level) int 0 mgv7_mount_zero_level (Mountain zero level) int 0

@ -4609,8 +4609,6 @@ Definition tables
y_min = -31000, y_min = -31000,
y_max = 64, y_max = 64,
-- ^ Lower and upper limits for ore. -- ^ Lower and upper limits for ore.
-- ^ Limits are relative to y = water_level - 1 for core mapgen, or
-- ^ relative to y = 0 for minetest.generate_ores().
flags = "", flags = "",
-- ^ Attributes for this ore generation -- ^ Attributes for this ore generation
noise_threshold = 0.5, noise_threshold = 0.5,
@ -4655,7 +4653,6 @@ Definition tables
y_min = 1, y_min = 1,
y_max = 31000, y_max = 31000,
-- ^ Lower and upper limits for biome. -- ^ Lower and upper limits for biome.
-- ^ Limits are relative to y = water_level - 1.
heat_point = 0, heat_point = 0,
humidity_point = 50, humidity_point = 50,
-- ^ Characteristic average temperature and humidity for the biome. -- ^ Characteristic average temperature and humidity for the biome.
@ -4692,8 +4689,6 @@ Definition tables
y_min = -31000 y_min = -31000
y_max = 31000 y_max = 31000
-- ^ Lower and upper limits for decoration. -- ^ Lower and upper limits for decoration.
-- ^ Limits are relative to y = water_level - 1 for core mapgen, or
-- ^ relative to y = 0 for minetest.generate_decorations().
-- ^ This parameter refers to the `y` position of the decoration base, so -- ^ This parameter refers to the `y` position of the decoration base, so
-- the actual maximum height would be `height_max + size.Y`. -- the actual maximum height would be `height_max + size.Y`.
spawn_by = "default:water", spawn_by = "default:water",

@ -613,7 +613,7 @@ MapgenBasic::~MapgenBasic()
void MapgenBasic::generateBiomes(MgStoneType *mgstone_type, void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
content_t *biome_stone, s16 biome_zero_level) content_t *biome_stone)
{ {
// can't generate biomes without a biome generator! // can't generate biomes without a biome generator!
assert(biomegen); assert(biomegen);
@ -665,10 +665,7 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
if (is_stone_surface || is_water_surface) { if (is_stone_surface || is_water_surface) {
// (Re)calculate biome // (Re)calculate biome
// Limit to +-MAX MAP GENERATION LIMIT to work with biome y_min / y_max. biome = biomegen->getBiomeAtIndex(index, y);
s32 relative_y = rangelim(y - biome_zero_level,
-MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
biome = biomegen->getBiomeAtIndex(index, relative_y);
if (biomemap[index] == BIOME_NONE && is_stone_surface) if (biomemap[index] == BIOME_NONE && is_stone_surface)
biomemap[index] = biome->index; biomemap[index] = biome->index;
@ -679,8 +676,7 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
noise_filler_depth->result[index], 0.0f); noise_filler_depth->result[index], 0.0f);
depth_water_top = biome->depth_water_top; depth_water_top = biome->depth_water_top;
depth_riverbed = biome->depth_riverbed; depth_riverbed = biome->depth_riverbed;
biome_y_min = rangelim(biome->y_min + biome_zero_level, biome_y_min = biome->y_min;
-MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
// Detect stone type for dungeons during every biome calculation. // Detect stone type for dungeons during every biome calculation.
// If none detected the last selected biome stone is chosen. // If none detected the last selected biome stone is chosen.

@ -251,7 +251,7 @@ public:
virtual void generateDungeons(s16 max_stone_y, virtual void generateDungeons(s16 max_stone_y,
MgStoneType stone_type, content_t biome_stone); MgStoneType stone_type, content_t biome_stone);
virtual void generateBiomes(MgStoneType *mgstone_type, virtual void generateBiomes(MgStoneType *mgstone_type,
content_t *biome_stone, s16 biome_zero_level); content_t *biome_stone);
virtual void dustTopNodes(); virtual void dustTopNodes();
protected: protected:

@ -245,7 +245,7 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
MgStoneType mgstone_type; MgStoneType mgstone_type;
content_t biome_stone; content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1); generateBiomes(&mgstone_type, &biome_stone);
// Generate caverns, tunnels and classic caves // Generate caverns, tunnels and classic caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -269,12 +269,10 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();

@ -193,7 +193,7 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
MgStoneType mgstone_type; MgStoneType mgstone_type;
content_t biome_stone; content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1); generateBiomes(&mgstone_type, &biome_stone);
if (flags & MG_CAVES) if (flags & MG_CAVES)
generateCaves(stone_surface_max_y, large_cave_depth); generateCaves(stone_surface_max_y, large_cave_depth);
@ -203,12 +203,10 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();

@ -203,7 +203,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
MgStoneType mgstone_type; MgStoneType mgstone_type;
content_t biome_stone; content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1); generateBiomes(&mgstone_type, &biome_stone);
if (flags & MG_CAVES) if (flags & MG_CAVES)
generateCaves(stone_surface_max_y, large_cave_depth); generateCaves(stone_surface_max_y, large_cave_depth);
@ -213,12 +213,10 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();

@ -204,7 +204,7 @@ void MapgenV5::makeChunk(BlockMakeData *data)
MgStoneType mgstone_type; MgStoneType mgstone_type;
content_t biome_stone; content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1); generateBiomes(&mgstone_type, &biome_stone);
// Generate caverns, tunnels and classic caves // Generate caverns, tunnels and classic caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -228,12 +228,10 @@ void MapgenV5::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();

@ -615,12 +615,10 @@ void MapgenV6::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Calculate lighting // Calculate lighting
if (flags & MG_LIGHT) if (flags & MG_LIGHT)

@ -44,7 +44,6 @@ FlagDesc flagdesc_mapgen_v7[] = {
{"ridges", MGV7_RIDGES}, {"ridges", MGV7_RIDGES},
{"floatlands", MGV7_FLOATLANDS}, {"floatlands", MGV7_FLOATLANDS},
{"caverns", MGV7_CAVERNS}, {"caverns", MGV7_CAVERNS},
{"biomerepeat", MGV7_BIOMEREPEAT},
{NULL, 0} {NULL, 0}
}; };
@ -290,12 +289,6 @@ void MapgenV7::makeChunk(BlockMakeData *data)
blockseed = getBlockSeed2(full_node_min, seed); blockseed = getBlockSeed2(full_node_min, seed);
// Get zero level for biomes and decorations
// Optionally repeat surface biomes in floatlands
s16 biome_zero_level = ((spflags & MGV7_FLOATLANDS) &&
(spflags & MGV7_BIOMEREPEAT) && node_max.Y >= shadow_limit) ?
floatland_level - 1 : water_level - 1;
// Generate base and mountain terrain // Generate base and mountain terrain
// An initial heightmap is no longer created here for use in generateRidgeTerrain() // An initial heightmap is no longer created here for use in generateRidgeTerrain()
s16 stone_surface_max_y = generateTerrain(); s16 stone_surface_max_y = generateTerrain();
@ -312,7 +305,7 @@ void MapgenV7::makeChunk(BlockMakeData *data)
MgStoneType mgstone_type; MgStoneType mgstone_type;
content_t biome_stone; content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1); generateBiomes(&mgstone_type, &biome_stone);
// Generate caverns, tunnels and classic caves // Generate caverns, tunnels and classic caves
if (flags & MG_CAVES) { if (flags & MG_CAVES) {
@ -336,12 +329,10 @@ void MapgenV7::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, biome_zero_level);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();

@ -22,12 +22,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapgen.h" #include "mapgen.h"
/////////////// Mapgen V7 flags ///////////// Mapgen V7 flags
#define MGV7_MOUNTAINS 0x01 #define MGV7_MOUNTAINS 0x01
#define MGV7_RIDGES 0x02 #define MGV7_RIDGES 0x02
#define MGV7_FLOATLANDS 0x04 #define MGV7_FLOATLANDS 0x04
#define MGV7_CAVERNS 0x08 #define MGV7_CAVERNS 0x08
#define MGV7_BIOMEREPEAT 0x10 #define MGV7_BIOMEREPEAT 0x10 // Now unused
class BiomeManager; class BiomeManager;
@ -35,8 +35,7 @@ extern FlagDesc flagdesc_mapgen_v7[];
struct MapgenV7Params : public MapgenParams { struct MapgenV7Params : public MapgenParams {
u32 spflags = MGV7_MOUNTAINS | MGV7_RIDGES | u32 spflags = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS;
MGV7_CAVERNS | MGV7_BIOMEREPEAT;
s16 mount_zero_level = 0; s16 mount_zero_level = 0;
float cave_width = 0.09f; float cave_width = 0.09f;
s16 large_cave_depth = -33; s16 large_cave_depth = -33;

@ -237,7 +237,7 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
// Place biome-specific nodes and build biomemap // Place biome-specific nodes and build biomemap
MgStoneType mgstone_type; MgStoneType mgstone_type;
content_t biome_stone; content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1); generateBiomes(&mgstone_type, &biome_stone);
// Cave creation. // Cave creation.
if (flags & MG_CAVES) if (flags & MG_CAVES)
@ -249,12 +249,10 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
// Generate the registered decorations // Generate the registered decorations
if (flags & MG_DECORATIONS) if (flags & MG_DECORATIONS)
m_emerge->decomgr->placeAllDecos(this, blockseed, m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Generate the registered ores // Generate the registered ores
m_emerge->oremgr->placeAllOres(this, blockseed, m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
node_min, node_max, water_level - 1);
// Sprinkle some dust on top after everything else was generated // Sprinkle some dust on top after everything else was generated
dustTopNodes(); dustTopNodes();

@ -48,7 +48,7 @@ DecorationManager::DecorationManager(IGameDef *gamedef) :
size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed, size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed,
v3s16 nmin, v3s16 nmax, s16 deco_zero_level) v3s16 nmin, v3s16 nmax)
{ {
size_t nplaced = 0; size_t nplaced = 0;
@ -57,7 +57,7 @@ size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed,
if (!deco) if (!deco)
continue; continue;
nplaced += deco->placeDeco(mg, blockseed, nmin, nmax, deco_zero_level); nplaced += deco->placeDeco(mg, blockseed, nmin, nmax);
blockseed++; blockseed++;
} }
@ -124,18 +124,8 @@ bool Decoration::canPlaceDecoration(MMVManip *vm, v3s16 p)
} }
size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
v3s16 nmin, v3s16 nmax, s16 deco_zero_level)
{ {
// Decoration y_min / y_max is displaced by deco_zero_level or remains
// unchanged. Any decoration with a limit at +-MAX_MAP_GENERATION_LIMIT is
// considered to have that limit at +-infinity, so we do not alter that limit.
s32 y_min_disp = (y_min <= -MAX_MAP_GENERATION_LIMIT) ?
-MAX_MAP_GENERATION_LIMIT : y_min + deco_zero_level;
s32 y_max_disp = (y_max >= MAX_MAP_GENERATION_LIMIT) ?
MAX_MAP_GENERATION_LIMIT : y_max + deco_zero_level;
PcgRandom ps(blockseed + 53); PcgRandom ps(blockseed + 53);
int carea_size = nmax.X - nmin.X + 1; int carea_size = nmax.X - nmin.X + 1;
@ -190,7 +180,7 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed,
else else
y = mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y); y = mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
if (y < y_min_disp || y > y_max_disp || y < nmin.Y || y > nmax.Y) if (y < y_min || y > y_max || y < nmin.Y || y > nmax.Y)
continue; continue;
if (y + getHeight() > mg->vm->m_area.MaxEdge.Y) if (y + getHeight() > mg->vm->m_area.MaxEdge.Y)

@ -54,8 +54,7 @@ public:
virtual void resolveNodeNames(); virtual void resolveNodeNames();
bool canPlaceDecoration(MMVManip *vm, v3s16 p); bool canPlaceDecoration(MMVManip *vm, v3s16 p);
size_t placeDeco(Mapgen *mg, u32 blockseed, size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
v3s16 nmin, v3s16 nmax, s16 deco_zero_level);
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0; virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0;
virtual int getHeight() = 0; virtual int getHeight() = 0;
@ -133,6 +132,5 @@ public:
} }
} }
size_t placeAllDecos(Mapgen *mg, u32 blockseed, size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
v3s16 nmin, v3s16 nmax, s16 deco_zero_level = 0);
}; };

@ -44,8 +44,7 @@ OreManager::OreManager(IGameDef *gamedef) :
} }
size_t OreManager::placeAllOres(Mapgen *mg, u32 blockseed, size_t OreManager::placeAllOres(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
v3s16 nmin, v3s16 nmax, s16 ore_zero_level)
{ {
size_t nplaced = 0; size_t nplaced = 0;
@ -54,7 +53,7 @@ size_t OreManager::placeAllOres(Mapgen *mg, u32 blockseed,
if (!ore) if (!ore)
continue; continue;
nplaced += ore->placeOre(mg, blockseed, nmin, nmax, ore_zero_level); nplaced += ore->placeOre(mg, blockseed, nmin, nmax);
blockseed++; blockseed++;
} }
@ -88,23 +87,13 @@ void Ore::resolveNodeNames()
} }
size_t Ore::placeOre(Mapgen *mg, u32 blockseed, size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
v3s16 nmin, v3s16 nmax, s16 ore_zero_level)
{ {
// Ore y_min / y_max is displaced by ore_zero_level or remains unchanged. if (nmin.Y > y_max || nmax.Y < y_min)
// Any ore with a limit at +-MAX_MAP_GENERATION_LIMIT is considered to have
// that limit at +-infinity, so we do not alter that limit.
s32 y_min_disp = (y_min <= -MAX_MAP_GENERATION_LIMIT) ?
-MAX_MAP_GENERATION_LIMIT : y_min + ore_zero_level;
s32 y_max_disp = (y_max >= MAX_MAP_GENERATION_LIMIT) ?
MAX_MAP_GENERATION_LIMIT : y_max + ore_zero_level;
if (nmin.Y > y_max_disp || nmax.Y < y_min_disp)
return 0; return 0;
int actual_ymin = MYMAX(nmin.Y, y_min_disp); int actual_ymin = MYMAX(nmin.Y, y_min);
int actual_ymax = MYMIN(nmax.Y, y_max_disp); int actual_ymax = MYMIN(nmax.Y, y_max);
if (clust_size >= actual_ymax - actual_ymin + 1) if (clust_size >= actual_ymax - actual_ymin + 1)
return 0; return 0;

@ -70,8 +70,7 @@ public:
virtual void resolveNodeNames(); virtual void resolveNodeNames();
size_t placeOre(Mapgen *mg, u32 blockseed, size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
v3s16 nmin, v3s16 nmax, s16 ore_zero_level);
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed, virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, u8 *biomemap) = 0; v3s16 nmin, v3s16 nmax, u8 *biomemap) = 0;
}; };
@ -180,6 +179,5 @@ public:
void clear(); void clear();
size_t placeAllOres(Mapgen *mg, u32 blockseed, size_t placeAllOres(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
v3s16 nmin, v3s16 nmax, s16 ore_zero_level = 0);
}; };