diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-25 19:37:06 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-25 19:37:06 +0100 |
| commit | e46dd0f45d1cab35c7441d72f5dcac83720cc539 (patch) | |
| tree | 1611ed041680e6dcccb115cbc7c99e098b809d33 /src | |
| parent | 1831d5d1eab5c9a607270a8a9b72a2ac1e6ce62a (diff) | |
add scenery horizontal mirroring
Diffstat (limited to 'src')
| -rw-r--r-- | src/anim-atlas.cpp | 22 | ||||
| -rw-r--r-- | src/anim-atlas.hpp | 2 | ||||
| -rw-r--r-- | src/anim.hpp | 2 | ||||
| -rw-r--r-- | src/scenery.cpp | 4 |
4 files changed, 21 insertions, 9 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index 33b107df..e8d4bd9b 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -70,18 +70,26 @@ auto anim_atlas::frame(rotation r, std::size_t frame) const noexcept -> const an return g.frames[frame]; } -auto anim_atlas::texcoords_for_frame(rotation r, std::size_t i) const noexcept -> texcoords +auto anim_atlas::texcoords_for_frame(rotation r, std::size_t i, bool mirror) const noexcept -> texcoords { 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 {{ - { (x0+x1) / size[0], 1 - (y0+y1) / size[1] }, // bottom right - { (x0+x1) / size[0], 1 - y0 / size[1] }, // top right - { x0 / size[0], 1 - (y0+y1) / size[1] }, // bottom left - { x0 / size[0], 1 - y0 / size[1] }, // top left - }}; + if (!mirror) + return {{ + { (x0+x1) / size[0], 1 - (y0+y1) / size[1] }, // bottom right + { (x0+x1) / size[0], 1 - y0 / size[1] }, // top right + { x0 / size[0], 1 - (y0+y1) / size[1] }, // bottom left + { x0 / size[0], 1 - y0 / size[1] }, // top left + }}; + else + return {{ + { x0 / size[0], 1 - (y0+y1) / size[1] }, // bottom right + { x0 / size[0], 1 - y0 / size[1] }, // top right + { (x0+x1) / size[0], 1 - (y0+y1) / size[1] }, // bottom left + { (x0+x1) / size[0], 1 - y0 / size[1] }, // top left + }}; } auto anim_atlas::frame_quad(const Vector3& center, rotation r, std::size_t i) const noexcept -> quad diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp index 5b79ca19..b25ff489 100644 --- a/src/anim-atlas.hpp +++ b/src/anim-atlas.hpp @@ -30,7 +30,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(rotation r, std::size_t frame, bool mirror) const noexcept; quad frame_quad(const Vector3& center, rotation r, std::size_t frame) const noexcept; BitArrayView bitmask() const; diff --git a/src/anim.hpp b/src/anim.hpp index 1a4011dc..674895ed 100644 --- a/src/anim.hpp +++ b/src/anim.hpp @@ -22,7 +22,7 @@ enum class anim_direction : unsigned char struct anim_group final { - String name; + String name, mirror_from; std::vector<anim_frame> frames; Vector2ui ground; Vector3b offset; diff --git a/src/scenery.cpp b/src/scenery.cpp index 7c3001b0..eb90b598 100644 --- a/src/scenery.cpp +++ b/src/scenery.cpp @@ -56,6 +56,9 @@ scenery::scenery(float dt, frame_t frame, rotation r, bool passable, scenery_typ bool scenery::can_activate() const noexcept { +#if 0 + return true; +#else switch (type) { default: @@ -65,6 +68,7 @@ bool scenery::can_activate() const noexcept case scenery_type::object: return true; } +#endif } void scenery::update(float dt, const anim_atlas& anim) |
