diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index d8ad63a93..924eea0be 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -32,6 +32,7 @@ #include "vector2.h" #include "core/string/ustring.h" +#include "vector2i.h" real_t Vector2::angle() const { return Math::atan2(y, x); @@ -173,4 +174,8 @@ bool Vector2::is_equal_approx(const Vector2 &p_v) const { Vector2::operator String() const { return "(" + String::num_real(x) + ", " + String::num_real(y) + ")"; -} \ No newline at end of file +} + +Vector2::operator Vector2i() const { + return Vector2i(x, y); +} diff --git a/core/math/vector2.h b/core/math/vector2.h index 903eb5591..cffa971fe 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -37,6 +37,7 @@ #include "core/error/error_macros.h" class String; +struct Vector2i; struct _NO_DISCARD_CLASS_ Vector2 { static const int AXIS_COUNT = 2; @@ -180,6 +181,7 @@ struct _NO_DISCARD_CLASS_ Vector2 { real_t aspect() const { return width / height; } operator String() const; + operator Vector2i() const; _FORCE_INLINE_ Vector2(real_t p_x, real_t p_y) { x = p_x; diff --git a/core/math/vector2i.h b/core/math/vector2i.h index 6393df50e..a45ce8684 100644 --- a/core/math/vector2i.h +++ b/core/math/vector2i.h @@ -129,10 +129,6 @@ struct _NO_DISCARD_CLASS_ Vector2i { operator String() const; operator Vector2() const { return Vector2(x, y); } - inline Vector2i(const Vector2 &p_vec2) { - x = (int)p_vec2.x; - y = (int)p_vec2.y; - } inline Vector2i(int p_x, int p_y) { x = p_x; y = p_y;