]> git.localhorst.tv Git - blank.git/commitdiff
fix divide by zero in Chaser AI
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 28 Aug 2015 13:28:13 +0000 (15:28 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 28 Aug 2015 13:44:48 +0000 (15:44 +0200)
src/ai/ai.cpp

index 4a2e3102b90d7f6dbdb88ba1bf39d2bd80d171bd..8cd4f1411abb1b9b21be99edb5e679a947c1c4e9 100644 (file)
@@ -30,6 +30,10 @@ Chaser::~Chaser() {
 void Chaser::Update(int dt) {
        glm::vec3 diff(Target().AbsoluteDifference(Controlled()));
        float dist = length(diff);
+       if (dist < std::numeric_limits<float>::epsilon()) {
+               Controlled().Velocity(glm::vec3(0.0f));
+               return;
+       }
        glm::vec3 norm_diff(diff / dist);
 
        bool line_of_sight = true;