mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Player physics: Ensure larger dtime simulation steps (#10563)
This commit is contained in:
parent
a701d24a00
commit
2dff3dd03f
@ -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();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user