Removed Vector2i(Vector2) constructor, added a Vector2i conversion operator to Vector2 instead. This solves ambigous Variant to Vector2i conversion errors.

This commit is contained in:
Relintai 2024-03-07 18:56:55 +01:00
parent 2e45ffc5ea
commit 27b73fa9f9
3 changed files with 8 additions and 5 deletions

View File

@ -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) + ")";
}
}
Vector2::operator Vector2i() const {
return Vector2i(x, y);
}

View File

@ -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;

View File

@ -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;