summaryrefslogtreecommitdiffstats
path: root/core/math/vector2.h
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-02-22 00:26:41 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-22 23:16:44 +0100
commit6da0eef9e6695e0da17953d80a1e6b0b673b4678 (patch)
tree1b08291b93a47f81c2a810f58996e1135777672a /core/math/vector2.h
parenta7891b9d120e1cb49bcdcffc1107f692ed481d86 (diff)
downloadredot-engine-6da0eef9e6695e0da17953d80a1e6b0b673b4678.tar.gz
Add support for Vector2i, Rect2i and Vector3i to Variant
WARNING: Requires C++17 'guaranteed copy elision' to fix ambiguous operator problems in Variant. This was added for this commit (and future C++17 uses) in #36457.
Diffstat (limited to 'core/math/vector2.h')
-rw-r--r--core/math/vector2.h7
1 files changed, 6 insertions, 1 deletions
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); }