summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-22 18:09:09 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-22 18:09:09 +0200
commit4d757f7b9bcb30affbae7c567e2691cb616e96c1 (patch)
treea1ced43035c5cd1efe427453322c5a13abe20caf
parentfb1988b1cd747c5f77583db827ac240dff2ed4be (diff)
Fix spread_aim producing infinite/nan vectors.
-rw-r--r--src/game/unit_soldier.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp
index d511553..c8e46d0 100644
--- a/src/game/unit_soldier.cpp
+++ b/src/game/unit_soldier.cpp
@@ -65,6 +65,9 @@ static v2f_t spread_aim(v2f_t x, v2f_t aim, float cof, procgen::prng_t *prng)
v2f_t tmp;
r = (aim - x).len();
+ if (r <= 0.1f)
+ return aim;
+
r_ = r + cof * r * prng->next_float(-1.0f, 1.0f);
tmp = (aim - x) / r * r_;