fixed crack animation timing in client
parent
03d67af9e8
commit
a55850e4dc
|
@ -176,6 +176,7 @@ void Client::step(float dtime)
|
||||||
if(dr != m_env.getDayNightRatio())
|
if(dr != m_env.getDayNightRatio())
|
||||||
{
|
{
|
||||||
//dstream<<"dr="<<dr<<std::endl;
|
//dstream<<"dr="<<dr<<std::endl;
|
||||||
|
dout_client<<DTIME<<"Client: changing day-night ratio"<<std::endl;
|
||||||
m_env.setDayNightRatio(dr);
|
m_env.setDayNightRatio(dr);
|
||||||
m_env.expireMeshes(true);
|
m_env.expireMeshes(true);
|
||||||
}
|
}
|
||||||
|
@ -1037,6 +1038,9 @@ bool Client::AsyncProcessPacket(LazyMeshUpdater &mesh_updater)
|
||||||
p.Z = readS16(&data[6]);
|
p.Z = readS16(&data[6]);
|
||||||
|
|
||||||
//TimeTaker t1("TOCLIENT_REMOVENODE", g_device);
|
//TimeTaker t1("TOCLIENT_REMOVENODE", g_device);
|
||||||
|
|
||||||
|
// This will clear the cracking animation after digging
|
||||||
|
((ClientMap&)m_env.getMap()).clearTempMod(p);
|
||||||
|
|
||||||
core::map<v3s16, MapBlock*> modified_blocks;
|
core::map<v3s16, MapBlock*> modified_blocks;
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,15 @@ public:
|
||||||
v3s16 blockpos = ((ClientMap&)m_env.getMap()).clearTempMod(p);
|
v3s16 blockpos = ((ClientMap&)m_env.getMap()).clearTempMod(p);
|
||||||
m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio());
|
m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getAvgRtt()
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_con_mutex);
|
||||||
|
con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
|
||||||
|
if(peer == NULL)
|
||||||
|
return 0.0;
|
||||||
|
return peer->avg_rtt;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -79,5 +79,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
#define WATER_LEVEL (0)
|
#define WATER_LEVEL (0)
|
||||||
|
|
||||||
|
// Length of cracking animation in count of images
|
||||||
|
#define CRACK_ANIMATION_LENGTH 4
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -2114,6 +2114,7 @@ int main(int argc, char *argv[])
|
||||||
static v3s16 nodepos_old(-32768,-32768,-32768);
|
static v3s16 nodepos_old(-32768,-32768,-32768);
|
||||||
|
|
||||||
static float dig_time = 0.0;
|
static float dig_time = 0.0;
|
||||||
|
static u16 dig_index = 0;
|
||||||
|
|
||||||
if(nodepos != nodepos_old)
|
if(nodepos != nodepos_old)
|
||||||
{
|
{
|
||||||
|
@ -2146,19 +2147,25 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if(g_input->getLeftState())
|
if(g_input->getLeftState())
|
||||||
{
|
{
|
||||||
dig_time += dtime;
|
|
||||||
|
|
||||||
float dig_time_complete = 0.5;
|
float dig_time_complete = 0.5;
|
||||||
MapNode n = client.getNode(nodepos);
|
MapNode n = client.getNode(nodepos);
|
||||||
if(n.d == CONTENT_STONE)
|
if(n.d == CONTENT_STONE)
|
||||||
dig_time_complete = 1.5;
|
dig_time_complete = 1.5;
|
||||||
|
|
||||||
|
float dig_time_complete0 = dig_time_complete+client.getAvgRtt()*2;
|
||||||
|
if(dig_time_complete0 < 0.0)
|
||||||
|
dig_time_complete0 = 0.0;
|
||||||
|
|
||||||
u16 dig_index = (u16)(3.99*dig_time/dig_time_complete);
|
dig_index = (u16)((float)CRACK_ANIMATION_LENGTH
|
||||||
if(dig_time > 0.125)
|
* dig_time/dig_time_complete0);
|
||||||
|
|
||||||
|
if(dig_time > 0.125 && dig_index < CRACK_ANIMATION_LENGTH)
|
||||||
{
|
{
|
||||||
//dstream<<"dig_index="<<dig_index<<std::endl;
|
//dstream<<"dig_index="<<dig_index<<std::endl;
|
||||||
client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, dig_index));
|
client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, dig_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dig_time += dtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_input->getRightClicked())
|
if(g_input->getRightClicked())
|
||||||
|
|
Loading…
Reference in New Issue