Player physics: Ensure larger dtime simulation steps (#10563)

master
Lars Müller 2020-10-29 20:15:46 +01:00 committed by GitHub
parent a701d24a00
commit 2dff3dd03f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 46 additions and 69 deletions

View File

@ -183,39 +183,17 @@ void ClientEnvironment::step(float dtime)
if(dtime > 0.5)
dtime = 0.5;
f32 dtime_downcount = dtime;
/*
Stuff that has a maximum time increment
*/
u32 loopcount = 0;
do
{
loopcount++;
f32 dtime_part;
if(dtime_downcount > dtime_max_increment)
{
dtime_part = dtime_max_increment;
dtime_downcount -= dtime_part;
}
else
{
dtime_part = dtime_downcount;
u32 steps = ceil(dtime / dtime_max_increment);
f32 dtime_part = dtime / steps;
for (; steps > 0; --steps) {
/*
Setting this to 0 (no -=dtime_part) disables an infinite loop
when dtime_part is so small that dtime_downcount -= dtime_part
does nothing
*/
dtime_downcount = 0;
}
/*
Handle local player
Local player handling
*/
{
// Control local player
lplayer->applyControl(dtime_part, this);
@ -260,7 +238,6 @@ void ClientEnvironment::step(float dtime)
lplayer->move(dtime_part, this, position_max_increment,
&player_collisions);
}
} while (dtime_downcount > 0.001);
bool player_immortal = lplayer->getCAO() && lplayer->getCAO()->isImmortal();