summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-23 19:05:04 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-23 19:05:04 +0100
commit38b7a0ae1ee5cd58a35e54d8ea6dc853ad744b89 (patch)
tree99e207b99bd817efe28c321641cefbd5843c7daf
parenta34efd6a77a71650c8d690fed3162646e66570ec (diff)
a
-rw-r--r--src/critter.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/critter.cpp b/src/critter.cpp
index 9a310955..ef3fd2a2 100644
--- a/src/critter.cpp
+++ b/src/critter.cpp
@@ -130,13 +130,27 @@ bool update_movement_body(size_t& i, critter& C, const anim_def& info)
}
template<rotation r>
-CORRADE_ALWAYS_INLINE
-bool update_movement_3way(size_t& index, critter& C, const anim_def& info)
+CORRADE_NEVER_INLINE
+bool update_movement_2(size_t& index, critter& C, const anim_def& info)
{
constexpr auto vec = rotation_to_vec(r);
return update_movement_body<r, vec.x(), vec.y()>(index, C, info);
}
+template<rotation r>
+CORRADE_ALWAYS_INLINE
+bool update_movement_3way(size_t i, critter& C, const anim_def& info)
+{
+ constexpr auto rotations = rotation_to_similar(r);
+ if (update_movement_2<rotations[0]>(i, C, info))
+ return true;
+ if (update_movement_2<rotations[1]>(i, C, info))
+ return true;
+ if (update_movement_2<rotations[2]>(i, C, info))
+ return true;
+ return false;
+}
+
template<rotation new_r>
CORRADE_NEVER_INLINE
bool update_movement_1(critter& C, size_t& i, const anim_def& info, uint32_t nframes)
@@ -145,13 +159,8 @@ bool update_movement_1(critter& C, size_t& i, const anim_def& info, uint32_t nfr
if constexpr(Diagonal)
{
for (auto k = 0u; k < nframes; k++)
- {
- constexpr auto rotations = rotation_to_similar(new_r);
- if (update_movement_3way<rotations[0]>(i, C, info)) continue;
- if (update_movement_3way<rotations[1]>(i, C, info)) continue;
- if (update_movement_3way<rotations[2]>(i, C, info)) continue;
- return false;
- }
+ if (!update_movement_3way<new_r>(i, C, info))
+ return false;
}
else
{