aboutsummaryrefslogtreecommitdiff
path: root/src/collision.cpp
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2022-09-20 10:55:51 +0200
committerGitHub <noreply@github.com>2022-09-20 10:55:51 +0200
commit1317cd12d74dba4ff765d6e18b0b30cdf42002a3 (patch)
tree417fcd478cf89fbf4912f816bec13cf8a4b6a9c5 /src/collision.cpp
parent11905a6db65e70c84683098711ce36958968c6c3 (diff)
downloadminetest-1317cd12d74dba4ff765d6e18b0b30cdf42002a3.tar.xz
Fix formula used for acceleration (#12353)
Diffstat (limited to 'src/collision.cpp')
-rw-r--r--src/collision.cpp7
1 files changed, 4 insertions, 3 deletions
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