diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-04-22 18:09:09 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-04-22 18:09:09 +0200 |
commit | 4d757f7b9bcb30affbae7c567e2691cb616e96c1 (patch) | |
tree | a1ced43035c5cd1efe427453322c5a13abe20caf | |
parent | fb1988b1cd747c5f77583db827ac240dff2ed4be (diff) |
Fix spread_aim producing infinite/nan vectors.
-rw-r--r-- | src/game/unit_soldier.cpp | 3 |
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_; |