mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Mapgen: Optimize biomemap creation by combining with generateBiomes
This commit is contained in:
parent
d24f384174
commit
d4457ef420
@ -524,6 +524,10 @@ MapgenBasic::~MapgenBasic()
|
|||||||
|
|
||||||
MgStoneType MapgenBasic::generateBiomes()
|
MgStoneType MapgenBasic::generateBiomes()
|
||||||
{
|
{
|
||||||
|
// can't generate biomes without a biome generator!
|
||||||
|
assert(biomegen);
|
||||||
|
assert(biomemap);
|
||||||
|
|
||||||
v3s16 em = vm->m_area.getExtent();
|
v3s16 em = vm->m_area.getExtent();
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
MgStoneType stone_type = MGSTONE_STONE;
|
MgStoneType stone_type = MGSTONE_STONE;
|
||||||
@ -546,6 +550,8 @@ MgStoneType MapgenBasic::generateBiomes()
|
|||||||
bool river_water_above = c_above == c_river_water_source;
|
bool river_water_above = c_above == c_river_water_source;
|
||||||
bool water_above = c_above == c_water_source || river_water_above;
|
bool water_above = c_above == c_water_source || river_water_above;
|
||||||
|
|
||||||
|
biomemap[index] = BIOME_NONE;
|
||||||
|
|
||||||
// If there is air or water above enable top/filler placement, otherwise force
|
// If there is air or water above enable top/filler placement, otherwise force
|
||||||
// nplaced to stone level by setting a number exceeding any possible filler depth.
|
// nplaced to stone level by setting a number exceeding any possible filler depth.
|
||||||
u16 nplaced = (air_above || water_above) ? 0 : U16_MAX;
|
u16 nplaced = (air_above || water_above) ? 0 : U16_MAX;
|
||||||
@ -560,11 +566,19 @@ MgStoneType MapgenBasic::generateBiomes()
|
|||||||
// 1. At the surface of stone below air or water.
|
// 1. At the surface of stone below air or water.
|
||||||
// 2. At the surface of water below air.
|
// 2. At the surface of water below air.
|
||||||
// 3. When stone or water is detected but biome has not yet been calculated.
|
// 3. When stone or water is detected but biome has not yet been calculated.
|
||||||
if ((c == c_stone && (air_above || water_above || !biome))
|
bool is_stone_surface = (c == c_stone) &&
|
||||||
|| ((c == c_water_source || c == c_river_water_source)
|
(air_above || water_above || !biome);
|
||||||
&& (air_above || !biome))) {
|
|
||||||
|
bool is_water_surface =
|
||||||
|
(c == c_water_source || c == c_river_water_source) &&
|
||||||
|
(air_above || !biome);
|
||||||
|
|
||||||
|
if (is_stone_surface || is_water_surface) {
|
||||||
biome = biomegen->getBiomeAtIndex(index, y);
|
biome = biomegen->getBiomeAtIndex(index, y);
|
||||||
|
|
||||||
|
if (biomemap[index] == BIOME_NONE && is_stone_surface)
|
||||||
|
biomemap[index] = biome->index;
|
||||||
|
|
||||||
depth_top = biome->depth_top;
|
depth_top = biome->depth_top;
|
||||||
base_filler = MYMAX(depth_top +
|
base_filler = MYMAX(depth_top +
|
||||||
biome->depth_filler +
|
biome->depth_filler +
|
||||||
|
@ -192,7 +192,6 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
|
|||||||
|
|
||||||
// Init biome generator, place biome-specific nodes, and build biomemap
|
// Init biome generator, place biome-specific nodes, and build biomemap
|
||||||
biomegen->calcBiomeNoise(node_min);
|
biomegen->calcBiomeNoise(node_min);
|
||||||
biomegen->getBiomes(heightmap);
|
|
||||||
MgStoneType stone_type = generateBiomes();
|
MgStoneType stone_type = generateBiomes();
|
||||||
|
|
||||||
if (flags & MG_CAVES)
|
if (flags & MG_CAVES)
|
||||||
|
@ -208,7 +208,6 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
|
|||||||
|
|
||||||
// Init biome generator, place biome-specific nodes, and build biomemap
|
// Init biome generator, place biome-specific nodes, and build biomemap
|
||||||
biomegen->calcBiomeNoise(node_min);
|
biomegen->calcBiomeNoise(node_min);
|
||||||
biomegen->getBiomes(heightmap);
|
|
||||||
MgStoneType stone_type = generateBiomes();
|
MgStoneType stone_type = generateBiomes();
|
||||||
|
|
||||||
if (flags & MG_CAVES)
|
if (flags & MG_CAVES)
|
||||||
|
@ -190,7 +190,6 @@ void MapgenV5::makeChunk(BlockMakeData *data)
|
|||||||
|
|
||||||
// Init biome generator, place biome-specific nodes, and build biomemap
|
// Init biome generator, place biome-specific nodes, and build biomemap
|
||||||
biomegen->calcBiomeNoise(node_min);
|
biomegen->calcBiomeNoise(node_min);
|
||||||
biomegen->getBiomes(heightmap);
|
|
||||||
MgStoneType stone_type = generateBiomes();
|
MgStoneType stone_type = generateBiomes();
|
||||||
|
|
||||||
// Generate caves
|
// Generate caves
|
||||||
|
@ -219,7 +219,6 @@ void MapgenV7::makeChunk(BlockMakeData *data)
|
|||||||
|
|
||||||
// Init biome generator, place biome-specific nodes, and build biomemap
|
// Init biome generator, place biome-specific nodes, and build biomemap
|
||||||
biomegen->calcBiomeNoise(node_min);
|
biomegen->calcBiomeNoise(node_min);
|
||||||
biomegen->getBiomes(heightmap);
|
|
||||||
MgStoneType stone_type = generateBiomes();
|
MgStoneType stone_type = generateBiomes();
|
||||||
|
|
||||||
if (flags & MG_CAVES)
|
if (flags & MG_CAVES)
|
||||||
|
@ -250,10 +250,7 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
|
|||||||
// Generate base terrain with initial heightmaps
|
// Generate base terrain with initial heightmaps
|
||||||
s16 stone_surface_max_y = generateTerrain();
|
s16 stone_surface_max_y = generateTerrain();
|
||||||
|
|
||||||
// Build biomemap
|
// Place biome-specific nodes and build biomemap
|
||||||
m_bgen->getBiomes(heightmap);
|
|
||||||
|
|
||||||
// Place biome-specific nodes
|
|
||||||
MgStoneType stone_type = generateBiomes();
|
MgStoneType stone_type = generateBiomes();
|
||||||
|
|
||||||
// Cave creation.
|
// Cave creation.
|
||||||
|
Loading…
Reference in New Issue
Block a user