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 /editor/draw.cpp | |
| parent | 078c376b6255fb6fd24362b27862819444327265 (diff) | |
move scenery modify logic to scenery_ref
Diffstat (limited to 'editor/draw.cpp')
| -rw-r--r-- | editor/draw.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp index 41a5c713..77d3f665 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -144,25 +144,22 @@ void app::draw() render_menu(); } -clickable_scenery* app::find_clickable_scenery(const Optional<Vector2i>& pixel_) +clickable* app::find_clickable_scenery(const Optional<Vector2i>& pixel_) { if (!pixel_ || _editor.mode() != editor_mode::none) return nullptr; const auto pixel = Vector2ui(*pixel_); - clickable_scenery* item = nullptr; + clickable* item = nullptr; float depth = -1; const auto array = M->clickable_scenery(); - for (clickable_scenery& c : array) + for (clickable& c : array) if (c.depth > depth && c.dest.contains(pixel)) { const auto pos_ = pixel - c.dest.min() + c.src.min(); - const auto pos = c.atlas.group(c.item.r).mirror_from.isEmpty() - ? pos_ - : Vector2ui(c.src.sizeX() - 1 - pos_[0], pos_[1]); - const auto stride = c.atlas.info().pixel_size[0]; - std::size_t idx = pos.y() * stride + pos.x(); + const auto pos = !c.mirrored ? pos_ : Vector2ui(c.src.sizeX() - 1 - pos_[0], pos_[1]); + std::size_t idx = pos.y() * c.stride + pos.x(); fm_debug_assert(idx < c.bitmask.size()); if (c.bitmask[idx]) { |
