Browse Source

Merge pull request #688 from zhehangd/master

Rémi Verschelde 3 years ago
parent
commit
917b0c2ca3
3 changed files with 11 additions and 0 deletions
  1. 1 0
      include/godot_cpp/variant/vector2.hpp
  2. 5 0
      src/variant/vector2.cpp
  3. 5 0
      src/variant/vector3.cpp

+ 1 - 0
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) {

+ 5 - 0
src/variant/vector2.cpp

@@ -31,6 +31,7 @@
 #include <godot_cpp/core/error_macros.hpp>
 #include <godot_cpp/variant/string.hpp>
 #include <godot_cpp/variant/vector2.hpp>
+#include <godot_cpp/variant/vector2i.hpp>
 
 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);
 }

+ 5 - 0
src/variant/vector3.cpp

@@ -31,6 +31,7 @@
 #include <godot_cpp/core/error_macros.hpp>
 #include <godot_cpp/variant/basis.hpp>
 #include <godot_cpp/variant/vector3.hpp>
+#include <godot_cpp/variant/vector3i.hpp>
 
 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