diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-04 09:04:10 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-04 09:05:29 +0200 |
commit | 5df797182137ac147dbd56b30df9e2a7fa84697e (patch) | |
tree | 80abef9acf702085a5c27a3fb2f8dfd33d0db379 | |
parent | 4291d046bfe7eaa2212e2a8c5afc59234ff8c236 (diff) |
short circuit empty critter movement
-rw-r--r-- | src/critter.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/critter.cpp b/src/critter.cpp index 0e8ac643..6f324077 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -186,12 +186,13 @@ void critter::update(size_t i, float dt) auto offset_ = vec + Vector2(offset_frac) * inv_frac; offset_frac = Vector2s(Vector2(std::fmod(offset_[0], 1.f), std::fmod(offset_[1], 1.f)) * frac); auto off_i = Vector2i(offset_); - if (can_move_to(off_i)) - { - move_to(i, off_i, new_r); - ++frame %= atlas->info().nframes; - goto done; - } + if (!off_i.isZero()) + if (can_move_to(off_i)) + { + move_to(i, off_i, new_r); + ++frame %= atlas->info().nframes; + goto done; + } } delta = 0; break; |