From df0e28fe43ae40efe13df1dacc8f2fc617cc1e4c Mon Sep 17 00:00:00 2001 From: Zhehang Ding Date: Mon, 7 Feb 2022 01:21:36 -0800 Subject: [PATCH] Add missing Vector2::operator Vector2i() --- include/godot_cpp/variant/vector2.hpp | 1 + src/variant/vector2.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/godot_cpp/variant/vector2.hpp b/include/godot_cpp/variant/vector2.hpp index f7ae8b06..56a2c958 100644 --- a/include/godot_cpp/variant/vector2.hpp +++ b/include/godot_cpp/variant/vector2.hpp @@ -151,6 +151,7 @@ public: real_t aspect() const { return width / height; } operator String() const; + operator Vector2i() const; inline Vector2() {} inline Vector2(real_t p_x, real_t p_y) { diff --git a/src/variant/vector2.cpp b/src/variant/vector2.cpp index 3cc9fda5..7ba09102 100644 --- a/src/variant/vector2.cpp +++ b/src/variant/vector2.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace godot { @@ -38,6 +39,10 @@ Vector2::operator String() const { return String::num(x, 5) + ", " + String::num(y, 5); } +Vector2::operator Vector2i() const { + return Vector2i(x, y); +} + real_t Vector2::angle() const { return Math::atan2(y, x); }