summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
Diffstat (limited to 'core/math')
-rw-r--r--core/math/rect2.h5
-rw-r--r--core/math/vector2.h7
2 files changed, 11 insertions, 1 deletions
diff --git a/core/math/rect2.h b/core/math/rect2.h
index 0d2e7eb6e5..e4ea615c22 100644
--- a/core/math/rect2.h
+++ b/core/math/rect2.h
@@ -387,6 +387,11 @@ struct Rect2i {
size = end - begin;
}
+ _FORCE_INLINE_ Rect2i abs() const {
+
+ return Rect2i(Point2i(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs());
+ }
+
operator String() const { return String(position) + ", " + String(size); }
operator Rect2() const { return Rect2(position, size); }
diff --git a/core/math/vector2.h b/core/math/vector2.h
index 1dec830821..ba5558102f 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -311,10 +311,15 @@ struct Vector2i {
bool operator<(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
bool operator>(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y > p_vec2.y) : (x > p_vec2.x); }
+ bool operator<=(const Vector2i &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); }
+ bool operator>=(const Vector2i &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); }
+
bool operator==(const Vector2i &p_vec2) const;
bool operator!=(const Vector2i &p_vec2) const;
- real_t get_aspect() const { return width / (real_t)height; }
+ real_t aspect() const { return width / (real_t)height; }
+ Vector2i sign() const { return Vector2i(SGN(x), SGN(y)); }
+ Vector2i abs() const { return Vector2i(ABS(x), ABS(y)); }
operator String() const { return String::num(x) + ", " + String::num(y); }