From efecf0ab20304b5d76b3072a66b36b50d8522082 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Nov 2022 21:39:41 +0100 Subject: scenery wip --- src/anim-atlas.cpp | 26 ++++++++++++++++++++++++++ src/anim-atlas.hpp | 3 +++ 2 files changed, 29 insertions(+) (limited to 'src') 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; + 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: -- cgit v1.2.3