1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Dynamic sky, fog and cloud colors; sun and moon

This commit is contained in:
Perttu Ahola 2012-03-16 16:34:30 +02:00
parent 58bed83d03
commit 2e90ed07ac
30 changed files with 1132 additions and 244 deletions

View file

@ -41,11 +41,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER
#include "clientmap.h"
#endif
#include "daynightratio.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
Environment::Environment():
m_time_of_day(9000)
m_time_of_day(9000),
m_time_of_day_f(9000./24000),
m_time_of_day_speed(0),
m_time_counter(0)
{
}
@ -195,17 +199,35 @@ void Environment::printPlayers(std::ostream &o)
}
}
/*void Environment::setDayNightRatio(u32 r)
{
getDayNightRatio() = r;
}*/
u32 Environment::getDayNightRatio()
{
//return getDayNightRatio();
return time_to_daynight_ratio(m_time_of_day);
}
void Environment::stepTimeOfDay(float dtime)
{
m_time_counter += dtime;
f32 speed = m_time_of_day_speed * 24000./(24.*3600);
u32 units = (u32)(m_time_counter*speed);
m_time_counter -= (f32)units / speed;
bool sync_f = false;
if(units > 0){
// Sync at overflow
if(m_time_of_day + units >= 24000)
sync_f = true;
m_time_of_day = (m_time_of_day + units) % 24000;
if(sync_f)
m_time_of_day_f = (float)m_time_of_day / 24000.0;
}
if(!sync_f){
m_time_of_day_f += m_time_of_day_speed/24/3600*dtime;
if(m_time_of_day_f > 1.0)
m_time_of_day_f -= 1.0;
if(m_time_of_day_f < 0.0)
m_time_of_day_f += 1.0;
}
}
/*
ABMWithState
*/
@ -893,6 +915,9 @@ void ServerEnvironment::step(float dtime)
//TimeTaker timer("ServerEnv step");
/* Step time of day */
stepTimeOfDay(dtime);
/*
Increment game time
*/
@ -1861,6 +1886,9 @@ void ClientEnvironment::step(float dtime)
{
DSTACK(__FUNCTION_NAME);
/* Step time of day */
stepTimeOfDay(dtime);
// Get some settings
bool free_move = g_settings->getBool("free_move");