forked from Mirrorlandia_minetest/minetest
Normalized heat and adjusted humidity
This commit is contained in:
parent
82e1ab7b2b
commit
902d5927f0
42
src/map.cpp
42
src/map.cpp
@ -4085,17 +4085,29 @@ s16 ServerMap::getHeat(ServerEnvironment *env, v3s16 p, MapBlock *block)
|
|||||||
//f32 heat = NoisePerlin3D(m_emerge->biomedef->np_heat, p.X, env->getGameTime()/100, p.Z, m_emerge->params->seed);
|
//f32 heat = NoisePerlin3D(m_emerge->biomedef->np_heat, p.X, env->getGameTime()/100, p.Z, m_emerge->params->seed);
|
||||||
|
|
||||||
//variant 2: season change based on default heat map
|
//variant 2: season change based on default heat map
|
||||||
f32 heat = NoisePerlin2D(m_emerge->biomedef->np_heat, p.X, p.Z, m_emerge->params->seed);
|
const f32 offset = 20; // = m_emerge->biomedef->np_heat->offset
|
||||||
heat += -30; // -30 - todo REMOVE after fixed NoiseParams nparams_biome_def_heat = {50, 50, -> 20, 50,
|
const f32 scale = 20; // = m_emerge->biomedef->np_heat->scale
|
||||||
f32 base = (f32)env->getGameTime() * env->getTimeOfDaySpeed();
|
const f32 range = 20;
|
||||||
base /= ( 86400 * g_settings->getS16("year_days") );
|
f32 heat = NoisePerlin2D(m_emerge->biomedef->np_heat, p.X, p.Z,
|
||||||
base += (f32)p.X / 3000;
|
m_emerge->params->seed); // 0..50..100
|
||||||
heat += 30 * sin(base * M_PI); // season
|
|
||||||
|
|
||||||
heat += p.Y / -333; // upper=colder, lower=hotter
|
heat -= m_emerge->biomedef->np_heat->offset; // -50..0..+50
|
||||||
|
|
||||||
|
// normalizing - todo REMOVE after fixed NoiseParams nparams_biome_def_heat = {50, 50, -> 20, 50,
|
||||||
|
if(m_emerge->biomedef->np_heat->scale)
|
||||||
|
heat /= m_emerge->biomedef->np_heat->scale / scale; // -20..0..+20
|
||||||
|
|
||||||
|
f32 seasonv = (f32)env->getGameTime() * env->getTimeOfDaySpeed();
|
||||||
|
seasonv /= 86400 * g_settings->getS16("year_days"); // season change speed
|
||||||
|
seasonv += (f32)p.X / 3000; // you can walk to area with other season
|
||||||
|
seasonv = sin(seasonv * M_PI);
|
||||||
|
heat += (range * (heat < 0 ? 2 : 0.5)) * seasonv; // -60..0..30
|
||||||
|
|
||||||
|
heat += offset; // -40..0..50
|
||||||
|
heat += p.Y / -333; // upper=colder, lower=hotter, 3c per 1000
|
||||||
|
|
||||||
// daily change, hotter at sun +4, colder at night -4
|
// daily change, hotter at sun +4, colder at night -4
|
||||||
heat += 8 * (sin(cycle_shift(env->getTimeOfDayF(), -0.25) * M_PI) - 0.5);
|
heat += 8 * (sin(cycle_shift(env->getTimeOfDayF(), -0.25) * M_PI) - 0.5); //-44..20..54
|
||||||
|
|
||||||
if(block != NULL) {
|
if(block != NULL) {
|
||||||
block->heat = heat;
|
block->heat = heat;
|
||||||
@ -4113,14 +4125,16 @@ s16 ServerMap::getHumidity(ServerEnvironment *env, v3s16 p, MapBlock *block)
|
|||||||
return block->humidity;
|
return block->humidity;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 humidity = NoisePerlin3D( m_emerge->biomedef->np_humidity,
|
f32 humidity = NoisePerlin2D(m_emerge->biomedef->np_humidity, p.X, p.Z,
|
||||||
p.X, env->getGameTime()/10, p.Z,
|
|
||||||
m_emerge->params->seed);
|
m_emerge->params->seed);
|
||||||
humidity += -12 * ( sin(cycle_shift(env->getTimeOfDayF(), -0.1) * M_PI) - 0.5);
|
|
||||||
//todo like heat//humidity += 20 * ( sin(((f32)p.Z / 300) * M_PI) - 0.5);
|
|
||||||
|
|
||||||
if (humidity > 100) humidity = 100;
|
f32 seasonv = (f32)env->getGameTime() * env->getTimeOfDaySpeed();
|
||||||
if (humidity < 0) humidity = 0;
|
seasonv /= 86400 * 2; // bad weather change speed (2 days)
|
||||||
|
seasonv += (f32)p.Z / 300;
|
||||||
|
humidity += 30 * sin(seasonv * M_PI);
|
||||||
|
|
||||||
|
humidity += -12 * ( sin(cycle_shift(env->getTimeOfDayF(), -0.1) * M_PI) - 0.5);
|
||||||
|
humidity = rangelim(humidity, 0, 100);
|
||||||
|
|
||||||
if(block != NULL) {
|
if(block != NULL) {
|
||||||
block->humidity = humidity;
|
block->humidity = humidity;
|
||||||
|
Loading…
Reference in New Issue
Block a user