1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix formula used for acceleration (#12353)

This commit is contained in:
Lars Müller 2022-09-20 10:55:51 +02:00 committed by GitHub
parent 11905a6db6
commit 1317cd12d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 16 deletions

View file

@ -249,10 +249,12 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
} else {
time_notification_done = false;
}
v3f newpos_f = *pos_f + (*speed_f + accel_f * 0.5f * dtime) * dtime;
*speed_f += accel_f * dtime;
// If there is no speed, there are no collisions
if (speed_f->getLength() == 0)
// If the object is static, there are no collisions
if (newpos_f == *pos_f)
return result;
// Limit speed for avoiding hangs
@ -270,7 +272,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
//TimeTaker tt2("collisionMoveSimple collect boxes");
ScopeProfiler sp2(g_profiler, "collisionMoveSimple(): collect boxes", SPT_AVG);
v3f newpos_f = *pos_f + *speed_f * dtime;
v3f minpos_f(
MYMIN(pos_f->X, newpos_f.X),
MYMIN(pos_f->Y, newpos_f.Y) + 0.01f * BS, // bias rounding, player often at +/-n.5