diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-22 18:46:52 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-22 18:46:52 +0100 |
commit | 51ebc370743b07926ce0a50232a1a65c6b6b27b5 (patch) | |
tree | 9c38ee65e32c6a760065ef33fe078847d7ea2d48 /main/draw.cpp | |
parent | a917bb7c28b383c3c684bf75732188bfff0060bb (diff) |
finally it works
Diffstat (limited to 'main/draw.cpp')
-rw-r--r-- | main/draw.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index 6b6c39a4..ba15b365 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -2,6 +2,8 @@ #include "floormat/app.hpp" #include "src/camera-offset.hpp" #include "src/anim-atlas.hpp" +#include "main/clickable.hpp" +#include <Corrade/Containers/ArrayView.h> #include <Magnum/GL/DefaultFramebuffer.h> #include <Magnum/GL/Renderer.h> #include <Magnum/Math/Color.h> @@ -111,17 +113,19 @@ void main_impl::draw_anim() noexcept const local_coords xy{i}; if (auto [atlas, s] = c[xy].scenery(); atlas) { + _anim_mesh.draw(_shader, *atlas, s.r, s.frame, xy); const auto& g = atlas->group(s.r); const auto& f = atlas->frame(s.r, s.frame); - const auto& mask = atlas->bitmask(); - Vector2 offset; constexpr Vector2 pixel88 = tile_shader::project(TILE_MAX_DIM*TILE_SIZE20*.5f); const auto world_pos = TILE_SIZE20 * Vector3(xy.x, xy.y, 0) + Vector3(g.offset); - offset += (Vector2(_shader.camera_offset()) + Vector2(sz))*.5f; - //offset += _shader.project(world_pos); - //offset -= Vector2(f.ground); - Debug{} << "offset" << offset.x() << offset.y(); - _anim_mesh.draw(_shader, *atlas, s.r, s.frame, xy); + const Vector2ui offset((Vector2(_shader.camera_offset()) + Vector2(sz) - pixel88)*.5f + + _shader.project(world_pos) - Vector2(f.ground)); + clickable<anim_atlas, scenery> item = { + *atlas, s, + { f.offset, f.offset + f.size }, { offset, offset + f.size }, + atlas->bitmask(), tile_shader::depth_value(xy, 0.25f), pos, xy + }; + _clickable_scenery.push_back(item); } } } @@ -217,4 +221,14 @@ void main_impl::drawEvent() timeline.nextFrame(); } +ArrayView<const clickable<anim_atlas, scenery>> main_impl::clickable_scenery() const noexcept +{ + return { _clickable_scenery.data(), _clickable_scenery.size() }; +} + +ArrayView<clickable<anim_atlas, scenery>> main_impl::clickable_scenery() noexcept +{ + return { _clickable_scenery.data(), _clickable_scenery.size() }; +} + } // namespace floormat |