From 1317cd12d74dba4ff765d6e18b0b30cdf42002a3 Mon Sep 17 00:00:00 2001 From: Lars Müller <34514239+appgurueu@users.noreply.github.com> Date: Tue, 20 Sep 2022 10:55:51 +0200 Subject: Fix formula used for acceleration (#12353) --- src/collision.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/collision.cpp') diff --git a/src/collision.cpp b/src/collision.cpp index be135a225..1ef094d29 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -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 -- cgit v1.2.3