diff options
Diffstat (limited to 'src/critter.cpp')
-rw-r--r-- | src/critter.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/critter.cpp b/src/critter.cpp index 9edc147a..3d48ee49 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -129,6 +129,16 @@ bool update_movement_body(size_t& i, critter& C, const anim_def& info) return false; } +template<rotation new_r, size_t k> +CORRADE_ALWAYS_INLINE +bool update_movement_3way(size_t& index, critter& C, const anim_def& info) +{ + constexpr auto rotations = rotation_to_similar(new_r); + constexpr auto vec = rotation_to_vec(rotations[k]); + constexpr auto vx = vec.x(), vy = vec.y(); + return update_movement_body<rotations[k], vx, vy>(index, C, info); +} + template<rotation new_r> CORRADE_NEVER_INLINE bool update_movement_1(critter& C, size_t& i, const anim_def& info, uint32_t nframes) @@ -138,17 +148,9 @@ bool update_movement_1(critter& C, size_t& i, const anim_def& info, uint32_t nfr { for (auto k = 0u; k < nframes; k++) { - constexpr auto fun = []<size_t k>(size_t& index, critter& C, const anim_def& info) { - constexpr auto rotations = rotation_to_similar(new_r); - constexpr auto vec = rotation_to_vec(rotations[k]); - constexpr auto vx = vec.x(), vy = vec.y(); - return update_movement_body<rotations[k], vx, vy>(index, C, info); - }; - - if (fun.template operator()<0>(i, C, info)) continue; - if (fun.template operator()<1>(i, C, info)) continue; - if (fun.template operator()<2>(i, C, info)) continue; - + if (update_movement_3way<new_r, 0>(i, C, info)) continue; + if (update_movement_3way<new_r, 1>(i, C, info)) continue; + if (update_movement_3way<new_r, 2>(i, C, info)) continue; return false; } } |