summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-03-08 08:40:49 +0100
committerGitHub <noreply@github.com>2018-03-08 08:40:49 +0100
commit079b919b412188f6a5a6feb9b7808483baba9ace (patch)
treef0df5d325a9a19e81570be77b8836bee1f81cef2
parent0b600fde3fc3603be610b201257a5d03e0987fe4 (diff)
parentbd2e1df216435d07b3fa95cb47c1e83e9f56470b (diff)
Merge pull request #17341 from poke1024/fix16461
Fix unselectable flipped sprites (fixes 16461)
-rw-r--r--scene/2d/sprite.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 11447c382c..e3fa1fdcb7 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -281,11 +281,17 @@ bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
Rect2 src_rect, dst_rect;
bool filter_clip;
_get_rects(src_rect, dst_rect, filter_clip);
+ dst_rect.size = dst_rect.size.abs();
if (!dst_rect.has_point(p_point))
return false;
- Vector2 q = ((p_point - dst_rect.position) / dst_rect.size) * src_rect.size + src_rect.position;
+ Vector2 q = (p_point - dst_rect.position) / dst_rect.size;
+ if (hflip)
+ q.x = 1.0f - q.x;
+ if (vflip)
+ q.y = 1.0f - q.y;
+ q = q * src_rect.size + src_rect.position;
Ref<Image> image;
Ref<AtlasTexture> atlasTexture = texture;