summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-27 21:39:41 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-27 21:39:41 +0100
commitefecf0ab20304b5d76b3072a66b36b50d8522082 (patch)
tree5afa6fb96ee863864c52c1a52ede96649c71278a /src
parentbeb6685f605b89ce4b2dd99f87b9319e4f7f4d94 (diff)
scenery wip
Diffstat (limited to 'src')
-rw-r--r--src/anim-atlas.cpp26
-rw-r--r--src/anim-atlas.hpp3
2 files changed, 29 insertions, 0 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp
index e8d4bd9b..f75b1679 100644
--- a/src/anim-atlas.cpp
+++ b/src/anim-atlas.cpp
@@ -137,4 +137,30 @@ BitArrayView anim_atlas::bitmask() const
return _bitmask;
}
+rotation anim_atlas::next_rotation_from(rotation r) const noexcept
+{
+ constexpr auto count = std::size_t(rotation_COUNT);
+ fm_assert(r < rotation_COUNT);
+ for (auto i = std::size_t(r)+1; i < count; i++)
+ if (_group_indices[i] != 0xff)
+ return rotation(i);
+ for (std::size_t i = 0; i < count; i++)
+ if (_group_indices[i] != 0xff)
+ return rotation(i);
+ fm_abort("where did the rotations go?!");
+}
+
+rotation anim_atlas::prev_rotation_from(rotation r) const noexcept
+{
+ using ssize = std::make_signed_t<std::size_t>;
+ constexpr auto count = ssize(rotation_COUNT);
+ for (auto i = ssize(r)-1; i >= 0; i--)
+ if (_group_indices[std::size_t(i)] != 0xff)
+ return rotation(i);
+ for (auto i = count-1; i >= 0; i--)
+ if (_group_indices[std::size_t(i)] != 0xff)
+ return rotation(i);
+ fm_abort("where did the rotations go?!");
+}
+
} // namespace floormat
diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp
index b25ff489..f64e4e01 100644
--- a/src/anim-atlas.hpp
+++ b/src/anim-atlas.hpp
@@ -35,6 +35,9 @@ struct anim_atlas final
BitArrayView bitmask() const;
+ [[nodiscard]] rotation next_rotation_from(rotation r) const noexcept;
+ [[nodiscard]] rotation prev_rotation_from(rotation r) const noexcept;
+
fm_DECLARE_DELETED_COPY_ASSIGNMENT(anim_atlas);
private: