From 902d5927f00677adfe33320af0ddc49e8eb0a16e Mon Sep 17 00:00:00 2001 From: proller Date: Mon, 19 Aug 2013 22:30:14 +0400 Subject: [PATCH] Normalized heat and adjusted humidity --- src/map.cpp | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 62ba85c4..457db14d 100644 --- a/src/map.cpp +++ b/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); //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); - heat += -30; // -30 - todo REMOVE after fixed NoiseParams nparams_biome_def_heat = {50, 50, -> 20, 50, - f32 base = (f32)env->getGameTime() * env->getTimeOfDaySpeed(); - base /= ( 86400 * g_settings->getS16("year_days") ); - base += (f32)p.X / 3000; - heat += 30 * sin(base * M_PI); // season + const f32 offset = 20; // = m_emerge->biomedef->np_heat->offset + const f32 scale = 20; // = m_emerge->biomedef->np_heat->scale + const f32 range = 20; + f32 heat = NoisePerlin2D(m_emerge->biomedef->np_heat, p.X, p.Z, + m_emerge->params->seed); // 0..50..100 - 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 - 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) { block->heat = heat; @@ -4113,14 +4125,16 @@ s16 ServerMap::getHumidity(ServerEnvironment *env, v3s16 p, MapBlock *block) return block->humidity; } - f32 humidity = NoisePerlin3D( m_emerge->biomedef->np_humidity, - p.X, env->getGameTime()/10, p.Z, - 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); + f32 humidity = NoisePerlin2D(m_emerge->biomedef->np_humidity, p.X, p.Z, + m_emerge->params->seed); + + f32 seasonv = (f32)env->getGameTime() * env->getTimeOfDaySpeed(); + seasonv /= 86400 * 2; // bad weather change speed (2 days) + seasonv += (f32)p.Z / 300; + humidity += 30 * sin(seasonv * M_PI); - if (humidity > 100) humidity = 100; - if (humidity < 0) humidity = 0; + humidity += -12 * ( sin(cycle_shift(env->getTimeOfDayF(), -0.1) * M_PI) - 0.5); + humidity = rangelim(humidity, 0, 100); if(block != NULL) { block->humidity = humidity; -- 2.30.2