diff --git a/include/godot_cpp/variant/vector2.hpp b/include/godot_cpp/variant/vector2.hpp index 05ba72f..72b45e3 100644 --- a/include/godot_cpp/variant/vector2.hpp +++ b/include/godot_cpp/variant/vector2.hpp @@ -153,6 +153,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 3cc9fda..7ba0910 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); } diff --git a/src/variant/vector3.cpp b/src/variant/vector3.cpp index 5c12c75..6cfb92a 100644 --- a/src/variant/vector3.cpp +++ b/src/variant/vector3.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace godot { @@ -121,4 +122,8 @@ Vector3::operator String() const { return (String::num(x, 5) + ", " + String::num(y, 5) + ", " + String::num(z, 5)); } +Vector3::operator Vector3i() const { + return Vector3i(x, y, z); +} + } // namespace godot