summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/variant/rect2i.hpp
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-05-07 12:55:23 -0500
committerGitHub <noreply@github.com>2024-05-07 12:55:23 -0500
commit43be24f34ccaba20faf05c76d724edb2a5339931 (patch)
treed7df360d17728f4667a4a47953cfddeac590b344 /include/godot_cpp/variant/rect2i.hpp
parent54fe2f9891525891a52c47ffbd190d15c38cccab (diff)
parentb65970860e2cb0b255528553392965b893cbb35f (diff)
downloadredot-cpp-43be24f34ccaba20faf05c76d724edb2a5339931.tar.gz
Merge pull request #1437 from AThousandShips/vec_elem_scalar
Add scalar versions of `Vector*` `min/max/clamp/snap(ped)`
Diffstat (limited to 'include/godot_cpp/variant/rect2i.hpp')
-rw-r--r--include/godot_cpp/variant/rect2i.hpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/include/godot_cpp/variant/rect2i.hpp b/include/godot_cpp/variant/rect2i.hpp
index c2a15ac..eff4958 100644
--- a/include/godot_cpp/variant/rect2i.hpp
+++ b/include/godot_cpp/variant/rect2i.hpp
@@ -97,14 +97,12 @@ struct _NO_DISCARD_ Rect2i {
return Rect2i();
}
- new_rect.position.x = Math::max(p_rect.position.x, position.x);
- new_rect.position.y = Math::max(p_rect.position.y, position.y);
+ new_rect.position = p_rect.position.max(position);
Point2i p_rect_end = p_rect.position + p_rect.size;
Point2i end = position + size;
- new_rect.size.x = Math::min(p_rect_end.x, end.x) - new_rect.position.x;
- new_rect.size.y = Math::min(p_rect_end.y, end.y) - new_rect.position.y;
+ new_rect.size = p_rect_end.min(end) - new_rect.position;
return new_rect;
}
@@ -117,11 +115,9 @@ struct _NO_DISCARD_ Rect2i {
#endif
Rect2i new_rect;
- new_rect.position.x = Math::min(p_rect.position.x, position.x);
- new_rect.position.y = Math::min(p_rect.position.y, position.y);
+ new_rect.position = p_rect.position.min(position);
- new_rect.size.x = Math::max(p_rect.position.x + p_rect.size.x, position.x + size.x);
- new_rect.size.y = Math::max(p_rect.position.y + p_rect.size.y, position.y + size.y);
+ new_rect.size = (p_rect.position + p_rect.size).max(position + size);
new_rect.size = new_rect.size - new_rect.position; // Make relative again.
@@ -219,7 +215,7 @@ struct _NO_DISCARD_ Rect2i {
}
_FORCE_INLINE_ Rect2i abs() const {
- return Rect2i(Point2i(position.x + Math::min(size.x, 0), position.y + Math::min(size.y, 0)), size.abs());
+ return Rect2i(position + size.mini(0), size.abs());
}
_FORCE_INLINE_ void set_end(const Vector2i &p_end) {