aboutsummaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-12-18 17:46:00 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-12-18 17:46:00 +0200
commit240499dc2c766c9d022e6df71e770a116a2c95de (patch)
tree3ae7c46b2ab20c226afb0d1ec5c6bddc80f33d48 /src/client.cpp
parent15a43c5ed02130f1b1e07a0385530da197b0c846 (diff)
downloadminetest-240499dc2c766c9d022e6df71e770a116a2c95de.tar.gz
minetest-240499dc2c766c9d022e6df71e770a116a2c95de.tar.bz2
minetest-240499dc2c766c9d022e6df71e770a116a2c95de.zip
before daynight mesh cache
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/client.cpp b/src/client.cpp
index f86445720..9fc9ebce6 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -81,7 +81,9 @@ Client::Client(IrrlichtDevice *device,
camera_direction(0,0,1),
m_server_ser_ver(SER_FMT_VER_INVALID),
m_step_dtime(0.0),
- m_inventory_updated(false)
+ m_inventory_updated(false),
+ m_time(0),
+ m_time_counter(0.0)
{
//m_fetchblock_mutex.Init();
m_incoming_queue_mutex.Init();
@@ -142,6 +144,29 @@ void Client::step(float dtime)
if(dtime > 2.0)
dtime = 2.0;
+ /*
+ Day/night
+ */
+ {
+ m_time_counter += dtime;
+ int seconds = (int)m_time_counter;
+ m_time_counter -= (float)seconds;
+ m_time += seconds;
+ if(seconds > 0)
+ {
+ dstream<<"m_time="<<m_time<<std::endl;
+ JMutexAutoLock envlock(m_env_mutex);
+ u32 dr = 500+500*sin((float)((m_time/10)%7)/7.*2.*PI);
+ if(dr != m_env.getDaylightRatio())
+ {
+ dstream<<"dr="<<dr<<std::endl;
+ m_env.setDaylightRatio(dr);
+ m_env.expireMeshes();
+ }
+ }
+ }
+
+
//dstream<<"Client steps "<<dtime<<std::endl;
{
@@ -1755,4 +1780,9 @@ void Client::printDebugInfo(std::ostream &os)
<<std::endl;
}
+float Client::getDaylightRatio()
+{
+ JMutexAutoLock envlock(m_env_mutex);
+ return m_env.getDaylightRatio();
+}