summaryrefslogtreecommitdiffhomepage
path: root/src/critter.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-23 18:57:40 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-23 18:57:40 +0100
commitfc9215760f3e835e391f4f06b306a00540a05f46 (patch)
tree22400f0d07bfe4fe0aaf9597d67d0fcf20ce593b /src/critter.cpp
parentba7e4da305101440eed3f929abccbcffc9659cc3 (diff)
inline update_movement body
Diffstat (limited to 'src/critter.cpp')
-rw-r--r--src/critter.cpp24
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;
}
}