diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-01 12:32:37 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-01 12:32:37 +0100 |
commit | 7ebee3863c061b1d0b64839b56bbc70ff4e5d924 (patch) | |
tree | ac0356bdcbf9f77864cb2cb2a6b5f2798c6fb3db /draw | |
parent | 078c376b6255fb6fd24362b27862819444327265 (diff) |
move scenery modify logic to scenery_ref
Diffstat (limited to 'draw')
-rw-r--r-- | draw/anim.cpp | 16 | ||||
-rw-r--r-- | draw/anim.hpp | 8 |
2 files changed, 12 insertions, 12 deletions
diff --git a/draw/anim.cpp b/draw/anim.cpp index 779c5a46..591d3801 100644 --- a/draw/anim.cpp +++ b/draw/anim.cpp @@ -27,21 +27,23 @@ std::array<UnsignedShort, 6> anim_mesh::make_index_array() void anim_mesh::add_clickable(tile_shader& shader, const Vector2i& win_size, chunk_coords c, std::uint8_t i, const std::shared_ptr<anim_atlas>& atlas, scenery& s, - std::vector<clickable_scenery>& clickable) + std::vector<clickable>& list) { const local_coords xy{i}; - const auto& g = atlas->group(s.r); - const auto& f = atlas->frame(s.r, s.frame); + const auto& a = *atlas; + const auto& g = a.group(s.r); + const auto& f = a.frame(s.r, s.frame); const auto world_pos = TILE_SIZE20 * Vector3(xy) + Vector3(g.offset) + Vector3(Vector2(s.offset), 0); const Vector2ui offset((Vector2(shader.camera_offset()) + Vector2(win_size)*.5f) + shader.project(world_pos) - Vector2(f.ground)); - clickable_scenery item = { - *atlas, s, + clickable item = { { f.offset, f.offset + f.size }, { offset, offset + f.size }, - atlas->bitmask(), tile_shader::depth_value(xy, tile_shader::scenery_depth_offset), c, xy, + a.bitmask(), tile_shader::depth_value(xy, tile_shader::scenery_depth_offset), + a.info().pixel_size[0], + c, xy, !g.mirror_from.isEmpty(), }; - clickable.push_back(item); + list.push_back(item); } void anim_mesh::draw(tile_shader& shader, chunk& c) diff --git a/draw/anim.hpp b/draw/anim.hpp index 1ce38d08..ccb03403 100644 --- a/draw/anim.hpp +++ b/draw/anim.hpp @@ -17,21 +17,19 @@ namespace floormat { struct tile_shader; struct anim_atlas; struct chunk; -template<typename Atlas, typename T> struct clickable; +struct clickable; struct scenery; struct anim_mesh final { - using clickable_scenery = clickable<anim_atlas, scenery>; - anim_mesh(); void draw(tile_shader& shader, chunk& c); void draw(tile_shader& shader, anim_atlas& atlas, rotation r, std::size_t frame, const Vector3& pos, float depth); void draw(tile_shader& shader, anim_atlas& atlas, rotation r, std::size_t frame, local_coords xy, Vector2b offset); static void add_clickable(tile_shader& shader, const Vector2i& win_size, - chunk_coords c, std::uint8_t i, const std::shared_ptr<anim_atlas>& atlas, scenery& s, - std::vector<clickable_scenery>& clickable); + chunk_coords c, std::uint8_t i, const std::shared_ptr<anim_atlas>& atlas, scenery& s, + std::vector<clickable>& list); private: struct vertex_data final { |