From 554c776e08c9ee35fa9e2677e02f4005c11ddbc0 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 25 Feb 2021 09:54:50 -0500 Subject: Reformat structure string operators The order of numbers is not changed except for Transform2D. All logic is done inside of their structures (and not in Variant). For the number of decimals printed, they now use String::num_real which works best with real_t, except for Color which is fixed at 4 decimals (this is a reliable number of float digits when converting from 16-bpc so it seems like a good choice) --- core/math/vector2.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/math/vector2.cpp') diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index ea430b15c4..eb3301f5d0 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -193,6 +193,10 @@ bool Vector2::is_equal_approx(const Vector2 &p_v) const { return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y); } +Vector2::operator String() const { + return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ")"; +} + /* Vector2i */ Vector2i Vector2i::clamp(const Vector2i &p_min, const Vector2i &p_max) const { @@ -269,3 +273,7 @@ bool Vector2i::operator==(const Vector2i &p_vec2) const { bool Vector2i::operator!=(const Vector2i &p_vec2) const { return x != p_vec2.x || y != p_vec2.y; } + +Vector2i::operator String() const { + return "(" + itos(x) + ", " + itos(y) + ")"; +} -- cgit v1.2.3