aboutsummaryrefslogtreecommitdiff
path: root/src/collision.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-04-07 19:19:36 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-04-07 19:19:36 +0300
commite879c92596f86e8f1ad040e85b2b3eb3c19aab90 (patch)
tree42407946b886ed0aa40d6fc1789d43c9962b3ff3 /src/collision.cpp
parent7281c68b271092feeac6f3d56946dbb01d1179e5 (diff)
downloadminetest-e879c92596f86e8f1ad040e85b2b3eb3c19aab90.tar.gz
minetest-e879c92596f86e8f1ad040e85b2b3eb3c19aab90.tar.bz2
minetest-e879c92596f86e8f1ad040e85b2b3eb3c19aab90.zip
Fix collision code getting stuck if speed is 0
Diffstat (limited to 'src/collision.cpp')
-rw-r--r--src/collision.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/collision.cpp b/src/collision.cpp
index 3460b04fd..ff0c083fd 100644
--- a/src/collision.cpp
+++ b/src/collision.cpp
@@ -29,6 +29,10 @@ collisionMoveResult collisionMoveSimple(Map *map, IGameDef *gamedef,
{
collisionMoveResult result;
+ // If there is no speed, there are no collisions
+ if(speed_f.getLength() == 0)
+ return result;
+
v3f oldpos_f = pos_f;
v3s16 oldpos_i = floatToInt(oldpos_f, BS);
@@ -196,6 +200,10 @@ collisionMoveResult collisionMovePrecise(Map *map, IGameDef *gamedef,
f32 dtime, v3f &pos_f, v3f &speed_f)
{
collisionMoveResult final_result;
+
+ // If there is no speed, there are no collisions
+ if(speed_f.getLength() == 0)
+ return final_result;
// Maximum time increment (for collision detection etc)
// time = distance / speed