summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/variant
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-02-20 11:47:57 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-02-20 12:04:08 +0100
commit7e3321d1b2fc9f81191f53ee427d44bed6a2d923 (patch)
tree7d2abe629e5ad7d6ab76d30a39b967e506d13a84 /include/godot_cpp/variant
parent917b0c2ca3e8363082d62acdc7dc73d77b1c68ec (diff)
downloadredot-cpp-7e3321d1b2fc9f81191f53ee427d44bed6a2d923.tar.gz
Use forward declares for vector math types
Adds operators to convert from int vector types to float vector types as done in the upstream engine implementations.
Diffstat (limited to 'include/godot_cpp/variant')
-rw-r--r--include/godot_cpp/variant/rect2.hpp3
-rw-r--r--include/godot_cpp/variant/rect2i.hpp15
-rw-r--r--include/godot_cpp/variant/vector2.hpp2
-rw-r--r--include/godot_cpp/variant/vector2i.hpp12
-rw-r--r--include/godot_cpp/variant/vector3.hpp3
-rw-r--r--include/godot_cpp/variant/vector3i.hpp5
6 files changed, 20 insertions, 20 deletions
diff --git a/include/godot_cpp/variant/rect2.hpp b/include/godot_cpp/variant/rect2.hpp
index f696bca..65e8005 100644
--- a/include/godot_cpp/variant/rect2.hpp
+++ b/include/godot_cpp/variant/rect2.hpp
@@ -37,6 +37,8 @@
namespace godot {
+class Rect2i;
+class String;
class Transform2D;
class Rect2 {
@@ -326,6 +328,7 @@ public:
}
operator String() const;
+ operator Rect2i() const;
Rect2() {}
Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) :
diff --git a/include/godot_cpp/variant/rect2i.hpp b/include/godot_cpp/variant/rect2i.hpp
index 9d82668..d1618c1 100644
--- a/include/godot_cpp/variant/rect2i.hpp
+++ b/include/godot_cpp/variant/rect2i.hpp
@@ -31,11 +31,15 @@
#ifndef GODOT_RECT2I_HPP
#define GODOT_RECT2I_HPP
-#include <godot_cpp/variant/rect2.hpp>
+#include <godot_cpp/classes/global_constants.hpp>
+#include <godot_cpp/core/math.hpp>
#include <godot_cpp/variant/vector2i.hpp>
namespace godot {
+class Rect2;
+class String;
+
class Rect2i {
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
@@ -206,15 +210,10 @@ public:
return position + size;
}
- operator String() const { return String(position) + ", " + String(size); }
-
- operator Rect2() const { return Rect2(position, size); }
+ operator String() const;
+ operator Rect2() const;
Rect2i() {}
- Rect2i(const Rect2 &p_r2) :
- position(p_r2.position),
- size(p_r2.size) {
- }
Rect2i(int p_x, int p_y, int p_width, int p_height) :
position(Point2i(p_x, p_y)),
size(Size2i(p_width, p_height)) {
diff --git a/include/godot_cpp/variant/vector2.hpp b/include/godot_cpp/variant/vector2.hpp
index 72b45e3..aba1da8 100644
--- a/include/godot_cpp/variant/vector2.hpp
+++ b/include/godot_cpp/variant/vector2.hpp
@@ -32,10 +32,10 @@
#define GODOT_VECTOR2_HPP
#include <godot_cpp/core/math.hpp>
-#include <godot_cpp/variant/string.hpp>
namespace godot {
+class String;
class Vector2i;
class Vector2 {
diff --git a/include/godot_cpp/variant/vector2i.hpp b/include/godot_cpp/variant/vector2i.hpp
index 69c6897..373bedf 100644
--- a/include/godot_cpp/variant/vector2i.hpp
+++ b/include/godot_cpp/variant/vector2i.hpp
@@ -32,11 +32,12 @@
#define GODOT_VECTOR2I_HPP
#include <godot_cpp/core/math.hpp>
-#include <godot_cpp/variant/string.hpp>
-#include <godot_cpp/variant/vector2.hpp>
namespace godot {
+class String;
+class Vector2;
+
class Vector2i {
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
@@ -96,14 +97,9 @@ public:
Vector2i abs() const { return Vector2i(Math::abs(x), Math::abs(y)); }
operator String() const;
-
- operator Vector2() const { return Vector2((real_t)x, (real_t)y); }
+ operator Vector2() const;
inline Vector2i() {}
- inline Vector2i(const Vector2 &p_vec2) {
- x = (int32_t)p_vec2.x;
- y = (int32_t)p_vec2.y;
- }
inline Vector2i(int32_t p_x, int32_t p_y) {
x = p_x;
y = p_y;
diff --git a/include/godot_cpp/variant/vector3.hpp b/include/godot_cpp/variant/vector3.hpp
index f34aa05..ca7ba29 100644
--- a/include/godot_cpp/variant/vector3.hpp
+++ b/include/godot_cpp/variant/vector3.hpp
@@ -32,11 +32,11 @@
#define GODOT_VECTOR3_HPP
#include <godot_cpp/core/math.hpp>
-#include <godot_cpp/variant/string.hpp>
namespace godot {
class Basis;
+class String;
class Vector3i;
class Vector3 {
@@ -159,7 +159,6 @@ public:
y = p_y;
z = p_z;
}
- Vector3(const Vector3i &p_ivec);
};
Vector3 Vector3::cross(const Vector3 &p_b) const {
diff --git a/include/godot_cpp/variant/vector3i.hpp b/include/godot_cpp/variant/vector3i.hpp
index 9aa0341..b1623b1 100644
--- a/include/godot_cpp/variant/vector3i.hpp
+++ b/include/godot_cpp/variant/vector3i.hpp
@@ -32,10 +32,12 @@
#define GODOT_VECTOR3I_HPP
#include <godot_cpp/core/math.hpp>
-#include <godot_cpp/variant/string.hpp>
namespace godot {
+class String;
+class Vector3;
+
class Vector3i {
_FORCE_INLINE_ GDNativeTypePtr _native_ptr() const { return (void *)this; }
@@ -107,6 +109,7 @@ public:
inline bool operator>=(const Vector3i &p_v) const;
operator String() const;
+ operator Vector3() const;
inline Vector3i() {}
inline Vector3i(int32_t p_x, int32_t p_y, int32_t p_z) {