summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/gui/texture_button.cpp6
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp7
2 files changed, 10 insertions, 3 deletions
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index c165c5a545..19bef9fdf5 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -64,7 +64,9 @@ bool TextureButton::has_point(const Point2 &p_point) const {
Rect2 rect = Rect2();
Size2 mask_size = click_mask->get_size();
- if (_tile) {
+ if (_position_rect.no_area()) {
+ rect.size = mask_size;
+ } else if (_tile) {
// if the stretch mode is tile we offset the point to keep it inside the mask size
rect.size = mask_size;
if (_position_rect.has_point(point)) {
@@ -216,6 +218,8 @@ void TextureButton::_notification(int p_what) {
draw_texture_rect(texdraw, _position_rect, _tile);
else
draw_texture_rect_region(texdraw, _position_rect, _texture_region);
+ } else {
+ _position_rect = Rect2();
}
if (has_focus() && focused.is_valid()) {
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index aaa37615d5..56b87f620c 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -369,8 +369,11 @@ void RectangleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_suppor
}
bool RectangleShape2DSW::contains_point(const Vector2 &p_point) const {
-
- return Math::abs(p_point.x) < half_extents.x && Math::abs(p_point.y) < half_extents.y;
+ float x = p_point.x;
+ float y = p_point.y;
+ float edge_x = half_extents.x;
+ float edge_y = half_extents.y;
+ return (x >= -edge_x) && (x < edge_x) && (y >= -edge_y) && (y < edge_y);
}
bool RectangleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {