From eed15d9a39d2cc3886bcd5025f70a230ad59d316 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 2 Apr 2023 06:09:21 +0200 Subject: a --- draw/anim.cpp | 1 + editor/imgui.cpp | 10 +++------- main/clickable.hpp | 1 + src/chunk-scenery.cpp | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/draw/anim.cpp b/draw/anim.cpp index e8aa4e3b..0d1f2827 100644 --- a/draw/anim.cpp +++ b/draw/anim.cpp @@ -46,6 +46,7 @@ void anim_mesh::add_clickable(tile_shader& shader, const Vector2i& win_size, .e = s_, .depth = s.ordinal(), .slope = data.slope, + .bb_min = data.bb_min, .bb_max = data.bb_max, .stride = a.info().pixel_size[0], .mirrored = !g.mirror_from.isEmpty(), }; diff --git a/editor/imgui.cpp b/editor/imgui.cpp index 73095134..5a173da7 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -115,22 +115,18 @@ void app::draw_clickables() ImDrawList& draw = *ImGui::GetForegroundDrawList(); const auto color = ImGui::ColorConvertFloat4ToU32({0, .8f, .8f, .95f}); constexpr float thickness = 2.5f; - const auto& shader = M->shader(); - const auto win_size = M->window_size(); for (const auto& x : M->clickable_scenery()) { auto dest = Math::Range2D(x.dest); - auto min = dest.min(), max = dest.max(); + auto min = dest.min(), max = dest.max(), center = dest.center(); draw.AddRect({ min.x(), min.y() }, { max.x(), max.y() }, color, 0, ImDrawFlags_None, thickness); if (x.slope != 0.f) { const auto& e = *x.e; - const auto bb_min_ = -tile_shader::project(Vector3(Vector2(e.bbox_size/2), 0)); - const auto bb_max_ = bb_min_ + tile_shader::project(Vector3(Vector2(e.bbox_size), 0)); - const auto bb_min = min + tile_shader::project(Vector3(bb_min_, 0)); - const auto bb_max = min + tile_shader::project(Vector3(bb_max_, 0)); + const auto bb_min = Vector2(min[0] + x.bb_min[0], min[1] + x.bb_min[1]); + const auto bb_max = Vector2(min[0] + x.bb_max[0], min[1] + x.bb_max[1]); draw.AddLine({ bb_min[0], bb_min[1] }, { bb_max[0], bb_max[1] }, color, thickness); } } diff --git a/main/clickable.hpp b/main/clickable.hpp index 7a192fb3..7de946a1 100644 --- a/main/clickable.hpp +++ b/main/clickable.hpp @@ -15,6 +15,7 @@ struct clickable final { BitArrayView bitmask; entity* e; float depth, slope; + Vector2s bb_min, bb_max; uint32_t stride; bool mirrored; }; diff --git a/src/chunk-scenery.cpp b/src/chunk-scenery.cpp index 7852088f..134a1e44 100644 --- a/src/chunk-scenery.cpp +++ b/src/chunk-scenery.cpp @@ -104,8 +104,8 @@ auto chunk::make_topo_sort_data(entity& e) -> topo_sort_data { data.slope = (bb_max[1]-bb_min[1])/bb_len; data.mode = topo_sort_data::mode_static; - data.bb_min = Vector2s(bb_min); - data.bb_max = Vector2s(bb_max); + data.bb_min = Vector2s(bb_min - px_start); + data.bb_max = Vector2s(bb_max - px_start); } break; } -- cgit v1.2.3