diff options
Diffstat (limited to 'src/scenery.cpp')
-rw-r--r-- | src/scenery.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/scenery.cpp b/src/scenery.cpp index ff78bfa8..873dcf93 100644 --- a/src/scenery.cpp +++ b/src/scenery.cpp @@ -3,6 +3,7 @@ #include "chunk.hpp" #include "compat/assert.hpp" #include "world.hpp" +#include "shaders/tile.hpp" #include "src/rotation.inl" #include <algorithm> @@ -89,16 +90,24 @@ Vector2 scenery::ordinal_offset(Vector2b offset) const Vector2 scenery::depth_offset() const { + constexpr auto sc_offset = tile_shader::scenery_depth_offset; constexpr auto inv_tile_size = 1.f/TILE_SIZE2; Vector2 ret; + ret += Vector2(atlas->group(r).depth_offset) * inv_tile_size; if (sc_type == scenery_type::door) { - constexpr auto door_offset = Vector2b(-bTILE_SIZE[0], 0); - const auto offset = rotate_point(door_offset, rotation::N, r); - ret += Vector2(offset); + const bool is_open = frame != atlas->info().nframes-1; + ret += Vector2(is_open ? sc_offset : -sc_offset, 0); + constexpr auto off_opened = Vector2(-1, 0); + constexpr auto off_closed = Vector2(0, 0); + const auto vec = is_open ? off_opened : off_closed; + const auto offset = rotate_point(vec, rotation::N, r); + ret += offset; } - ret += Vector2(atlas->group(r).depth_offset); - return ret * inv_tile_size; + else + ret += Vector2(sc_offset, 0); + + return ret; } bool scenery::activate(size_t) |