From: Daniel Karbach Date: Fri, 28 Aug 2015 13:28:13 +0000 (+0200) Subject: fix divide by zero in Chaser AI X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=cda510e480aba3702e95059163378822ccac8d17;p=blank.git fix divide by zero in Chaser AI --- diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index 4a2e310..8cd4f14 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -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::epsilon()) { + Controlled().Velocity(glm::vec3(0.0f)); + return; + } glm::vec3 norm_diff(diff / dist); bool line_of_sight = true;