summaryrefslogtreecommitdiffhomepage
path: root/editor/draw.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-01 13:17:50 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-01 13:17:50 +0100
commitd478c37fc03c7590823f003a3b326e79ae8012f9 (patch)
treed64f164bc4b5922324bd88bfe809d7dea2dde2ba /editor/draw.cpp
parent7ebee3863c061b1d0b64839b56bbc70ff4e5d924 (diff)
draw: skip clickables fully off the screen
Diffstat (limited to 'editor/draw.cpp')
-rw-r--r--editor/draw.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp
index 77d3f665..329603e0 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -144,23 +144,22 @@ void app::draw()
render_menu();
}
-clickable* app::find_clickable_scenery(const Optional<Vector2i>& pixel_)
+clickable* app::find_clickable_scenery(const Optional<Vector2i>& pixel)
{
- if (!pixel_ || _editor.mode() != editor_mode::none)
+ if (!pixel || _editor.mode() != editor_mode::none)
return nullptr;
- const auto pixel = Vector2ui(*pixel_);
clickable* item = nullptr;
float depth = -1;
const auto array = M->clickable_scenery();
for (clickable& c : array)
- if (c.depth > depth && c.dest.contains(pixel))
+ if (c.depth > depth && c.dest.contains(*pixel))
{
- const auto pos_ = pixel - c.dest.min() + c.src.min();
- 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());
+ const auto pos_ = *pixel - c.dest.min() + Vector2i(c.src.min());
+ const auto pos = !c.mirrored ? pos_ : Vector2i(int(c.src.sizeX()) - 1 - pos_[0], pos_[1]);
+ std::size_t idx = unsigned(pos.y()) * c.stride + unsigned(pos.x());
+ fm_assert(idx < c.bitmask.size());
if (c.bitmask[idx])
{
depth = c.depth;