Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rect2::has_point() breaks with negative size fixed #38310

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions core/math/rect2.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ struct Rect2 {
return new_rect;
};
inline bool has_point(const Point2 &p_point) const {
if (p_point.x < position.x)

Rect2 abs_rect = abs();
if (p_point.x < abs_rect.position.x)
return false;
if (p_point.y < position.y)
if (p_point.y < abs_rect.position.y)
return false;

if (p_point.x >= (position.x + size.x))
if (p_point.x >= (abs_rect.position.x + abs_rect.size.x))
return false;
if (p_point.y >= (position.y + size.y))
if (p_point.y >= (abs_rect.position.y + abs_rect.size.y))
return false;

return true;
Expand Down