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

This commit is contained in:
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

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