diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-08 02:33:38 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-08 02:33:38 +0100 |
commit | 69324ea83c8c4e73e5e201e0ca53114484a49791 (patch) | |
tree | 85f77a6408cb06a405f48beedd229319f376755a /src | |
parent | 8df4de4557ea49ff39462505a0662aacca447bf3 (diff) |
a
Diffstat (limited to 'src')
-rw-r--r-- | src/anim-atlas.cpp | 22 | ||||
-rw-r--r-- | src/anim-atlas.hpp | 2 |
2 files changed, 8 insertions, 16 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index 0bd886bc..4b502208 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -1,6 +1,7 @@ #include "anim-atlas.hpp" #include "compat/assert.hpp" #include "shaders/tile.hpp" +#include "tile-defs.hpp" #include <Magnum/Math/Color.h> #include <Magnum/GL/TextureFormat.h> @@ -68,12 +69,8 @@ auto anim_atlas::frame(rotation r, std::size_t frame) const noexcept -> const an auto anim_atlas::texcoords_for_frame(rotation r, std::size_t i) const noexcept -> texcoords { - return texcoords_for_frame(frame(r, i)); -} - -auto anim_atlas::texcoords_for_frame(const anim_frame& frame) const noexcept -> texcoords -{ - const Vector2 p0(frame.offset), p1(frame.size); + const auto f = frame(r, i); + const Vector2 p0(f.offset), p1(f.size); const auto x0 = p0.x()+.5f, x1 = p1.x()-1, y0 = p0.y()+.5f, y1 = p1.y()-1; const auto size = _info.pixel_size; return {{ @@ -86,14 +83,11 @@ auto anim_atlas::texcoords_for_frame(const anim_frame& frame) const noexcept -> auto anim_atlas::frame_quad(const Vector3& center, rotation r, std::size_t i) const noexcept -> quad { - return frame_quad(center, frame(r, i)); -} - -auto anim_atlas::frame_quad(const Vector3& center, const anim_frame& frame) noexcept -> quad -{ - const auto size = Vector2d(frame.size); - const double gx = frame.ground[0]*.25, gy = frame.ground[1]*.25; - const double sx = size[0]*.25, sy = size[1]*.25; + const auto f = frame(r, i); + const auto size = Vector2d(f.size); + const double gx = f.ground[0]*.5, gy = f.ground[1]*.5; + //auto gx = 0, gy = 0; + const double sx = size[0]*.5, sy = size[1]*.5; const auto bottom_right = Vector2(tile_shader::unproject({ sx - gx, sy - gy })), top_right = Vector2(tile_shader::unproject({ sx - gx, -sy - gy })), bottom_left = Vector2(tile_shader::unproject({ -sx - gx, sy - gy })), diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp index c54cf373..40cc15fe 100644 --- a/src/anim-atlas.hpp +++ b/src/anim-atlas.hpp @@ -32,9 +32,7 @@ struct anim_atlas final const anim_group& group(rotation r) const noexcept; const anim_frame& frame(rotation r, std::size_t frame) const noexcept; texcoords texcoords_for_frame(rotation r, std::size_t frame) const noexcept; - texcoords texcoords_for_frame(const anim_frame& frame) const noexcept; quad frame_quad(const Vector3& center, rotation r, std::size_t frame) const noexcept; - static quad frame_quad(const Vector3& center, const anim_frame& frame) noexcept; fm_DECLARE_DELETED_COPY_ASSIGNMENT(anim_atlas); |