From fc9215760f3e835e391f4f06b306a00540a05f46 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 23 Mar 2024 18:57:40 +0100 Subject: inline update_movement body --- src/critter.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/critter.cpp') 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 +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(index, C, info); +} + template 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& 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(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(i, C, info)) continue; + if (update_movement_3way(i, C, info)) continue; + if (update_movement_3way(i, C, info)) continue; return false; } } -- cgit v1.2.3