From e879c92596f86e8f1ad040e85b2b3eb3c19aab90 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 7 Apr 2012 19:19:36 +0300 Subject: [PATCH] Fix collision code getting stuck if speed is 0 --- src/collision.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/collision.cpp b/src/collision.cpp index 3460b04f..ff0c083f 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 -- 2.30.2