forked from Mirrorlandia_minetest/minetest
Biome API: Add noise defined biome blend
This commit is contained in:
parent
2da1503780
commit
e45ecad3ab
@ -532,9 +532,11 @@
|
||||
# Mgv5 uses eased noise for np_ground so this is shown in group format,
|
||||
# other noise parameters are shown in positional format to save space.
|
||||
|
||||
# Noise parameters for biome API temperature and humidity
|
||||
# Noise parameters for biome API temperature, humidity and biome blend
|
||||
#mg_biome_np_heat = 50, 50, (750, 750, 750), 5349, 3, 0.5, 2.0
|
||||
#mg_biome_np_heat_blend = 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0
|
||||
#mg_biome_np_humidity = 50, 50, (750, 750, 750), 842, 3, 0.5, 2.0
|
||||
#mg_biome_np_humidity_blend = 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0
|
||||
|
||||
#mgv5_np_filler_depth = 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0
|
||||
#mgv5_np_factor = 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0
|
||||
|
@ -445,7 +445,9 @@ void MapgenParams::load(const Settings &settings)
|
||||
settings.getS16NoEx("chunksize", chunksize);
|
||||
settings.getFlagStrNoEx("mg_flags", flags, flagdesc_mapgen);
|
||||
settings.getNoiseParams("mg_biome_np_heat", np_biome_heat);
|
||||
settings.getNoiseParams("mg_biome_np_heat_blend", np_biome_heat_blend);
|
||||
settings.getNoiseParams("mg_biome_np_humidity", np_biome_humidity);
|
||||
settings.getNoiseParams("mg_biome_np_humidity_blend", np_biome_humidity_blend);
|
||||
|
||||
delete sparams;
|
||||
sparams = EmergeManager::createMapgenParams(mg_name);
|
||||
@ -462,7 +464,9 @@ void MapgenParams::save(Settings &settings) const
|
||||
settings.setS16("chunksize", chunksize);
|
||||
settings.setFlagStr("mg_flags", flags, flagdesc_mapgen, (u32)-1);
|
||||
settings.setNoiseParams("mg_biome_np_heat", np_biome_heat);
|
||||
settings.setNoiseParams("mg_biome_np_heat_blend", np_biome_heat_blend);
|
||||
settings.setNoiseParams("mg_biome_np_humidity", np_biome_humidity);
|
||||
settings.setNoiseParams("mg_biome_np_humidity_blend", np_biome_humidity_blend);
|
||||
|
||||
if (sparams)
|
||||
sparams->writeParams(&settings);
|
||||
|
@ -115,7 +115,9 @@ struct MapgenParams {
|
||||
u32 flags;
|
||||
|
||||
NoiseParams np_biome_heat;
|
||||
NoiseParams np_biome_heat_blend;
|
||||
NoiseParams np_biome_humidity;
|
||||
NoiseParams np_biome_humidity_blend;
|
||||
|
||||
MapgenSpecificParams *sparams;
|
||||
|
||||
@ -126,7 +128,9 @@ struct MapgenParams {
|
||||
water_level(1),
|
||||
flags(MG_TREES | MG_CAVES | MG_LIGHT),
|
||||
np_biome_heat(NoiseParams(50, 50, v3f(750.0, 750.0, 750.0), 5349, 3, 0.5, 2.0)),
|
||||
np_biome_heat_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 13, 2, 1.0, 2.0)),
|
||||
np_biome_humidity(NoiseParams(50, 50, v3f(750.0, 750.0, 750.0), 842, 3, 0.5, 2.0)),
|
||||
np_biome_humidity_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 90003, 2, 1.0, 2.0)),
|
||||
sparams(NULL)
|
||||
{}
|
||||
|
||||
|
@ -68,13 +68,15 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
|
||||
noise_height = new Noise(&sp->np_height, seed, csize.X, csize.Z);
|
||||
|
||||
// 3D terrain noise
|
||||
noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
|
||||
// Biome noise
|
||||
noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
|
||||
noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
|
||||
noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
|
||||
noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
|
||||
noise_heat_blend = new Noise(¶ms->np_biome_heat_blend, seed, csize.X, csize.Z);
|
||||
noise_humidity_blend = new Noise(¶ms->np_biome_humidity_blend, seed, csize.X, csize.Z);
|
||||
|
||||
//// Resolve nodes to be used
|
||||
INodeDefManager *ndef = emerge->ndef;
|
||||
@ -116,6 +118,8 @@ MapgenV5::~MapgenV5()
|
||||
|
||||
delete noise_heat;
|
||||
delete noise_humidity;
|
||||
delete noise_heat_blend;
|
||||
delete noise_humidity_blend;
|
||||
|
||||
delete[] heightmap;
|
||||
delete[] biomemap;
|
||||
@ -330,7 +334,13 @@ void MapgenV5::calculateNoise()
|
||||
noise_filler_depth->perlinMap2D(x, z);
|
||||
noise_heat->perlinMap2D(x, z);
|
||||
noise_humidity->perlinMap2D(x, z);
|
||||
noise_heat_blend->perlinMap2D(x, z);
|
||||
noise_humidity_blend->perlinMap2D(x, z);
|
||||
|
||||
for (s32 i = 0; i < csize.X * csize.Z; i++) {
|
||||
noise_heat->result[i] += noise_heat_blend->result[i];
|
||||
noise_humidity->result[i] += noise_humidity_blend->result[i];
|
||||
}
|
||||
//printf("calculateNoise: %dus\n", t.stop());
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,11 @@ public:
|
||||
Noise *noise_cave1;
|
||||
Noise *noise_cave2;
|
||||
Noise *noise_ground;
|
||||
|
||||
Noise *noise_heat;
|
||||
Noise *noise_humidity;
|
||||
Noise *noise_heat_blend;
|
||||
Noise *noise_humidity_blend;
|
||||
|
||||
content_t c_stone;
|
||||
content_t c_water_source;
|
||||
|
@ -82,8 +82,10 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
|
||||
noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z);
|
||||
|
||||
//// Biome noise
|
||||
noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
|
||||
noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
|
||||
noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z);
|
||||
noise_humidity = new Noise(¶ms->np_biome_humidity, seed, csize.X, csize.Z);
|
||||
noise_heat_blend = new Noise(¶ms->np_biome_heat_blend, seed, csize.X, csize.Z);
|
||||
noise_humidity_blend = new Noise(¶ms->np_biome_humidity_blend, seed, csize.X, csize.Z);
|
||||
|
||||
//// Resolve nodes to be used
|
||||
INodeDefManager *ndef = emerge->ndef;
|
||||
@ -130,6 +132,8 @@ MapgenV7::~MapgenV7()
|
||||
|
||||
delete noise_heat;
|
||||
delete noise_humidity;
|
||||
delete noise_heat_blend;
|
||||
delete noise_humidity_blend;
|
||||
|
||||
delete[] ridge_heightmap;
|
||||
delete[] heightmap;
|
||||
@ -227,11 +231,11 @@ void MapgenV7::makeChunk(BlockMakeData *data)
|
||||
assert(data->vmanip);
|
||||
assert(data->nodedef);
|
||||
assert(data->blockpos_requested.X >= data->blockpos_min.X &&
|
||||
data->blockpos_requested.Y >= data->blockpos_min.Y &&
|
||||
data->blockpos_requested.Z >= data->blockpos_min.Z);
|
||||
data->blockpos_requested.Y >= data->blockpos_min.Y &&
|
||||
data->blockpos_requested.Z >= data->blockpos_min.Z);
|
||||
assert(data->blockpos_requested.X <= data->blockpos_max.X &&
|
||||
data->blockpos_requested.Y <= data->blockpos_max.Y &&
|
||||
data->blockpos_requested.Z <= data->blockpos_max.Z);
|
||||
data->blockpos_requested.Y <= data->blockpos_max.Y &&
|
||||
data->blockpos_requested.Z <= data->blockpos_max.Z);
|
||||
|
||||
this->generating = true;
|
||||
this->vm = data->vmanip;
|
||||
@ -365,14 +369,23 @@ void MapgenV7::calculateNoise()
|
||||
noise_filler_depth->perlinMap2D(x, z);
|
||||
noise_heat->perlinMap2D(x, z);
|
||||
noise_humidity->perlinMap2D(x, z);
|
||||
noise_heat_blend->perlinMap2D(x, z);
|
||||
noise_humidity_blend->perlinMap2D(x, z);
|
||||
|
||||
for (s32 i = 0; i < csize.X * csize.Z; i++) {
|
||||
noise_heat->result[i] += noise_heat_blend->result[i];
|
||||
noise_humidity->result[i] += noise_humidity_blend->result[i];
|
||||
}
|
||||
//printf("calculateNoise: %dus\n", t.stop());
|
||||
}
|
||||
|
||||
|
||||
Biome *MapgenV7::getBiomeAtPoint(v3s16 p)
|
||||
{
|
||||
float heat = NoisePerlin2D(&noise_heat->np, p.X, p.Z, seed);
|
||||
float humidity = NoisePerlin2D(&noise_humidity->np, p.X, p.Z, seed);
|
||||
float heat = NoisePerlin2D(&noise_heat->np, p.X, p.Z, seed) +
|
||||
NoisePerlin2D(&noise_heat_blend->np, p.X, p.Z, seed);
|
||||
float humidity = NoisePerlin2D(&noise_humidity->np, p.X, p.Z, seed) +
|
||||
NoisePerlin2D(&noise_humidity_blend->np, p.X, p.Z, seed);
|
||||
s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Z);
|
||||
|
||||
return bmgr->getBiome(heat, humidity, groundlevel);
|
||||
|
@ -82,6 +82,8 @@ public:
|
||||
|
||||
Noise *noise_heat;
|
||||
Noise *noise_humidity;
|
||||
Noise *noise_heat_blend;
|
||||
Noise *noise_humidity_blend;
|
||||
|
||||
content_t c_stone;
|
||||
content_t c_water_source;
|
||||
|
Loading…
Reference in New Issue
Block a user