From a4b364ea3f051e7a56e6e05e81066e34420fe7bc Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 20 Jan 2024 12:47:33 +0100 Subject: [PATCH] Fix building sfwl. --- .gitignore | 1 + compile_linux_sfwl.sh | 4 +- sfw/core/vector2i.h | 4 + sfwl/core/hashfuncs.h | 68 - sfwl/core/rect2i.cpp | 3 +- sfwl/core/rect2i.h | 18 +- sfwl/core/vector2i.h | 24 +- sfwl/core/version.h | 6 +- sfwl/object/variant.cpp | 1545 -------------------- sfwl/object/variant.h | 98 +- sfwl/object/variant_op.cpp | 2790 +----------------------------------- 11 files changed, 38 insertions(+), 4523 deletions(-) diff --git a/.gitignore b/.gitignore index 00db678..ee2fdb8 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ game game.exe game-vc.* vc140.pdb +sfwl_app diff --git a/compile_linux_sfwl.sh b/compile_linux_sfwl.sh index 71bada2..bd8a1dd 100755 --- a/compile_linux_sfwl.sh +++ b/compile_linux_sfwl.sh @@ -12,8 +12,8 @@ ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/safe_refcount.cpp -o sfwl/c ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/ustring.cpp -o sfwl/core/ustring.o ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/string_name.cpp -o sfwl/core/string_name.o -ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfwl/core/rect2i.cpp -o sfwl/core/rect2i.o -ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfwl/core/vector2i.cpp -o sfwl/core/vector2i.o +ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/rect2i.cpp -o sfwl/core/rect2i.o +ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/vector2i.cpp -o sfwl/core/vector2i.o ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/file_access.cpp -o sfwl/core/file_access.o ccache g++ -Wall -D_REENTRANT -g -Isfwl -c sfwl/core/dir_access.cpp -o sfwl/core/dir_access.o diff --git a/sfw/core/vector2i.h b/sfw/core/vector2i.h index 2a3e164..c2793bf 100644 --- a/sfw/core/vector2i.h +++ b/sfw/core/vector2i.h @@ -139,6 +139,10 @@ Vector2i Vector2i::linear_interpolate(const Vector2i &p_to, real_t p_weight) con return res; } +_FORCE_INLINE_ Vector2i operator*(int p_scalar, const Vector2i &p_vec) { + return p_vec * p_scalar; +} + typedef Vector2i Size2i; typedef Vector2i Point2i; diff --git a/sfwl/core/hashfuncs.h b/sfwl/core/hashfuncs.h index fd1fba7..096c1c9 100644 --- a/sfwl/core/hashfuncs.h +++ b/sfwl/core/hashfuncs.h @@ -9,17 +9,10 @@ /*************************************************************************/ //--STRIP -#include "core/aabb.h" #include "core/math_defs.h" #include "core/math_funcs.h" -#include "core/rect2.h" #include "core/rect2i.h" -#include "core/vector2.h" #include "core/vector2i.h" -#include "core/vector3.h" -#include "core/vector3i.h" -#include "core/vector4.h" -#include "core/vector4i.h" #include "core/string_name.h" #include "core/ustring.h" #include "core/typedefs.h" @@ -314,37 +307,6 @@ struct HashMapHasherDefault { h = hash_murmur3_one_32(p_vec.y, h); return hash_fmix32(h); } - static _FORCE_INLINE_ uint32_t hash(const Vector3i &p_vec) { - uint32_t h = hash_murmur3_one_32(p_vec.x); - h = hash_murmur3_one_32(p_vec.y, h); - h = hash_murmur3_one_32(p_vec.z, h); - return hash_fmix32(h); - } - static _FORCE_INLINE_ uint32_t hash(const Vector4i &p_vec) { - uint32_t h = hash_murmur3_one_32(p_vec.x); - h = hash_murmur3_one_32(p_vec.y, h); - h = hash_murmur3_one_32(p_vec.z, h); - h = hash_murmur3_one_32(p_vec.w, h); - return hash_fmix32(h); - } - static _FORCE_INLINE_ uint32_t hash(const Vector2 &p_vec) { - uint32_t h = hash_murmur3_one_real(p_vec.x); - h = hash_murmur3_one_real(p_vec.y, h); - return hash_fmix32(h); - } - static _FORCE_INLINE_ uint32_t hash(const Vector3 &p_vec) { - uint32_t h = hash_murmur3_one_real(p_vec.x); - h = hash_murmur3_one_real(p_vec.y, h); - h = hash_murmur3_one_real(p_vec.z, h); - return hash_fmix32(h); - } - static _FORCE_INLINE_ uint32_t hash(const Vector4 &p_vec) { - uint32_t h = hash_murmur3_one_real(p_vec.x); - h = hash_murmur3_one_real(p_vec.y, h); - h = hash_murmur3_one_real(p_vec.z, h); - h = hash_murmur3_one_real(p_vec.w, h); - return hash_fmix32(h); - } static _FORCE_INLINE_ uint32_t hash(const Rect2i &p_rect) { uint32_t h = hash_murmur3_one_32(p_rect.position.x); h = hash_murmur3_one_32(p_rect.position.y, h); @@ -352,22 +314,6 @@ struct HashMapHasherDefault { h = hash_murmur3_one_32(p_rect.size.y, h); return hash_fmix32(h); } - static _FORCE_INLINE_ uint32_t hash(const Rect2 &p_rect) { - uint32_t h = hash_murmur3_one_real(p_rect.position.x); - h = hash_murmur3_one_real(p_rect.position.y, h); - h = hash_murmur3_one_real(p_rect.size.x, h); - h = hash_murmur3_one_real(p_rect.size.y, h); - return hash_fmix32(h); - } - static _FORCE_INLINE_ uint32_t hash(const AABB &p_aabb) { - uint32_t h = hash_murmur3_one_real(p_aabb.position.x); - h = hash_murmur3_one_real(p_aabb.position.y, h); - h = hash_murmur3_one_real(p_aabb.position.z, h); - h = hash_murmur3_one_real(p_aabb.size.x, h); - h = hash_murmur3_one_real(p_aabb.size.y, h); - h = hash_murmur3_one_real(p_aabb.size.z, h); - return hash_fmix32(h); - } }; template @@ -391,20 +337,6 @@ struct HashMapComparatorDefault { } }; -template <> -struct HashMapComparatorDefault { - static bool compare(const Vector2 &p_lhs, const Vector2 &p_rhs) { - return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y))); - } -}; - -template <> -struct HashMapComparatorDefault { - static bool compare(const Vector3 &p_lhs, const Vector3 &p_rhs) { - return ((p_lhs.x == p_rhs.x) || (Math::is_nan(p_lhs.x) && Math::is_nan(p_rhs.x))) && ((p_lhs.y == p_rhs.y) || (Math::is_nan(p_lhs.y) && Math::is_nan(p_rhs.y))) && ((p_lhs.z == p_rhs.z) || (Math::is_nan(p_lhs.z) && Math::is_nan(p_rhs.z))); - } -}; - constexpr uint32_t HASH_TABLE_SIZE_MAX = 29; const uint32_t hash_table_size_primes[HASH_TABLE_SIZE_MAX] = { diff --git a/sfwl/core/rect2i.cpp b/sfwl/core/rect2i.cpp index 96f5b70..f100628 100644 --- a/sfwl/core/rect2i.cpp +++ b/sfwl/core/rect2i.cpp @@ -4,7 +4,8 @@ /*************************************************************************/ //--STRIP -#include "core/transform_2d.h" // Includes rect2.h but Rect2 needs Transform2D +#include "core/rect2i.h" +#include "core/ustring.h" //--STRIP Rect2i::operator String() const { diff --git a/sfwl/core/rect2i.h b/sfwl/core/rect2i.h index 46fae29..5a1d6ae 100644 --- a/sfwl/core/rect2i.h +++ b/sfwl/core/rect2i.h @@ -10,7 +10,6 @@ //--STRIP #include "core/vector2i.h" // also includes math_funcs and ustring -#include "core/rect2.h" //--STRIP struct _NO_DISCARD_CLASS_ Rect2i { @@ -64,8 +63,8 @@ struct _NO_DISCARD_CLASS_ Rect2i { new_rect.position.x = MAX(p_rect.position.x, position.x); new_rect.position.y = MAX(p_rect.position.y, position.y); - Point2 p_rect_end = p_rect.position + p_rect.size; - Point2 end = position + size; + Point2i p_rect_end = p_rect.position + p_rect.size; + Point2i end = position + size; new_rect.size.x = (int)(MIN(p_rect_end.x, end.x) - new_rect.position.x); new_rect.size.y = (int)(MIN(p_rect_end.y, end.y) - new_rect.position.y); @@ -213,21 +212,14 @@ struct _NO_DISCARD_CLASS_ Rect2i { return position + size; } - Rect2 to_rect2() const { return Rect2(position, size); } - operator String() const; - operator Rect2() const { return Rect2(position, size); } - Rect2i(const Rect2 &p_r2) : - position(p_r2.position), - size(p_r2.size) { - } Rect2i() {} Rect2i(int p_x, int p_y, int p_width, int p_height) : - position(Point2(p_x, p_y)), - size(Size2(p_width, p_height)) { + position(Point2i(p_x, p_y)), + size(Size2i(p_width, p_height)) { } - Rect2i(const Point2 &p_pos, const Size2 &p_size) : + Rect2i(const Point2i &p_pos, const Size2i &p_size) : position(p_pos), size(p_size) { } diff --git a/sfwl/core/vector2i.h b/sfwl/core/vector2i.h index 2a3e164..223d04e 100644 --- a/sfwl/core/vector2i.h +++ b/sfwl/core/vector2i.h @@ -11,8 +11,6 @@ //--STRIP #include "core/error_macros.h" #include "core/math_funcs.h" - -#include "core/vector2.h" //--STRIP class String; @@ -88,8 +86,8 @@ struct _NO_DISCARD_CLASS_ Vector2i { Vector2i operator-() const; bool operator<(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); } bool operator>(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y > p_vec2.y) : (x > p_vec2.x); } - bool operator<=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); } - bool operator>=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); } + bool operator<=(const Vector2i &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); } + bool operator>=(const Vector2i &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); } bool operator==(const Vector2i &p_vec2) const; bool operator!=(const Vector2i &p_vec2) const; @@ -102,14 +100,11 @@ struct _NO_DISCARD_CLASS_ Vector2i { Vector2i abs() const { return Vector2i(ABS(x), ABS(y)); } Vector2i clamp(const Vector2i &p_min, const Vector2i &p_max) const; - Vector2 to_vector2() const { return Vector2(x, y); } - 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(const Vector2i &p_vec2) { + x = p_vec2.x; + y = p_vec2.y; } inline Vector2i(int p_x, int p_y) { x = p_x; @@ -131,12 +126,13 @@ Vector2i Vector2i::linear_interpolate(const Vector2i &p_a, const Vector2i &p_b, } Vector2i Vector2i::linear_interpolate(const Vector2i &p_to, real_t p_weight) const { - Vector2 res = *this; + real_t res_x = x; + real_t res_y = y; - res.x += (p_weight * (p_to.x - x)); - res.y += (p_weight * (p_to.y - y)); + res_x += (p_weight * (p_to.x - x)); + res_y += (p_weight * (p_to.y - y)); - return res; + return Vector2i(res_x, res_y); } typedef Vector2i Size2i; diff --git a/sfwl/core/version.h b/sfwl/core/version.h index e1881dd..80b0ace 100644 --- a/sfwl/core/version.h +++ b/sfwl/core/version.h @@ -1,9 +1,9 @@ //--STRIP -#ifndef SFW_VERSION_H -#define SFW_VERSION_H +#ifndef SFWL_VERSION_H +#define SFWL_VERSION_H //--STRIP -#define SFW_VERSION 1 +#define SFWL_VERSION 1 //--STRIP #endif diff --git a/sfwl/object/variant.cpp b/sfwl/object/variant.cpp index 6a9c8a0..6893ea9 100644 --- a/sfwl/object/variant.cpp +++ b/sfwl/object/variant.cpp @@ -37,52 +37,12 @@ String Variant::get_type_name(Variant::Type p_type) { } break; // math types - case RECT2: { - return "Rect2"; - } break; case RECT2I: { return "Rect2i"; } break; - case VECTOR2: { - return "Vector2"; - } break; case VECTOR2I: { return "Vector2i"; } break; - case VECTOR3: { - return "Vector3"; - } break; - case VECTOR3I: { - return "Vector3i"; - } break; - case VECTOR4: { - return "Vector4"; - } break; - case VECTOR4I: { - return "Vector4i"; - } break; - - case PLANE: { - return "Plane"; - } break; - case QUATERNION: { - return "Quaternion"; - } break; - case AABB: { - return "AABB"; - } break; - case BASIS: { - return "Basis"; - } break; - case TRANSFORM: { - return "Transform"; - } break; - case TRANSFORM2D: { - return "Transform2D"; - } break; - case PROJECTION: { - return "Projection"; - } break; // misc types case COLOR: { @@ -114,24 +74,9 @@ String Variant::get_type_name(Variant::Type p_type) { case POOL_STRING_ARRAY: { return "PoolStringArray"; } break; - case POOL_VECTOR2_ARRAY: { - return "PoolVector2Array"; - } break; case POOL_VECTOR2I_ARRAY: { return "PoolVector2iArray"; } break; - case POOL_VECTOR3_ARRAY: { - return "PoolVector3Array"; - } break; - case POOL_VECTOR3I_ARRAY: { - return "PoolVector3iArray"; - } break; - case POOL_VECTOR4_ARRAY: { - return "PoolVector4Array"; - } break; - case POOL_VECTOR4I_ARRAY: { - return "PoolVector4iArray"; - } break; case POOL_COLOR_ARRAY: { return "PoolColorArray"; } break; @@ -199,25 +144,8 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { invalid_types = invalid; } break; - case RECT2: { - static const Type valid[] = { - RECT2I, - NIL - }; - - valid_types = valid; - } break; case RECT2I: { static const Type valid[] = { - RECT2, - NIL - }; - - valid_types = valid; - } break; - case VECTOR2: { - static const Type valid[] = { - VECTOR2I, NIL }; @@ -225,88 +153,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { } break; case VECTOR2I: { static const Type valid[] = { - VECTOR2, - NIL - }; - - valid_types = valid; - } break; - case VECTOR3: { - static const Type valid[] = { - VECTOR3I, - NIL - }; - - valid_types = valid; - } break; - case VECTOR3I: { - static const Type valid[] = { - VECTOR3, - NIL - }; - - valid_types = valid; - } break; - case VECTOR4: { - static const Type valid[] = { - VECTOR4I, - NIL - }; - - valid_types = valid; - } break; - case VECTOR4I: { - static const Type valid[] = { - VECTOR4, - NIL - }; - - valid_types = valid; - } break; - case PLANE: { - //can't - } break; - case QUATERNION: { - static const Type valid[] = { - BASIS, - NIL - }; - - valid_types = valid; - } break; - case AABB: { - //can't - } break; - case BASIS: { - static const Type valid[] = { - QUATERNION, - VECTOR3, - NIL - }; - - valid_types = valid; - } break; - case TRANSFORM: { - static const Type valid[] = { - TRANSFORM2D, - QUATERNION, - BASIS, - NIL - }; - - valid_types = valid; - } break; - case TRANSFORM2D: { - static const Type valid[] = { - TRANSFORM, - NIL - }; - - valid_types = valid; - } break; - case PROJECTION: { - static const Type valid[] = { - TRANSFORM, NIL }; @@ -347,10 +193,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { POOL_STRING_ARRAY, POOL_REAL_ARRAY, POOL_COLOR_ARRAY, - POOL_VECTOR2_ARRAY, POOL_VECTOR2I_ARRAY, - POOL_VECTOR3_ARRAY, - POOL_VECTOR3I_ARRAY, NIL }; @@ -387,13 +230,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { }; valid_types = valid; } break; - case POOL_VECTOR2_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - valid_types = valid; - } break; case POOL_VECTOR2I_ARRAY: { static const Type valid[] = { ARRAY, @@ -401,34 +237,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { }; valid_types = valid; } break; - case POOL_VECTOR3_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - valid_types = valid; - } break; - case POOL_VECTOR3I_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - valid_types = valid; - } break; - case POOL_VECTOR4_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - valid_types = valid; - } break; - case POOL_VECTOR4I_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - valid_types = valid; - } break; case POOL_COLOR_ARRAY: { static const Type valid[] = { ARRAY, @@ -523,25 +331,8 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; - case RECT2: { - static const Type valid[] = { - RECT2I, - NIL - }; - - valid_types = valid; - } break; case RECT2I: { static const Type valid[] = { - RECT2, - NIL - }; - - valid_types = valid; - } break; - case VECTOR2: { - static const Type valid[] = { - VECTOR2I, NIL }; @@ -549,88 +340,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type } break; case VECTOR2I: { static const Type valid[] = { - VECTOR2, - NIL - }; - - valid_types = valid; - } break; - case VECTOR3: { - static const Type valid[] = { - VECTOR3I, - NIL - }; - - valid_types = valid; - } break; - case VECTOR3I: { - static const Type valid[] = { - VECTOR3, - NIL - }; - - valid_types = valid; - } break; - case VECTOR4: { - static const Type valid[] = { - VECTOR4I, - NIL - }; - - valid_types = valid; - } break; - case VECTOR4I: { - static const Type valid[] = { - VECTOR4, - NIL - }; - - valid_types = valid; - } break; - case PLANE: { - //Can't - } break; - case QUATERNION: { - static const Type valid[] = { - BASIS, - NIL - }; - - valid_types = valid; - } break; - case AABB: { - //Can't - } break; - case BASIS: { - static const Type valid[] = { - QUATERNION, - VECTOR3, - NIL - }; - - valid_types = valid; - } break; - case TRANSFORM: { - static const Type valid[] = { - TRANSFORM2D, - QUATERNION, - BASIS, - NIL - }; - - valid_types = valid; - } break; - case TRANSFORM2D: { - static const Type valid[] = { - TRANSFORM, - NIL - }; - - valid_types = valid; - } break; - case PROJECTION: { - static const Type valid[] = { - TRANSFORM, NIL }; @@ -670,12 +379,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type POOL_STRING_ARRAY, POOL_REAL_ARRAY, POOL_COLOR_ARRAY, - POOL_VECTOR2_ARRAY, POOL_VECTOR2I_ARRAY, - POOL_VECTOR3_ARRAY, - POOL_VECTOR3I_ARRAY, - POOL_VECTOR4_ARRAY, - POOL_VECTOR4I_ARRAY, NIL }; @@ -713,14 +417,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; - case POOL_VECTOR2_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - - valid_types = valid; - } break; case POOL_VECTOR2I_ARRAY: { static const Type valid[] = { ARRAY, @@ -729,38 +425,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; - case POOL_VECTOR3_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - - valid_types = valid; - } break; - case POOL_VECTOR3I_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - - valid_types = valid; - } break; - case POOL_VECTOR4_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - - valid_types = valid; - } break; - case POOL_VECTOR4I_ARRAY: { - static const Type valid[] = { - ARRAY, - NIL - }; - - valid_types = valid; - } break; case POOL_COLOR_ARRAY: { static const Type valid[] = { ARRAY, @@ -868,52 +532,12 @@ bool Variant::is_zero() const { } break; // math types - case RECT2: { - return *reinterpret_cast(_data._mem) == Rect2(); - } break; case RECT2I: { return *reinterpret_cast(_data._mem) == Rect2i(); } break; - case VECTOR2: { - return *reinterpret_cast(_data._mem) == Vector2(); - } break; case VECTOR2I: { return *reinterpret_cast(_data._mem) == Vector2i(); } break; - case VECTOR3: { - return *reinterpret_cast(_data._mem) == Vector3(); - } break; - case VECTOR3I: { - return *reinterpret_cast(_data._mem) == Vector3i(); - } break; - case VECTOR4: { - return *reinterpret_cast(_data._mem) == Vector4(); - } break; - case VECTOR4I: { - return *reinterpret_cast(_data._mem) == Vector4i(); - } break; - - case PLANE: { - return *reinterpret_cast(_data._mem) == Plane(); - } break; - case QUATERNION: { - return *reinterpret_cast(_data._mem) == Quaternion(); - } break; - case AABB: { - return *_data._aabb == ::AABB(); - } break; - case BASIS: { - return *_data._basis == Basis(); - } break; - case TRANSFORM: { - return *_data._transform == Transform(); - } break; - case TRANSFORM2D: { - return *_data._transform2d == Transform2D(); - } break; - case PROJECTION: { - return *_data._projection == Projection(); - } break; // misc types case COLOR: { @@ -945,24 +569,9 @@ bool Variant::is_zero() const { case POOL_STRING_ARRAY: { return reinterpret_cast *>(_data._mem)->size() == 0; } break; - case POOL_VECTOR2_ARRAY: { - return reinterpret_cast *>(_data._mem)->size() == 0; - } break; case POOL_VECTOR2I_ARRAY: { return reinterpret_cast *>(_data._mem)->size() == 0; } break; - case POOL_VECTOR3_ARRAY: { - return reinterpret_cast *>(_data._mem)->size() == 0; - } break; - case POOL_VECTOR3I_ARRAY: { - return reinterpret_cast *>(_data._mem)->size() == 0; - } break; - case POOL_VECTOR4_ARRAY: { - return reinterpret_cast *>(_data._mem)->size() == 0; - } break; - case POOL_VECTOR4I_ARRAY: { - return reinterpret_cast *>(_data._mem)->size() == 0; - } break; case POOL_COLOR_ARRAY: { return reinterpret_cast *>(_data._mem)->size() == 0; } break; @@ -989,33 +598,12 @@ bool Variant::is_one() const { case REAL: { return _data._real == 1; } break; - case RECT2: { - return *reinterpret_cast(_data._mem) == Rect2(1, 1, 1, 1); - } break; case RECT2I: { return *reinterpret_cast(_data._mem) == Rect2i(1, 1, 1, 1); } break; - case VECTOR2: { - return *reinterpret_cast(_data._mem) == Vector2(1, 1); - } break; case VECTOR2I: { return *reinterpret_cast(_data._mem) == Vector2i(1, 1); } break; - case VECTOR3: { - return *reinterpret_cast(_data._mem) == Vector3(1, 1, 1); - } break; - case VECTOR3I: { - return *reinterpret_cast(_data._mem) == Vector3i(1, 1, 1); - } break; - case VECTOR4: { - return *reinterpret_cast(_data._mem) == Vector4(1, 1, 1, 1); - } break; - case VECTOR4I: { - return *reinterpret_cast(_data._mem) == Vector4i(1, 1, 1, 1); - } break; - case PLANE: { - return *reinterpret_cast(_data._mem) == Plane(1, 1, 1, 1); - } break; case COLOR: { return *reinterpret_cast(_data._mem) == Color(1, 1, 1, 1); } break; @@ -1077,52 +665,12 @@ void Variant::reference(const Variant &p_variant) { } break; // math types - case RECT2: { - memnew_placement(_data._mem, Rect2(*reinterpret_cast(p_variant._data._mem))); - } break; case RECT2I: { memnew_placement(_data._mem, Rect2i(*reinterpret_cast(p_variant._data._mem))); } break; - case VECTOR2: { - memnew_placement(_data._mem, Vector2(*reinterpret_cast(p_variant._data._mem))); - } break; case VECTOR2I: { memnew_placement(_data._mem, Vector2i(*reinterpret_cast(p_variant._data._mem))); } break; - case VECTOR3: { - memnew_placement(_data._mem, Vector3(*reinterpret_cast(p_variant._data._mem))); - } break; - case VECTOR3I: { - memnew_placement(_data._mem, Vector3i(*reinterpret_cast(p_variant._data._mem))); - } break; - case VECTOR4: { - memnew_placement(_data._mem, Vector4(*reinterpret_cast(p_variant._data._mem))); - } break; - case VECTOR4I: { - memnew_placement(_data._mem, Vector4i(*reinterpret_cast(p_variant._data._mem))); - } break; - - case PLANE: { - memnew_placement(_data._mem, Plane(*reinterpret_cast(p_variant._data._mem))); - } break; - case QUATERNION: { - memnew_placement(_data._mem, Quaternion(*reinterpret_cast(p_variant._data._mem))); - } break; - case AABB: { - _data._aabb = memnew(::AABB(*p_variant._data._aabb)); - } break; - case BASIS: { - _data._basis = memnew(Basis(*p_variant._data._basis)); - } break; - case TRANSFORM: { - _data._transform = memnew(Transform(*p_variant._data._transform)); - } break; - case TRANSFORM2D: { - _data._transform2d = memnew(Transform2D(*p_variant._data._transform2d)); - } break; - case PROJECTION: { - _data._projection = memnew(Projection(*p_variant._data._projection)); - } break; // misc types case COLOR: { @@ -1157,24 +705,9 @@ void Variant::reference(const Variant &p_variant) { case POOL_STRING_ARRAY: { memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); } break; - case POOL_VECTOR2_ARRAY: { - memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); - } break; case POOL_VECTOR2I_ARRAY: { memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); } break; - case POOL_VECTOR3_ARRAY: { - memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); - } break; - case POOL_VECTOR3I_ARRAY: { - memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); - } break; - case POOL_VECTOR4_ARRAY: { - memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); - } break; - case POOL_VECTOR4I_ARRAY: { - memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); - } break; case POOL_COLOR_ARRAY: { memnew_placement(_data._mem, PoolVector(*reinterpret_cast *>(p_variant._data._mem))); } break; @@ -1196,45 +729,15 @@ void Variant::zero() { case REAL: this->_data._real = 0; break; - case RECT2: - *reinterpret_cast(this->_data._mem) = Rect2(); - break; case RECT2I: *reinterpret_cast(this->_data._mem) = Rect2i(); break; - case VECTOR2: - *reinterpret_cast(this->_data._mem) = Vector2(); - break; case VECTOR2I: *reinterpret_cast(this->_data._mem) = Vector2i(); break; - case VECTOR3: - *reinterpret_cast(this->_data._mem) = Vector3(); - break; - case VECTOR3I: - *reinterpret_cast(this->_data._mem) = Vector3i(); - break; - case VECTOR4: - *reinterpret_cast(this->_data._mem) = Vector4(); - break; - case VECTOR4I: - *reinterpret_cast(this->_data._mem) = Vector4i(); - break; - case PLANE: - *reinterpret_cast(this->_data._mem) = Plane(); - break; - case QUATERNION: - *reinterpret_cast(this->_data._mem) = Quaternion(); - break; - case AABB: - *reinterpret_cast<::AABB *>(this->_data._mem) = ::AABB(); - break; case COLOR: *reinterpret_cast(this->_data._mem) = Color(); break; - case PROJECTION: - *reinterpret_cast(this->_data._mem) = Projection(); - break; default: this->clear(); break; @@ -1265,21 +768,6 @@ void Variant::clear() { PLANE, QUATERNION, */ - case AABB: { - memdelete(_data._aabb); - } break; - case BASIS: { - memdelete(_data._basis); - } break; - case TRANSFORM: { - memdelete(_data._transform); - } break; - case TRANSFORM2D: { - memdelete(_data._transform2d); - } break; - case PROJECTION: { - memdelete(_data._projection); - } break; //COLOR // misc types @@ -1315,24 +803,9 @@ void Variant::clear() { case POOL_STRING_ARRAY: { reinterpret_cast *>(_data._mem)->~PoolVector(); } break; - case POOL_VECTOR2_ARRAY: { - reinterpret_cast *>(_data._mem)->~PoolVector(); - } break; case POOL_VECTOR2I_ARRAY: { reinterpret_cast *>(_data._mem)->~PoolVector(); } break; - case POOL_VECTOR3_ARRAY: { - reinterpret_cast *>(_data._mem)->~PoolVector(); - } break; - case POOL_VECTOR3I_ARRAY: { - reinterpret_cast *>(_data._mem)->~PoolVector(); - } break; - case POOL_VECTOR4_ARRAY: { - reinterpret_cast *>(_data._mem)->~PoolVector(); - } break; - case POOL_VECTOR4I_ARRAY: { - reinterpret_cast *>(_data._mem)->~PoolVector(); - } break; case POOL_COLOR_ARRAY: { reinterpret_cast *>(_data._mem)->~PoolVector(); } break; @@ -1632,38 +1105,10 @@ String Variant::stringify(List &stack) const { return rtos(_data._real); case STRING: return *reinterpret_cast(_data._mem); - case RECT2: - return operator Rect2(); case RECT2I: return operator Rect2i(); - case VECTOR2: - return operator Vector2(); case VECTOR2I: return operator Vector2i(); - case VECTOR3: - return operator Vector3(); - case VECTOR3I: - return operator Vector3i(); - case VECTOR4: - return operator Vector4(); - case VECTOR4I: - return operator Vector4i(); - case PLANE: - return operator Plane(); - case QUATERNION: - return operator Quaternion(); - case AABB: - return operator ::AABB(); - case BASIS: { - return operator Basis(); - } break; - case TRANSFORM: - return operator Transform(); - case TRANSFORM2D: { - return operator Transform2D(); - } break; - case PROJECTION: - return operator Projection(); case COLOR: return operator Color(); case OBJECT: { @@ -1739,24 +1184,9 @@ String Variant::stringify(List &stack) const { case POOL_STRING_ARRAY: { return stringify_vector(operator PoolVector(), stack); } break; - case POOL_VECTOR2_ARRAY: { - return stringify_vector(operator PoolVector(), stack); - } break; case POOL_VECTOR2I_ARRAY: { return stringify_vector(operator PoolVector(), stack); } break; - case POOL_VECTOR3_ARRAY: { - return stringify_vector(operator PoolVector(), stack); - } break; - case POOL_VECTOR3I_ARRAY: { - return stringify_vector(operator PoolVector(), stack); - } break; - case POOL_VECTOR4_ARRAY: { - return stringify_vector(operator PoolVector(), stack); - } break; - case POOL_VECTOR4I_ARRAY: { - return stringify_vector(operator PoolVector(), stack); - } break; case POOL_COLOR_ARRAY: { return stringify_vector(operator PoolVector(), stack); } break; @@ -1769,239 +1199,22 @@ String Variant::stringify(List &stack) const { return ""; } -Variant::operator Rect2() const { - if (type == RECT2) { - return *reinterpret_cast(_data._mem); - } else if (type == RECT2I) { - return Rect2(*reinterpret_cast(_data._mem)); - } else { - return Rect2(); - } -} Variant::operator Rect2i() const { if (type == RECT2I) { return *reinterpret_cast(_data._mem); - } else if (type == RECT2) { - return Rect2i(*reinterpret_cast(_data._mem)); } else { return Rect2i(); } } -Variant::operator Vector2() const { - if (type == VECTOR2) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR2I) { - return Vector2(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR3) { - return Vector2(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR3I) { - return Vector2(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR4) { - return Vector2(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR4I) { - return Vector2(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else { - return Vector2(); - } -} Variant::operator Vector2i() const { if (type == VECTOR2I) { return *reinterpret_cast(_data._mem); - } else if (type == VECTOR2) { - return Vector2i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR3) { - return Vector2i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR3I) { - return Vector2i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR4) { - return Vector2i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); - } else if (type == VECTOR4I) { - return Vector2i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y); } else { return Vector2i(); } } -Variant::operator Vector3() const { - if (type == VECTOR3) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR3I) { - return Vector3(*reinterpret_cast(_data._mem)); - } else if (type == VECTOR2) { - return Vector3(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0); - } else if (type == VECTOR2I) { - return Vector3(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0); - } else if (type == VECTOR4) { - return Vector3(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z); - } else if (type == VECTOR4I) { - return Vector3(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z); - } else { - return Vector3(); - } -} -Variant::operator Vector3i() const { - if (type == VECTOR3I) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR3) { - return Vector3i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z); - } else if (type == VECTOR2) { - return Vector3i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0); - } else if (type == VECTOR2I) { - return Vector3i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0); - } else if (type == VECTOR4) { - return Vector3i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z); - } else if (type == VECTOR4I) { - return Vector3i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z); - } else { - return Vector3i(); - } -} - -Variant::operator Vector4() const { - if (type == VECTOR4) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR4I) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR2) { - return Vector4(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0, 0.0); - } else if (type == VECTOR2I) { - return Vector4(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0, 0.0); - } else if (type == VECTOR3) { - return Vector4(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z, 0.0); - } else if (type == VECTOR3I) { - return Vector4(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z, 0.0); - } else { - return Vector4(); - } -} - -Variant::operator Vector4i() const { - if (type == VECTOR4I) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR4) { - const Vector4 &v4 = *reinterpret_cast(_data._mem); - return Vector4i(v4.x, v4.y, v4.z, v4.w); - } else if (type == VECTOR2) { - return Vector4i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0, 0.0); - } else if (type == VECTOR2I) { - return Vector4i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, 0.0, 0.0); - } else if (type == VECTOR3) { - return Vector4i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z, 0.0); - } else if (type == VECTOR3I) { - return Vector4i(reinterpret_cast(_data._mem)->x, reinterpret_cast(_data._mem)->y, reinterpret_cast(_data._mem)->z, 0.0); - } else { - return Vector4i(); - } -} - -Variant::operator Plane() const { - if (type == PLANE) { - return *reinterpret_cast(_data._mem); - } else { - return Plane(); - } -} -Variant::operator ::AABB() const { - if (type == AABB) { - return *_data._aabb; - } else { - return ::AABB(); - } -} - -Variant::operator Basis() const { - if (type == BASIS) { - return *_data._basis; - } else if (type == QUATERNION) { - return *reinterpret_cast(_data._mem); - } else if (type == VECTOR3) { - return Basis(*reinterpret_cast(_data._mem)); - } else if (type == TRANSFORM) { // unexposed in Variant::can_convert? - return _data._transform->basis; - } else { - return Basis(); - } -} - -Variant::operator Quaternion() const { - if (type == QUATERNION) { - return *reinterpret_cast(_data._mem); - } else if (type == BASIS) { - return *_data._basis; - } else if (type == TRANSFORM) { - return _data._transform->basis; - } else { - return Quaternion(); - } -} - -Variant::operator Transform2D() const { - if (type == TRANSFORM2D) { - return *_data._transform2d; - } else if (type == TRANSFORM) { - const Transform &t = *_data._transform; - Transform2D m; - m.columns[0][0] = t.basis.rows[0][0]; - m.columns[0][1] = t.basis.rows[1][0]; - m.columns[1][0] = t.basis.rows[0][1]; - m.columns[1][1] = t.basis.rows[1][1]; - m.columns[2][0] = t.origin[0]; - m.columns[2][1] = t.origin[1]; - return m; - } else { - return Transform2D(); - } -} - -Variant::operator Transform() const { - if (type == TRANSFORM) { - return *_data._transform; - } else if (type == BASIS) { - return Transform(*_data._basis, Vector3()); - } else if (type == QUATERNION) { - return Transform(Basis(*reinterpret_cast(_data._mem)), Vector3()); - } else if (type == TRANSFORM2D) { - const Transform2D &t = *_data._transform2d; - Transform m; - m.basis.rows[0][0] = t.columns[0][0]; - m.basis.rows[1][0] = t.columns[0][1]; - m.basis.rows[0][1] = t.columns[1][0]; - m.basis.rows[1][1] = t.columns[1][1]; - m.origin[0] = t.columns[2][0]; - m.origin[1] = t.columns[2][1]; - return m; - } else if (type == PROJECTION) { - return *_data._projection; - } else { - return Transform(); - } -} - -Variant::operator Projection() const { - if (type == TRANSFORM) { - return *_data._transform; - } else if (type == BASIS) { - return Transform(*_data._basis, Vector3()); - } else if (type == QUATERNION) { - return Transform(Basis(*reinterpret_cast(_data._mem)), Vector3()); - } else if (type == TRANSFORM2D) { - const Transform2D &t = *_data._transform2d; - Transform m; - m.basis.rows[0][0] = t.columns[0][0]; - m.basis.rows[1][0] = t.columns[0][1]; - m.basis.rows[0][1] = t.columns[1][0]; - m.basis.rows[1][1] = t.columns[1][1]; - m.origin[0] = t.columns[2][0]; - m.origin[1] = t.columns[2][1]; - return m; - } else if (type == PROJECTION) { - return *_data._projection; - } else { - return Projection(); - } -} - Variant::operator Color() const { if (type == COLOR) { return *reinterpret_cast(_data._mem); @@ -2060,24 +1273,9 @@ inline DA _convert_array_from_variant(const Variant &p_variant) { case Variant::POOL_STRING_ARRAY: { return _convert_array>(p_variant.operator PoolVector()); } - case Variant::POOL_VECTOR2_ARRAY: { - return _convert_array>(p_variant.operator PoolVector()); - } case Variant::POOL_VECTOR2I_ARRAY: { return _convert_array>(p_variant.operator PoolVector()); } - case Variant::POOL_VECTOR3_ARRAY: { - return _convert_array>(p_variant.operator PoolVector()); - } - case Variant::POOL_VECTOR3I_ARRAY: { - return _convert_array>(p_variant.operator PoolVector()); - } - case Variant::POOL_VECTOR4_ARRAY: { - return _convert_array>(p_variant.operator PoolVector()); - } - case Variant::POOL_VECTOR4I_ARRAY: { - return _convert_array>(p_variant.operator PoolVector()); - } case Variant::POOL_COLOR_ARRAY: { return _convert_array>(p_variant.operator PoolVector()); } @@ -2133,13 +1331,6 @@ Variant::operator PoolVector() const { return _convert_array_from_variant>(*this); } } -Variant::operator PoolVector() const { - if (type == POOL_VECTOR2_ARRAY) { - return *reinterpret_cast *>(_data._mem); - } else { - return _convert_array_from_variant>(*this); - } -} Variant::operator PoolVector() const { if (type == POOL_VECTOR2I_ARRAY) { return *reinterpret_cast *>(_data._mem); @@ -2147,34 +1338,6 @@ Variant::operator PoolVector() const { return _convert_array_from_variant>(*this); } } -Variant::operator PoolVector() const { - if (type == POOL_VECTOR3_ARRAY) { - return *reinterpret_cast *>(_data._mem); - } else { - return _convert_array_from_variant>(*this); - } -} -Variant::operator PoolVector() const { - if (type == POOL_VECTOR3I_ARRAY) { - return *reinterpret_cast *>(_data._mem); - } else { - return _convert_array_from_variant>(*this); - } -} -Variant::operator PoolVector() const { - if (type == POOL_VECTOR4_ARRAY) { - return *reinterpret_cast *>(_data._mem); - } else { - return _convert_array_from_variant>(*this); - } -} -Variant::operator PoolVector() const { - if (type == POOL_VECTOR4I_ARRAY) { - return *reinterpret_cast *>(_data._mem); - } else { - return _convert_array_from_variant>(*this); - } -} Variant::operator PoolVector() const { if (type == POOL_COLOR_ARRAY) { return *reinterpret_cast *>(_data._mem); @@ -2185,60 +1348,6 @@ Variant::operator PoolVector() const { /* helpers */ -Variant::operator PoolVector() const { - Array va = operator Array(); - PoolVector planes; - int va_size = va.size(); - if (va_size == 0) { - return planes; - } - - planes.resize(va_size); - PoolVector::Write w = planes.write(); - - for (int i = 0; i < va_size; i++) { - w[i] = va[i]; - } - - return planes; -} - -Variant::operator PoolVector() const { - PoolVector va = operator PoolVector(); - PoolVector faces; - int va_size = va.size(); - if (va_size == 0) { - return faces; - } - - faces.resize(va_size / 3); - PoolVector::Write w = faces.write(); - PoolVector::Read r = va.read(); - - for (int i = 0; i < va_size; i++) { - w[i / 3].vertex[i % 3] = r[i]; - } - - return faces; -} - -Variant::operator Vector() const { - Array va = operator Array(); - Vector planes; - int va_size = va.size(); - if (va_size == 0) { - return planes; - } - - planes.resize(va_size); - - for (int i = 0; i < va_size; i++) { - planes.write[i] = va[i]; - } - - return planes; -} - Variant::operator Vector() const { Array from = operator Array(); Vector to; @@ -2302,21 +1411,6 @@ Variant::operator Vector() const { return to; } -Variant::operator Vector() const { - PoolVector from = operator PoolVector(); - Vector to; - int len = from.size(); - if (len == 0) { - return Vector(); - } - to.resize(len); - PoolVector::Read r = from.read(); - Vector2 *w = to.ptrw(); - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - return to; -} Variant::operator Vector() const { PoolVector from = operator PoolVector(); Vector to; @@ -2333,68 +1427,6 @@ Variant::operator Vector() const { return to; } -Variant::operator Vector() const { - PoolVector from = operator PoolVector(); - Vector to; - int len = from.size(); - if (len == 0) { - return Vector(); - } - to.resize(len); - PoolVector::Read r = from.read(); - Vector3 *w = to.ptrw(); - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - return to; -} -Variant::operator Vector() const { - PoolVector from = operator PoolVector(); - Vector to; - int len = from.size(); - if (len == 0) { - return Vector(); - } - to.resize(len); - PoolVector::Read r = from.read(); - Vector3i *w = to.ptrw(); - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - return to; -} - -Variant::operator Vector() const { - PoolVector from = operator PoolVector(); - Vector to; - int len = from.size(); - if (len == 0) { - return Vector(); - } - to.resize(len); - PoolVector::Read r = from.read(); - Vector4 *w = to.ptrw(); - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - return to; -} -Variant::operator Vector() const { - PoolVector from = operator PoolVector(); - Vector to; - int len = from.size(); - if (len == 0) { - return Vector(); - } - to.resize(len); - PoolVector::Read r = from.read(); - Vector4i *w = to.ptrw(); - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - return to; -} - Variant::operator Vector() const { PoolVector from = operator PoolVector(); Vector to; @@ -2509,75 +1541,16 @@ Variant::Variant(const CharType *p_wstring) { memnew_placement(_data._mem, String(p_wstring)); } -Variant::Variant(const Rect2 &p_rect2) { - type = RECT2; - memnew_placement(_data._mem, Rect2(p_rect2)); -} Variant::Variant(const Rect2i &p_rect2) { type = RECT2I; memnew_placement(_data._mem, Rect2i(p_rect2)); } -Variant::Variant(const Vector2 &p_vector2) { - type = VECTOR2; - memnew_placement(_data._mem, Vector2(p_vector2)); -} Variant::Variant(const Vector2i &p_vector2) { type = VECTOR2I; memnew_placement(_data._mem, Vector2i(p_vector2)); } -Variant::Variant(const Vector3 &p_vector3) { - type = VECTOR3; - memnew_placement(_data._mem, Vector3(p_vector3)); -} -Variant::Variant(const Vector3i &p_vector3) { - type = VECTOR3I; - memnew_placement(_data._mem, Vector3i(p_vector3)); -} - -Variant::Variant(const Vector4 &p_vector4) { - type = VECTOR4; - memnew_placement(_data._mem, Vector4(p_vector4)); -} -Variant::Variant(const Vector4i &p_vector4) { - type = VECTOR4I; - memnew_placement(_data._mem, Vector4i(p_vector4)); -} - -Variant::Variant(const Plane &p_plane) { - type = PLANE; - memnew_placement(_data._mem, Plane(p_plane)); -} -Variant::Variant(const ::AABB &p_aabb) { - type = AABB; - _data._aabb = memnew(::AABB(p_aabb)); -} - -Variant::Variant(const Basis &p_matrix) { - type = BASIS; - _data._basis = memnew(Basis(p_matrix)); -} - -Variant::Variant(const Quaternion &p_quat) { - type = QUATERNION; - memnew_placement(_data._mem, Quaternion(p_quat)); -} -Variant::Variant(const Transform &p_transform) { - type = TRANSFORM; - _data._transform = memnew(Transform(p_transform)); -} - -Variant::Variant(const Transform2D &p_transform) { - type = TRANSFORM2D; - _data._transform2d = memnew(Transform2D(p_transform)); -} - -Variant::Variant(const Projection &p_projection) { - type = PROJECTION; - _data._projection = memnew(Projection(p_projection)); -} - Variant::Variant(const Color &p_color) { type = COLOR; memnew_placement(_data._mem, Color(p_color)); @@ -2614,30 +1587,6 @@ Variant::Variant(const Array &p_array) { memnew_placement(_data._mem, Array(p_array)); } -Variant::Variant(const PoolVector &p_array) { - type = ARRAY; - - Array *plane_array = memnew_placement(_data._mem, Array); - - plane_array->resize(p_array.size()); - - for (int i = 0; i < p_array.size(); i++) { - plane_array->operator[](i) = Variant(p_array[i]); - } -} - -Variant::Variant(const Vector &p_array) { - type = ARRAY; - - Array *plane_array = memnew_placement(_data._mem, Array); - - plane_array->resize(p_array.size()); - - for (int i = 0; i < p_array.size(); i++) { - plane_array->operator[](i) = Variant(p_array[i]); - } -} - Variant::Variant(const PoolVector &p_raw_array) { type = POOL_BYTE_ARRAY; memnew_placement(_data._mem, PoolVector(p_raw_array)); @@ -2654,58 +1603,16 @@ Variant::Variant(const PoolVector &p_string_array) { type = POOL_STRING_ARRAY; memnew_placement(_data._mem, PoolVector(p_string_array)); } -Variant::Variant(const PoolVector &p_vector2_array) { - type = POOL_VECTOR2_ARRAY; - memnew_placement(_data._mem, PoolVector(p_vector2_array)); -} Variant::Variant(const PoolVector &p_vector2_array) { type = POOL_VECTOR2I_ARRAY; memnew_placement(_data._mem, PoolVector(p_vector2_array)); } -Variant::Variant(const PoolVector &p_vector3_array) { - type = POOL_VECTOR3_ARRAY; - memnew_placement(_data._mem, PoolVector(p_vector3_array)); -} -Variant::Variant(const PoolVector &p_vector3_array) { - type = POOL_VECTOR3I_ARRAY; - memnew_placement(_data._mem, PoolVector(p_vector3_array)); -} - -Variant::Variant(const PoolVector &p_vector4_array) { - type = POOL_VECTOR4_ARRAY; - memnew_placement(_data._mem, PoolVector(p_vector4_array)); -} -Variant::Variant(const PoolVector &p_vector4_array) { - type = POOL_VECTOR4I_ARRAY; - memnew_placement(_data._mem, PoolVector(p_vector4_array)); -} Variant::Variant(const PoolVector &p_color_array) { type = POOL_COLOR_ARRAY; memnew_placement(_data._mem, PoolVector(p_color_array)); } -Variant::Variant(const PoolVector &p_face_array) { - PoolVector vertices; - int face_count = p_face_array.size(); - vertices.resize(face_count * 3); - - if (face_count) { - PoolVector::Read r = p_face_array.read(); - PoolVector::Write w = vertices.write(); - - for (int i = 0; i < face_count; i++) { - for (int j = 0; j < 3; j++) { - w[i * 3 + j] = r[i].vertex[j]; - } - } - } - - type = NIL; - - *this = vertices; -} - /* helpers */ Variant::Variant(const Vector &p_array) { @@ -2774,21 +1681,6 @@ Variant::Variant(const Vector &p_array) { *this = v; } -Variant::Variant(const Vector &p_array) { - type = NIL; - PoolVector v; - int len = p_array.size(); - if (len > 0) { - v.resize(len); - PoolVector::Write w = v.write(); - const Vector2 *r = p_array.ptr(); - - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - } - *this = v; -} Variant::Variant(const Vector &p_array) { type = NIL; PoolVector v; @@ -2805,68 +1697,6 @@ Variant::Variant(const Vector &p_array) { *this = v; } -Variant::Variant(const Vector &p_array) { - type = NIL; - PoolVector v; - int len = p_array.size(); - if (len > 0) { - v.resize(len); - PoolVector::Write w = v.write(); - const Vector3 *r = p_array.ptr(); - - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - } - *this = v; -} -Variant::Variant(const Vector &p_array) { - type = NIL; - PoolVector v; - int len = p_array.size(); - if (len > 0) { - v.resize(len); - PoolVector::Write w = v.write(); - const Vector3i *r = p_array.ptr(); - - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - } - *this = v; -} - -Variant::Variant(const Vector &p_array) { - type = NIL; - PoolVector v; - int len = p_array.size(); - if (len > 0) { - v.resize(len); - PoolVector::Write w = v.write(); - const Vector4 *r = p_array.ptr(); - - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - } - *this = v; -} -Variant::Variant(const Vector &p_array) { - type = NIL; - PoolVector v; - int len = p_array.size(); - if (len > 0) { - v.resize(len); - PoolVector::Write w = v.write(); - const Vector4i *r = p_array.ptr(); - - for (int i = 0; i < len; i++) { - w[i] = r[i]; - } - } - *this = v; -} - Variant::Variant(const Vector &p_array) { type = NIL; PoolVector v; @@ -2908,52 +1738,12 @@ void Variant::operator=(const Variant &p_variant) { } break; // math types - case RECT2: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; case RECT2I: { *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); } break; - case VECTOR2: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; case VECTOR2I: { *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); } break; - case VECTOR3: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; - case VECTOR3I: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; - case VECTOR4: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; - case VECTOR4I: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; - - case PLANE: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; - case QUATERNION: { - *reinterpret_cast(_data._mem) = *reinterpret_cast(p_variant._data._mem); - } break; - case AABB: { - *_data._aabb = *(p_variant._data._aabb); - } break; - case BASIS: { - *_data._basis = *(p_variant._data._basis); - } break; - case TRANSFORM: { - *_data._transform = *(p_variant._data._transform); - } break; - case TRANSFORM2D: { - *_data._transform2d = *(p_variant._data._transform2d); - } break; - case PROJECTION: { - *_data._projection = *(p_variant._data._projection); - } break; // misc types case COLOR: { @@ -2993,24 +1783,9 @@ void Variant::operator=(const Variant &p_variant) { case POOL_STRING_ARRAY: { *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); } break; - case POOL_VECTOR2_ARRAY: { - *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); - } break; case POOL_VECTOR2I_ARRAY: { *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); } break; - case POOL_VECTOR3_ARRAY: { - *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); - } break; - case POOL_VECTOR3I_ARRAY: { - *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); - } break; - case POOL_VECTOR4_ARRAY: { - *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); - } break; - case POOL_VECTOR4I_ARRAY: { - *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); - } break; case POOL_COLOR_ARRAY: { *reinterpret_cast *>(_data._mem) = *reinterpret_cast *>(p_variant._data._mem); } break; @@ -3054,115 +1829,12 @@ uint32_t Variant::recursive_hash(int p_recursion_count) const { } break; // math types - case RECT2: { - return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); - } break; case RECT2I: { return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); } break; - case VECTOR2: { - return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); - } break; case VECTOR2I: { return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); } break; - case VECTOR3: { - return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); - } break; - case VECTOR3I: { - return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); - } break; - case VECTOR4: { - return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); - } break; - case VECTOR4I: { - return HashMapHasherDefault::hash(*reinterpret_cast(_data._mem)); - } break; - case PLANE: { - uint32_t h = HASH_MURMUR3_SEED; - const Plane &p = *reinterpret_cast(_data._mem); - h = hash_murmur3_one_real(p.normal.x, h); - h = hash_murmur3_one_real(p.normal.y, h); - h = hash_murmur3_one_real(p.normal.z, h); - h = hash_murmur3_one_real(p.d, h); - return hash_fmix32(h); - } break; - case QUATERNION: { - uint32_t h = HASH_MURMUR3_SEED; - const Quaternion &q = *reinterpret_cast(_data._mem); - h = hash_murmur3_one_real(q.x, h); - h = hash_murmur3_one_real(q.y, h); - h = hash_murmur3_one_real(q.z, h); - h = hash_murmur3_one_real(q.w, h); - return hash_fmix32(h); - } break; - case AABB: { - return HashMapHasherDefault::hash(*_data._aabb); - } break; - case BASIS: { - uint32_t h = HASH_MURMUR3_SEED; - const Basis &b = *_data._basis; - h = hash_murmur3_one_real(b[0].x, h); - h = hash_murmur3_one_real(b[0].y, h); - h = hash_murmur3_one_real(b[0].z, h); - h = hash_murmur3_one_real(b[1].x, h); - h = hash_murmur3_one_real(b[1].y, h); - h = hash_murmur3_one_real(b[1].z, h); - h = hash_murmur3_one_real(b[2].x, h); - h = hash_murmur3_one_real(b[2].y, h); - h = hash_murmur3_one_real(b[2].z, h); - return hash_fmix32(h); - } break; - case TRANSFORM: { - uint32_t h = HASH_MURMUR3_SEED; - const Transform &t = *_data._transform; - h = hash_murmur3_one_real(t.basis[0].x, h); - h = hash_murmur3_one_real(t.basis[0].y, h); - h = hash_murmur3_one_real(t.basis[0].z, h); - h = hash_murmur3_one_real(t.basis[1].x, h); - h = hash_murmur3_one_real(t.basis[1].y, h); - h = hash_murmur3_one_real(t.basis[1].z, h); - h = hash_murmur3_one_real(t.basis[2].x, h); - h = hash_murmur3_one_real(t.basis[2].y, h); - h = hash_murmur3_one_real(t.basis[2].z, h); - h = hash_murmur3_one_real(t.origin.x, h); - h = hash_murmur3_one_real(t.origin.y, h); - h = hash_murmur3_one_real(t.origin.z, h); - return hash_fmix32(h); - } break; - case TRANSFORM2D: { - uint32_t h = HASH_MURMUR3_SEED; - const Transform2D &t = *_data._transform2d; - h = hash_murmur3_one_real(t[0].x, h); - h = hash_murmur3_one_real(t[0].y, h); - h = hash_murmur3_one_real(t[1].x, h); - h = hash_murmur3_one_real(t[1].y, h); - h = hash_murmur3_one_real(t[2].x, h); - h = hash_murmur3_one_real(t[2].y, h); - - return hash_fmix32(h); - } break; - case PROJECTION: { - uint32_t h = HASH_MURMUR3_SEED; - const Projection &t = *_data._projection; - h = hash_murmur3_one_real(t.matrix[0].x, h); - h = hash_murmur3_one_real(t.matrix[0].y, h); - h = hash_murmur3_one_real(t.matrix[0].z, h); - h = hash_murmur3_one_real(t.matrix[0].w, h); - h = hash_murmur3_one_real(t.matrix[1].x, h); - h = hash_murmur3_one_real(t.matrix[1].y, h); - h = hash_murmur3_one_real(t.matrix[1].z, h); - h = hash_murmur3_one_real(t.matrix[1].w, h); - h = hash_murmur3_one_real(t.matrix[2].x, h); - h = hash_murmur3_one_real(t.matrix[2].y, h); - h = hash_murmur3_one_real(t.matrix[2].z, h); - h = hash_murmur3_one_real(t.matrix[2].w, h); - h = hash_murmur3_one_real(t.matrix[3].x, h); - h = hash_murmur3_one_real(t.matrix[3].y, h); - h = hash_murmur3_one_real(t.matrix[3].z, h); - h = hash_murmur3_one_real(t.matrix[3].w, h); - return hash_fmix32(h); - } break; // misc types case COLOR: { @@ -3245,24 +1917,6 @@ uint32_t Variant::recursive_hash(int p_recursion_count) const { return hash; } break; - case POOL_VECTOR2_ARRAY: { - uint32_t hash = HASH_MURMUR3_SEED; - const PoolVector &arr = *reinterpret_cast *>(_data._mem); - int len = arr.size(); - - if (likely(len)) { - PoolVector::Read r = arr.read(); - - for (int i = 0; i < len; i++) { - hash = hash_murmur3_one_real(r[i].x, hash); - hash = hash_murmur3_one_real(r[i].y, hash); - } - - hash = hash_fmix32(hash); - } - - return hash; - } break; case POOL_VECTOR2I_ARRAY: { uint32_t hash = HASH_MURMUR3_SEED; const PoolVector &arr = *reinterpret_cast *>(_data._mem); @@ -3281,84 +1935,7 @@ uint32_t Variant::recursive_hash(int p_recursion_count) const { return hash; } break; - case POOL_VECTOR3_ARRAY: { - uint32_t hash = HASH_MURMUR3_SEED; - const PoolVector &arr = *reinterpret_cast *>(_data._mem); - int len = arr.size(); - if (likely(len)) { - PoolVector::Read r = arr.read(); - - for (int i = 0; i < len; i++) { - hash = hash_murmur3_one_real(r[i].x, hash); - hash = hash_murmur3_one_real(r[i].y, hash); - hash = hash_murmur3_one_real(r[i].z, hash); - } - - hash = hash_fmix32(hash); - } - - return hash; - } break; - case POOL_VECTOR3I_ARRAY: { - uint32_t hash = HASH_MURMUR3_SEED; - const PoolVector &arr = *reinterpret_cast *>(_data._mem); - int len = arr.size(); - - if (likely(len)) { - PoolVector::Read r = arr.read(); - - for (int i = 0; i < len; i++) { - hash = hash_murmur3_one_32(r[i].x, hash); - hash = hash_murmur3_one_32(r[i].y, hash); - hash = hash_murmur3_one_32(r[i].z, hash); - } - - hash = hash_fmix32(hash); - } - - return hash; - } break; - case POOL_VECTOR4_ARRAY: { - uint32_t hash = HASH_MURMUR3_SEED; - const PoolVector &arr = *reinterpret_cast *>(_data._mem); - int len = arr.size(); - - if (likely(len)) { - PoolVector::Read r = arr.read(); - - for (int i = 0; i < len; i++) { - hash = hash_murmur3_one_real(r[i].x, hash); - hash = hash_murmur3_one_real(r[i].y, hash); - hash = hash_murmur3_one_real(r[i].z, hash); - hash = hash_murmur3_one_real(r[i].w, hash); - } - - hash = hash_fmix32(hash); - } - - return hash; - } break; - case POOL_VECTOR4I_ARRAY: { - uint32_t hash = HASH_MURMUR3_SEED; - const PoolVector &arr = *reinterpret_cast *>(_data._mem); - int len = arr.size(); - - if (likely(len)) { - PoolVector::Read r = arr.read(); - - for (int i = 0; i < len; i++) { - hash = hash_murmur3_one_32(r[i].x, hash); - hash = hash_murmur3_one_32(r[i].y, hash); - hash = hash_murmur3_one_32(r[i].z, hash); - hash = hash_murmur3_one_32(r[i].w, hash); - } - - hash = hash_fmix32(hash); - } - - return hash; - } break; case POOL_COLOR_ARRAY: { uint32_t hash = HASH_MURMUR3_SEED; const PoolVector &arr = *reinterpret_cast *>(_data._mem); @@ -3465,13 +2042,6 @@ bool Variant::hash_compare(const Variant &p_variant) const { return *reinterpret_cast(_data._mem) == *reinterpret_cast(p_variant._data._mem); } break; - case RECT2: { - const Rect2 *l = reinterpret_cast(_data._mem); - const Rect2 *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector2(l->position, r->position) && - hash_compare_vector2(l->size, r->size); - } break; case RECT2I: { const Rect2i *l = reinterpret_cast(_data._mem); const Rect2i *r = reinterpret_cast(p_variant._data._mem); @@ -3479,112 +2049,12 @@ bool Variant::hash_compare(const Variant &p_variant) const { return hash_compare_vector2i(l->position, r->position) && hash_compare_vector2i(l->size, r->size); } break; - case VECTOR2: { - const Vector2 *l = reinterpret_cast(_data._mem); - const Vector2 *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector2(*l, *r); - } break; case VECTOR2I: { const Vector2i *l = reinterpret_cast(_data._mem); const Vector2i *r = reinterpret_cast(p_variant._data._mem); return hash_compare_vector2i(*l, *r); } break; - case VECTOR3: { - const Vector3 *l = reinterpret_cast(_data._mem); - const Vector3 *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector3(*l, *r); - } break; - case VECTOR3I: { - const Vector3i *l = reinterpret_cast(_data._mem); - const Vector3i *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector3i(*l, *r); - } break; - case VECTOR4: { - const Vector4 *l = reinterpret_cast(_data._mem); - const Vector4 *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector4(*l, *r); - } break; - case VECTOR4I: { - const Vector4i *l = reinterpret_cast(_data._mem); - const Vector4i *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector4i(*l, *r); - } break; - - case PLANE: { - const Plane *l = reinterpret_cast(_data._mem); - const Plane *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_vector3(l->normal, r->normal) && - hash_compare_scalar(l->d, r->d); - } break; - case QUATERNION: { - const Quaternion *l = reinterpret_cast(_data._mem); - const Quaternion *r = reinterpret_cast(p_variant._data._mem); - - return hash_compare_quat(*l, *r); - } break; - case AABB: { - const ::AABB *l = _data._aabb; - const ::AABB *r = p_variant._data._aabb; - - return hash_compare_vector3(l->position, r->position) && - hash_compare_vector3(l->size, r->size); - - } break; - case BASIS: { - const Basis *l = _data._basis; - const Basis *r = p_variant._data._basis; - - for (int i = 0; i < 3; i++) { - if (!hash_compare_vector3(l->rows[i], r->rows[i])) { - return false; - } - } - - return true; - } break; - case TRANSFORM: { - const Transform *l = _data._transform; - const Transform *r = p_variant._data._transform; - - for (int i = 0; i < 3; i++) { - if (!hash_compare_vector3(l->basis.rows[i], r->basis.rows[i])) { - return false; - } - } - - return hash_compare_vector3(l->origin, r->origin); - } break; - case TRANSFORM2D: { - Transform2D *l = _data._transform2d; - Transform2D *r = p_variant._data._transform2d; - - for (int i = 0; i < 3; i++) { - if (!hash_compare_vector2(l->columns[i], r->columns[i])) { - return false; - } - } - - return true; - } break; - case PROJECTION: { - const Projection *l = _data._projection; - const Projection *r = p_variant._data._projection; - - for (int i = 0; i < 4; i++) { - if (!hash_compare_vector4(l->matrix[i], r->matrix[i])) { - return false; - } - } - - return true; - } break; case COLOR: { const Color *l = reinterpret_cast(_data._mem); @@ -3612,24 +2082,9 @@ bool Variant::hash_compare(const Variant &p_variant) const { case POOL_REAL_ARRAY: { hash_compare_pool_array(_data._mem, p_variant._data._mem, real_t, hash_compare_scalar); } break; - case POOL_VECTOR2_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2, hash_compare_vector2); - } break; case POOL_VECTOR2I_ARRAY: { hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2i, hash_compare_vector2i); } break; - case POOL_VECTOR3_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3, hash_compare_vector3); - } break; - case POOL_VECTOR3I_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3i, hash_compare_vector3i); - } break; - case POOL_VECTOR4_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector4, hash_compare_vector4); - } break; - case POOL_VECTOR4I_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector4i, hash_compare_vector4i); - } break; case POOL_COLOR_ARRAY: { hash_compare_pool_array(_data._mem, p_variant._data._mem, Color, hash_compare_color); } break; diff --git a/sfwl/object/variant.h b/sfwl/object/variant.h index d17c205..a64fd58 100644 --- a/sfwl/object/variant.h +++ b/sfwl/object/variant.h @@ -9,21 +9,11 @@ /*************************************************************************/ //--STRIP -#include "core/aabb.h" -#include "core/basis.h" #include "core/color.h" -#include "core/face3.h" -#include "core/plane.h" #include "core/pool_vector.h" -#include "core/projection.h" -#include "core/quaternion.h" -#include "core/transform.h" -#include "core/transform_2d.h" #include "core/ustring.h" -#include "core/vector3.h" -#include "core/vector3i.h" -#include "core/vector4.h" -#include "core/vector4i.h" +#include "core/vector2i.h" +#include "core/rect2i.h" #include "object/array.h" #include "object/dictionary.h" #include "object/ref_ptr.h" @@ -37,12 +27,7 @@ typedef PoolVector PoolByteArray; typedef PoolVector PoolIntArray; typedef PoolVector PoolRealArray; typedef PoolVector PoolStringArray; -typedef PoolVector PoolVector2Array; typedef PoolVector PoolVector2iArray; -typedef PoolVector PoolVector3Array; -typedef PoolVector PoolVector3iArray; -typedef PoolVector PoolVector4Array; -typedef PoolVector PoolVector4iArray; typedef PoolVector PoolColorArray; // Temporary workaround until c++11 alignas() @@ -73,22 +58,8 @@ public: STRING, // math types - RECT2, RECT2I, - VECTOR2, VECTOR2I, - VECTOR3, - VECTOR3I, - VECTOR4, - VECTOR4I, - - PLANE, - QUATERNION, - AABB, - BASIS, - TRANSFORM, - TRANSFORM2D, - PROJECTION, // misc types COLOR, @@ -102,15 +73,10 @@ public: POOL_INT_ARRAY, POOL_REAL_ARRAY, POOL_STRING_ARRAY, - POOL_VECTOR2_ARRAY, POOL_VECTOR2I_ARRAY, - POOL_VECTOR3_ARRAY, - POOL_VECTOR3I_ARRAY, - POOL_VECTOR4_ARRAY, - POOL_VECTOR4I_ARRAY, POOL_COLOR_ARRAY, - VARIANT_MAX // 38 + VARIANT_MAX }; @@ -141,11 +107,6 @@ private: bool _bool; int64_t _int; double _real; - Transform2D *_transform2d; - ::AABB *_aabb; - Basis *_basis; - Transform *_transform; - Projection *_projection; void *_ptr; //generic pointer uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)]; } _data GCC_ALIGNED_8; @@ -190,21 +151,8 @@ public: operator double() const; operator String() const; operator StringName() const; - operator Rect2() const; operator Rect2i() const; - operator Vector2() const; operator Vector2i() const; - operator Vector3() const; - operator Vector3i() const; - operator Vector4() const; - operator Vector4i() const; - operator Plane() const; - operator ::AABB() const; - operator Quaternion() const; - operator Basis() const; - operator Transform() const; - operator Transform2D() const; - operator Projection() const; operator Color() const; operator RefPtr() const; @@ -218,15 +166,8 @@ public: operator PoolVector() const; operator PoolVector() const; operator PoolVector() const; - operator PoolVector() const; operator PoolVector() const; - operator PoolVector() const; - operator PoolVector() const; - operator PoolVector() const; - operator PoolVector() const; operator PoolVector() const; - operator PoolVector() const; - operator PoolVector() const; operator Vector() const; operator Vector() const; @@ -234,16 +175,9 @@ public: operator Vector() const; operator Vector() const; operator Vector() const; - operator Vector() const; - operator Vector() const; - operator Vector() const; - operator Vector() const; operator Vector() const; - operator Vector() const; operator Vector() const; - operator Vector() const; - // some core type enums to convert to operator Margin() const; operator Side() const; @@ -269,40 +203,20 @@ public: Variant(const StringName &p_string); Variant(const char *const p_cstring); Variant(const CharType *p_wstring); - Variant(const Vector2 &p_vector2); Variant(const Vector2i &p_vector2); - Variant(const Rect2 &p_rect2); Variant(const Rect2i &p_rect2); - Variant(const Vector3 &p_vector3); - Variant(const Vector3i &p_vector3); - Variant(const Vector4 &p_vector4); - Variant(const Vector4i &p_vector4); - Variant(const Projection &p_projection); - Variant(const Plane &p_plane); - Variant(const ::AABB &p_aabb); - Variant(const Quaternion &p_quat); - Variant(const Basis &p_matrix); - Variant(const Transform2D &p_transform); - Variant(const Transform &p_transform); Variant(const Color &p_color); Variant(const RefPtr &p_resource); Variant(const Object *p_object); Variant(const Dictionary &p_dictionary); Variant(const Array &p_array); - Variant(const PoolVector &p_array); Variant(const PoolVector &p_raw_array); Variant(const PoolVector &p_int_array); Variant(const PoolVector &p_real_array); Variant(const PoolVector &p_string_array); - Variant(const PoolVector &p_vector3_array); - Variant(const PoolVector &p_vector3_array); Variant(const PoolVector &p_color_array); - Variant(const PoolVector &p_face_array); - Variant(const PoolVector &p_vector2_array); Variant(const PoolVector &p_vector2_array); - Variant(const PoolVector &p_vector4_array); - Variant(const PoolVector &p_vector4_array); Variant(const Vector &p_array); Variant(const Vector &p_array); @@ -310,14 +224,8 @@ public: Variant(const Vector &p_array); Variant(const Vector &p_array); Variant(const Vector &p_array); - Variant(const Vector &p_array); - Variant(const Vector &p_array); Variant(const Vector &p_array); - Variant(const Vector &p_array); - Variant(const Vector &p_array); Variant(const Vector &p_array); - Variant(const Vector &p_array); - Variant(const Vector &p_array); // If this changes the table in variant_op must be updated enum Operator { diff --git a/sfwl/object/variant_op.cpp b/sfwl/object/variant_op.cpp index a079c40..710ecf7 100644 --- a/sfwl/object/variant_op.cpp +++ b/sfwl/object/variant_op.cpp @@ -21,21 +21,8 @@ CASE_TYPE(PREFIX, OP, BOOL) \ CASE_TYPE(PREFIX, OP, REAL) \ CASE_TYPE(PREFIX, OP, STRING) \ - CASE_TYPE(PREFIX, OP, RECT2) \ CASE_TYPE(PREFIX, OP, RECT2I) \ - CASE_TYPE(PREFIX, OP, VECTOR2) \ CASE_TYPE(PREFIX, OP, VECTOR2I) \ - CASE_TYPE(PREFIX, OP, VECTOR3) \ - CASE_TYPE(PREFIX, OP, VECTOR3I) \ - CASE_TYPE(PREFIX, OP, VECTOR4) \ - CASE_TYPE(PREFIX, OP, VECTOR4I) \ - CASE_TYPE(PREFIX, OP, PLANE) \ - CASE_TYPE(PREFIX, OP, QUATERNION) \ - CASE_TYPE(PREFIX, OP, AABB) \ - CASE_TYPE(PREFIX, OP, BASIS) \ - CASE_TYPE(PREFIX, OP, TRANSFORM) \ - CASE_TYPE(PREFIX, OP, TRANSFORM2D) \ - CASE_TYPE(PREFIX, OP, PROJECTION) \ CASE_TYPE(PREFIX, OP, COLOR) \ CASE_TYPE(PREFIX, OP, OBJECT) \ CASE_TYPE(PREFIX, OP, STRING_NAME) \ @@ -45,12 +32,7 @@ CASE_TYPE(PREFIX, OP, POOL_INT_ARRAY) \ CASE_TYPE(PREFIX, OP, POOL_REAL_ARRAY) \ CASE_TYPE(PREFIX, OP, POOL_STRING_ARRAY) \ - CASE_TYPE(PREFIX, OP, POOL_VECTOR2_ARRAY) \ CASE_TYPE(PREFIX, OP, POOL_VECTOR2I_ARRAY) \ - CASE_TYPE(PREFIX, OP, POOL_VECTOR3_ARRAY) \ - CASE_TYPE(PREFIX, OP, POOL_VECTOR3I_ARRAY) \ - CASE_TYPE(PREFIX, OP, POOL_VECTOR4_ARRAY) \ - CASE_TYPE(PREFIX, OP, POOL_VECTOR4I_ARRAY) \ CASE_TYPE(PREFIX, OP, POOL_COLOR_ARRAY) #ifdef __GNUC__ @@ -64,21 +46,8 @@ TYPE(PREFIX, OP, INT), \ TYPE(PREFIX, OP, REAL), \ TYPE(PREFIX, OP, STRING), \ - TYPE(PREFIX, OP, RECT2), \ TYPE(PREFIX, OP, RECT2I), \ - TYPE(PREFIX, OP, VECTOR2), \ TYPE(PREFIX, OP, VECTOR2I), \ - TYPE(PREFIX, OP, VECTOR3), \ - TYPE(PREFIX, OP, VECTOR3I), \ - TYPE(PREFIX, OP, VECTOR4), \ - TYPE(PREFIX, OP, VECTOR4I), \ - TYPE(PREFIX, OP, PLANE), \ - TYPE(PREFIX, OP, QUATERNION), \ - TYPE(PREFIX, OP, AABB), \ - TYPE(PREFIX, OP, BASIS), \ - TYPE(PREFIX, OP, TRANSFORM), \ - TYPE(PREFIX, OP, TRANSFORM2D), \ - TYPE(PREFIX, OP, PROJECTION), \ TYPE(PREFIX, OP, COLOR), \ TYPE(PREFIX, OP, OBJECT), \ TYPE(PREFIX, OP, STRING_NAME), \ @@ -88,18 +57,13 @@ TYPE(PREFIX, OP, POOL_INT_ARRAY), \ TYPE(PREFIX, OP, POOL_REAL_ARRAY), \ TYPE(PREFIX, OP, POOL_STRING_ARRAY), \ - TYPE(PREFIX, OP, POOL_VECTOR2_ARRAY), \ TYPE(PREFIX, OP, POOL_VECTOR2I_ARRAY), \ - TYPE(PREFIX, OP, POOL_VECTOR3_ARRAY), \ - TYPE(PREFIX, OP, POOL_VECTOR3I_ARRAY), \ - TYPE(PREFIX, OP, POOL_VECTOR4_ARRAY), \ - TYPE(PREFIX, OP, POOL_VECTOR4I_ARRAY), \ TYPE(PREFIX, OP, POOL_COLOR_ARRAY), \ } /* clang-format on */ -#define CASES(PREFIX) static const void *switch_table_##PREFIX[25][38] = { \ +#define CASES(PREFIX) static const void *switch_table_##PREFIX[25][18] = { \ TYPES(PREFIX, OP_EQUAL), \ TYPES(PREFIX, OP_NOT_EQUAL), \ TYPES(PREFIX, OP_LESS), \ @@ -232,18 +196,6 @@ bool Variant::booleanize() const { _RETURN(p_a._data.m_type m_op p_b._data._int); \ if (p_b.type == REAL) \ _RETURN(p_a._data.m_type m_op p_b._data._real); \ - if (p_b.type == VECTOR2) \ - _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == VECTOR2I) \ - _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == VECTOR3) \ - _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == VECTOR3I) \ - _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == VECTOR4) \ - _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == VECTOR4I) \ - _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ \ _RETURN_FAIL \ }; @@ -507,21 +459,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM_NULL(math, OP_EQUAL, INT, ==, _int); DEFAULT_OP_NUM_NULL(math, OP_EQUAL, REAL, ==, _real); DEFAULT_OP_STR_NULL(math, OP_EQUAL, STRING, ==, String); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, RECT2, ==, Rect2); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, RECT2I, ==, Rect2i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR2, ==, Vector2); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR2I, ==, Vector2i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3, ==, Vector3); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3I, ==, Vector3i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR4, ==, Vector4); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR4I, ==, Vector4i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, PLANE, ==, Plane); - DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUATERNION, ==, Quaternion); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, AABB, ==, _aabb); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM2D, ==, _transform2d); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, PROJECTION, ==, _projection); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, COLOR, ==, Color); DEFAULT_OP_STR_NULL_SN(math, OP_EQUAL, STRING_NAME, ==, StringName); @@ -529,12 +468,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_INT_ARRAY, int); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_REAL_ARRAY, real_t); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_STRING_ARRAY, String); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR2I_ARRAY, Vector2i); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR3_ARRAY, Vector3); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR3I_ARRAY, Vector3i); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR4_ARRAY, Vector4); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR4I_ARRAY, Vector4i); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_COLOR_ARRAY, Color); } @@ -607,21 +541,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, INT, !=, _int); DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, REAL, !=, _real); DEFAULT_OP_STR_NULL(math, OP_NOT_EQUAL, STRING, !=, String); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, RECT2, !=, Rect2); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, RECT2I, !=, Rect2i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR2, !=, Vector2); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR2I, !=, Vector2i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3I, !=, Vector3i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR4, !=, Vector4); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR4I, !=, Vector4i); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, PLANE, !=, Plane); - DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUATERNION, !=, Quaternion); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, AABB, !=, _aabb); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM2D, !=, _transform2d); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, PROJECTION, !=, _projection); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, COLOR, !=, Color); DEFAULT_OP_STR_NULL_SN(math, OP_NOT_EQUAL, STRING_NAME, !=, StringName); @@ -629,12 +550,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_INT_ARRAY, int); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_REAL_ARRAY, real_t); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_STRING_ARRAY, String); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR2I_ARRAY, Vector2i); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR3_ARRAY, Vector3); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR3I_ARRAY, Vector3i); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR4_ARRAY, Vector4); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR4I_ARRAY, Vector4i); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_COLOR_ARRAY, Color); } @@ -680,35 +596,17 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM(math, OP_LESS, INT, <, _int); DEFAULT_OP_NUM(math, OP_LESS, REAL, <, _real); DEFAULT_OP_STR(math, OP_LESS, STRING, <, String); - DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2, <, Vector2); DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2I, <, Vector2i); - DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR3, <, Vector3); - DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR3I, <, Vector3i); - DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR4, <, Vector4); - DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR4I, <, Vector4i); DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_BYTE_ARRAY, uint8_t); DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_INT_ARRAY, int); DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_REAL_ARRAY, real_t); DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_STRING_ARRAY, String); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR2I_ARRAY, Vector2i); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR3_ARRAY, Vector3); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR3I_ARRAY, Vector3i); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR4_ARRAY, Vector4); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR4I_ARRAY, Vector4i); DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_COLOR_ARRAY, Color); CASE_TYPE(math, OP_LESS, NIL) - CASE_TYPE(math, OP_LESS, RECT2) CASE_TYPE(math, OP_LESS, RECT2I) - CASE_TYPE(math, OP_LESS, PLANE) - CASE_TYPE(math, OP_LESS, QUATERNION) - CASE_TYPE(math, OP_LESS, AABB) - CASE_TYPE(math, OP_LESS, BASIS) - CASE_TYPE(math, OP_LESS, TRANSFORM) - CASE_TYPE(math, OP_LESS, TRANSFORM2D) - CASE_TYPE(math, OP_LESS, PROJECTION) CASE_TYPE(math, OP_LESS, STRING_NAME) CASE_TYPE(math, OP_LESS, COLOR) CASE_TYPE(math, OP_LESS, DICTIONARY) @@ -725,24 +623,11 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM(math, OP_LESS_EQUAL, INT, <=, _int); DEFAULT_OP_NUM(math, OP_LESS_EQUAL, REAL, <=, _real); DEFAULT_OP_STR(math, OP_LESS_EQUAL, STRING, <=, String); - DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR2, <=, Vector2); DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR2I, <=, Vector2i); - DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR3, <=, Vector3); - DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR3I, <=, Vector3i); - DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR4, <=, Vector4); - DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR4I, <=, Vector4i); CASE_TYPE(math, OP_LESS_EQUAL, NIL) CASE_TYPE(math, OP_LESS_EQUAL, BOOL) - CASE_TYPE(math, OP_LESS_EQUAL, RECT2) CASE_TYPE(math, OP_LESS_EQUAL, RECT2I) - CASE_TYPE(math, OP_LESS_EQUAL, PLANE) - CASE_TYPE(math, OP_LESS_EQUAL, QUATERNION) - CASE_TYPE(math, OP_LESS_EQUAL, AABB) - CASE_TYPE(math, OP_LESS_EQUAL, BASIS) - CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM) - CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D) - CASE_TYPE(math, OP_LESS_EQUAL, PROJECTION) CASE_TYPE(math, OP_LESS_EQUAL, COLOR) CASE_TYPE(math, OP_LESS_EQUAL, STRING_NAME) CASE_TYPE(math, OP_LESS_EQUAL, DICTIONARY) @@ -751,12 +636,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS_EQUAL, POOL_INT_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, POOL_REAL_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, POOL_STRING_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR2_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR2I_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR3_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR3I_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR4_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR4I_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, POOL_COLOR_ARRAY); _RETURN_FAIL; } @@ -803,35 +683,17 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM(math, OP_GREATER, INT, >, _int); DEFAULT_OP_NUM(math, OP_GREATER, REAL, >, _real); DEFAULT_OP_STR_REV(math, OP_GREATER, STRING, <, String); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR2, <, Vector2); DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR2I, <, Vector2i); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR3, <, Vector3); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR3I, <, Vector3i); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR4, <, Vector4); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR4I, <, Vector4i); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_BYTE_ARRAY, uint8_t); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_INT_ARRAY, int); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_REAL_ARRAY, real_t); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_STRING_ARRAY, String); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR2I_ARRAY, Vector2i); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR3_ARRAY, Vector3); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR3I_ARRAY, Vector3i); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR4_ARRAY, Vector4); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR4I_ARRAY, Vector4i); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_COLOR_ARRAY, Color); CASE_TYPE(math, OP_GREATER, NIL) - CASE_TYPE(math, OP_GREATER, RECT2) CASE_TYPE(math, OP_GREATER, RECT2I) - CASE_TYPE(math, OP_GREATER, PLANE) - CASE_TYPE(math, OP_GREATER, QUATERNION) - CASE_TYPE(math, OP_GREATER, AABB) - CASE_TYPE(math, OP_GREATER, BASIS) CASE_TYPE(math, OP_GREATER, STRING_NAME) - CASE_TYPE(math, OP_GREATER, TRANSFORM) - CASE_TYPE(math, OP_GREATER, TRANSFORM2D) - CASE_TYPE(math, OP_GREATER, PROJECTION) CASE_TYPE(math, OP_GREATER, COLOR) CASE_TYPE(math, OP_GREATER, DICTIONARY) _RETURN_FAIL; @@ -847,24 +709,11 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, INT, >=, _int); DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, REAL, >=, _real); DEFAULT_OP_STR_REV(math, OP_GREATER_EQUAL, STRING, <=, String); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR2, <=, Vector2); DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR2I, <=, Vector2i); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR3, <=, Vector3); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR3I, <=, Vector3i); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR4, <=, Vector4); - DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR4I, <=, Vector4i); CASE_TYPE(math, OP_GREATER_EQUAL, NIL) CASE_TYPE(math, OP_GREATER_EQUAL, BOOL) - CASE_TYPE(math, OP_GREATER_EQUAL, RECT2) CASE_TYPE(math, OP_GREATER_EQUAL, RECT2I) - CASE_TYPE(math, OP_GREATER_EQUAL, PLANE) - CASE_TYPE(math, OP_GREATER_EQUAL, QUATERNION) - CASE_TYPE(math, OP_GREATER_EQUAL, AABB) - CASE_TYPE(math, OP_GREATER_EQUAL, BASIS) - CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM) - CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D) - CASE_TYPE(math, OP_GREATER_EQUAL, PROJECTION) CASE_TYPE(math, OP_GREATER_EQUAL, COLOR) CASE_TYPE(math, OP_GREATER_EQUAL, DICTIONARY) CASE_TYPE(math, OP_GREATER_EQUAL, STRING_NAME) @@ -873,12 +722,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER_EQUAL, POOL_INT_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, POOL_REAL_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, POOL_STRING_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR2_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR2I_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR3_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR3I_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR4_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR4I_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, POOL_COLOR_ARRAY); _RETURN_FAIL; } @@ -906,37 +750,19 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM(math, OP_ADD, INT, +, _int); DEFAULT_OP_NUM(math, OP_ADD, REAL, +, _real); DEFAULT_OP_STR(math, OP_ADD, STRING, +, String); - DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2, +, Vector2); DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2I, +, Vector2i); - DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR3, +, Vector3); - DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR3I, +, Vector3i); - DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR4, +, Vector4); - DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR4I, +, Vector4i); - DEFAULT_OP_LOCALMEM(math, OP_ADD, QUATERNION, +, Quaternion); DEFAULT_OP_LOCALMEM(math, OP_ADD, COLOR, +, Color); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_BYTE_ARRAY, uint8_t); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_INT_ARRAY, int); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_REAL_ARRAY, real_t); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_STRING_ARRAY, String); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR2I_ARRAY, Vector2i); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR3_ARRAY, Vector3); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR3I_ARRAY, Vector3i); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR4_ARRAY, Vector4); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR4I_ARRAY, Vector4i); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_COLOR_ARRAY, Color); CASE_TYPE(math, OP_ADD, NIL) CASE_TYPE(math, OP_ADD, BOOL) - CASE_TYPE(math, OP_ADD, RECT2) CASE_TYPE(math, OP_ADD, RECT2I) - CASE_TYPE(math, OP_ADD, PLANE) - CASE_TYPE(math, OP_ADD, AABB) - CASE_TYPE(math, OP_ADD, BASIS) - CASE_TYPE(math, OP_ADD, TRANSFORM) - CASE_TYPE(math, OP_ADD, TRANSFORM2D) - CASE_TYPE(math, OP_ADD, PROJECTION) CASE_TYPE(math, OP_ADD, OBJECT) CASE_TYPE(math, OP_ADD, DICTIONARY) CASE_TYPE(math, OP_ADD, STRING_NAME) @@ -946,26 +772,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, SWITCH_OP(math, OP_SUBTRACT, p_a.type) { DEFAULT_OP_NUM(math, OP_SUBTRACT, INT, -, _int); DEFAULT_OP_NUM(math, OP_SUBTRACT, REAL, -, _real); - DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2, -, Vector2); DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2I, -, Vector2i); - DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3, -, Vector3); - DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3I, -, Vector3i); - DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR4, -, Vector4); - DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR4I, -, Vector4i); - DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, QUATERNION, -, Quaternion); DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, COLOR, -, Color); CASE_TYPE(math, OP_SUBTRACT, NIL) CASE_TYPE(math, OP_SUBTRACT, BOOL) CASE_TYPE(math, OP_SUBTRACT, STRING) - CASE_TYPE(math, OP_SUBTRACT, RECT2) CASE_TYPE(math, OP_SUBTRACT, RECT2I) - CASE_TYPE(math, OP_SUBTRACT, PLANE) - CASE_TYPE(math, OP_SUBTRACT, AABB) - CASE_TYPE(math, OP_SUBTRACT, BASIS) - CASE_TYPE(math, OP_SUBTRACT, TRANSFORM) - CASE_TYPE(math, OP_SUBTRACT, TRANSFORM2D) - CASE_TYPE(math, OP_SUBTRACT, PROJECTION) CASE_TYPE(math, OP_SUBTRACT, OBJECT) CASE_TYPE(math, OP_SUBTRACT, STRING_NAME) CASE_TYPE(math, OP_SUBTRACT, DICTIONARY) @@ -974,120 +787,21 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SUBTRACT, POOL_INT_ARRAY); CASE_TYPE(math, OP_SUBTRACT, POOL_REAL_ARRAY); CASE_TYPE(math, OP_SUBTRACT, POOL_STRING_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR2_ARRAY); CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR2I_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR3_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR3I_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR4_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR4I_ARRAY); CASE_TYPE(math, OP_SUBTRACT, POOL_COLOR_ARRAY); _RETURN_FAIL; } SWITCH_OP(math, OP_MULTIPLY, p_a.type) { - CASE_TYPE(math, OP_MULTIPLY, QUATERNION) { - switch (p_b.type) { - case VECTOR3: { - _RETURN(reinterpret_cast(p_a._data._mem)->xform(*(const Vector3 *)p_b._data._mem)); - } - case VECTOR3I: { - _RETURN(reinterpret_cast(p_a._data._mem)->xform(*(const Vector3i *)p_b._data._mem)); - } - case QUATERNION: { - _RETURN(*reinterpret_cast(p_a._data._mem) * *reinterpret_cast(p_b._data._mem)); - } - case REAL: { - _RETURN(*reinterpret_cast(p_a._data._mem) * p_b._data._real); - } - default: - _RETURN_FAIL; - } - } - - CASE_TYPE(math, OP_MULTIPLY, BASIS) { - switch (p_b.type) { - case VECTOR3: { - _RETURN(p_a._data._basis->xform(*(const Vector3 *)p_b._data._mem)); - } - case VECTOR3I: { - _RETURN(p_a._data._basis->xform(*(const Vector3i *)p_b._data._mem)); - } - case BASIS: { - _RETURN(*p_a._data._basis * *p_b._data._basis); - } - default: - _RETURN_FAIL; - } - } - - CASE_TYPE(math, OP_MULTIPLY, TRANSFORM) { - switch (p_b.type) { - case VECTOR3: { - _RETURN(p_a._data._transform->xform(*(const Vector3 *)p_b._data._mem)); - } - case VECTOR3I: { - _RETURN(p_a._data._transform->xform(*(const Vector3i *)p_b._data._mem)); - } - case TRANSFORM: { - _RETURN(*p_a._data._transform * *p_b._data._transform); - } - default: - _RETURN_FAIL; - } - } - - CASE_TYPE(math, OP_MULTIPLY, TRANSFORM2D) { - switch (p_b.type) { - case TRANSFORM2D: { - _RETURN(*p_a._data._transform2d * *p_b._data._transform2d); - } - case VECTOR2: { - _RETURN(p_a._data._transform2d->xform(*(const Vector2 *)p_b._data._mem)); - } - case VECTOR2I: { - _RETURN(p_a._data._transform2d->xform(*(const Vector2i *)p_b._data._mem)); - } - default: - _RETURN_FAIL; - } - } - - CASE_TYPE(math, OP_MULTIPLY, PROJECTION) { - switch (p_b.type) { - case VECTOR4: { - _RETURN(p_a._data._projection->xform(*(const Vector4 *)p_b._data._mem)); - } - case VECTOR3: { - _RETURN(p_a._data._projection->xform(*(const Vector3 *)p_b._data._mem)); - } - case PLANE: { - _RETURN(p_a._data._projection->xform(*(const Plane *)p_b._data._mem)); - } - case PROJECTION: { - _RETURN(p_a._data._projection->operator*(*(const Projection *)p_b._data._mem)); - } - default: - _RETURN_FAIL; - } - } - DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, INT, *, _int); DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, REAL, *, _real); - DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR2, *, Vector2); DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR2I, *, Vector2i); - DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR3, *, Vector3); - DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR3I, *, Vector3i); - DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR4, *, Vector4); - DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR4I, *, Vector4i); DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, COLOR, *, Color); CASE_TYPE(math, OP_MULTIPLY, NIL) CASE_TYPE(math, OP_MULTIPLY, BOOL) CASE_TYPE(math, OP_MULTIPLY, STRING) - CASE_TYPE(math, OP_MULTIPLY, RECT2) CASE_TYPE(math, OP_MULTIPLY, RECT2I) - CASE_TYPE(math, OP_MULTIPLY, PLANE) - CASE_TYPE(math, OP_MULTIPLY, AABB) CASE_TYPE(math, OP_MULTIPLY, OBJECT) CASE_TYPE(math, OP_MULTIPLY, STRING_NAME) CASE_TYPE(math, OP_MULTIPLY, DICTIONARY) @@ -1096,50 +810,21 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MULTIPLY, POOL_INT_ARRAY); CASE_TYPE(math, OP_MULTIPLY, POOL_REAL_ARRAY); CASE_TYPE(math, OP_MULTIPLY, POOL_STRING_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR2_ARRAY); CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR2I_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR3_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR3I_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR4_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR4I_ARRAY); CASE_TYPE(math, OP_MULTIPLY, POOL_COLOR_ARRAY); _RETURN_FAIL; } SWITCH_OP(math, OP_DIVIDE, p_a.type) { - CASE_TYPE(math, OP_DIVIDE, QUATERNION) { - if (p_b.type != REAL) - _RETURN_FAIL; -#ifdef DEBUG_ENABLED - if (p_b._data._real == 0) { - r_valid = false; - _RETURN("Division By Zero"); - } -#endif - _RETURN(*reinterpret_cast(p_a._data._mem) / p_b._data._real); - } - DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, INT, _int); DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, REAL, _real); - DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR2, /, Vector2); DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR2I, /, Vector2i); - DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR3, /, Vector3); - DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR3I, /, Vector3i); - DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR4, /, Vector4); - DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR4I, /, Vector4i); DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, COLOR, /, Color); CASE_TYPE(math, OP_DIVIDE, NIL) CASE_TYPE(math, OP_DIVIDE, BOOL) CASE_TYPE(math, OP_DIVIDE, STRING) - CASE_TYPE(math, OP_DIVIDE, RECT2) CASE_TYPE(math, OP_DIVIDE, RECT2I) - CASE_TYPE(math, OP_DIVIDE, PLANE) - CASE_TYPE(math, OP_DIVIDE, AABB) - CASE_TYPE(math, OP_DIVIDE, BASIS) - CASE_TYPE(math, OP_DIVIDE, TRANSFORM) - CASE_TYPE(math, OP_DIVIDE, TRANSFORM2D) - CASE_TYPE(math, OP_DIVIDE, PROJECTION) CASE_TYPE(math, OP_DIVIDE, OBJECT) CASE_TYPE(math, OP_DIVIDE, STRING_NAME) CASE_TYPE(math, OP_DIVIDE, DICTIONARY) @@ -1148,12 +833,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_DIVIDE, POOL_INT_ARRAY); CASE_TYPE(math, OP_DIVIDE, POOL_REAL_ARRAY); CASE_TYPE(math, OP_DIVIDE, POOL_STRING_ARRAY); - CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR2_ARRAY); CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR2I_ARRAY); - CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR3_ARRAY); - CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR3I_ARRAY); - CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR4_ARRAY); - CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR4I_ARRAY); CASE_TYPE(math, OP_DIVIDE, POOL_COLOR_ARRAY); _RETURN_FAIL; } @@ -1161,25 +841,12 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, SWITCH_OP(math, OP_POSITIVE, p_a.type) { DEFAULT_OP_NUM_POS(math, OP_POSITIVE, INT, _int); DEFAULT_OP_NUM_POS(math, OP_POSITIVE, REAL, _real); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR2, Vector2); DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR2I, Vector2i); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3, Vector3); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3I, Vector3i); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR4, Vector4); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR4I, Vector4i); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, PLANE, Plane); - DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, QUATERNION, Quaternion); CASE_TYPE(math, OP_POSITIVE, NIL) CASE_TYPE(math, OP_POSITIVE, BOOL) CASE_TYPE(math, OP_POSITIVE, STRING) - CASE_TYPE(math, OP_POSITIVE, RECT2) CASE_TYPE(math, OP_POSITIVE, RECT2I) - CASE_TYPE(math, OP_POSITIVE, AABB) - CASE_TYPE(math, OP_POSITIVE, BASIS) - CASE_TYPE(math, OP_POSITIVE, TRANSFORM) - CASE_TYPE(math, OP_POSITIVE, TRANSFORM2D) - CASE_TYPE(math, OP_POSITIVE, PROJECTION) CASE_TYPE(math, OP_POSITIVE, COLOR) CASE_TYPE(math, OP_POSITIVE, OBJECT) CASE_TYPE(math, OP_POSITIVE, STRING_NAME) @@ -1189,12 +856,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_POSITIVE, POOL_INT_ARRAY) CASE_TYPE(math, OP_POSITIVE, POOL_REAL_ARRAY) CASE_TYPE(math, OP_POSITIVE, POOL_STRING_ARRAY) - CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR2_ARRAY) CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR2I_ARRAY) - CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR3_ARRAY) - CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR3I_ARRAY) - CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR4_ARRAY) - CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR4I_ARRAY) CASE_TYPE(math, OP_POSITIVE, POOL_COLOR_ARRAY) _RETURN_FAIL; } @@ -1203,26 +865,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_NUM_NEG(math, OP_NEGATE, INT, _int); DEFAULT_OP_NUM_NEG(math, OP_NEGATE, REAL, _real); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2, Vector2); DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2I, Vector2i); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR3, Vector3); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR3I, Vector3i); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR4, Vector4); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR4I, Vector4i); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, PLANE, Plane); - DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, QUATERNION, Quaternion); DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, COLOR, Color); CASE_TYPE(math, OP_NEGATE, NIL) CASE_TYPE(math, OP_NEGATE, BOOL) CASE_TYPE(math, OP_NEGATE, STRING) - CASE_TYPE(math, OP_NEGATE, RECT2) CASE_TYPE(math, OP_NEGATE, RECT2I) - CASE_TYPE(math, OP_NEGATE, AABB) - CASE_TYPE(math, OP_NEGATE, BASIS) - CASE_TYPE(math, OP_NEGATE, TRANSFORM) - CASE_TYPE(math, OP_NEGATE, TRANSFORM2D) - CASE_TYPE(math, OP_NEGATE, PROJECTION) CASE_TYPE(math, OP_NEGATE, OBJECT) CASE_TYPE(math, OP_NEGATE, STRING_NAME) CASE_TYPE(math, OP_NEGATE, DICTIONARY) @@ -1231,12 +880,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_NEGATE, POOL_INT_ARRAY) CASE_TYPE(math, OP_NEGATE, POOL_REAL_ARRAY) CASE_TYPE(math, OP_NEGATE, POOL_STRING_ARRAY) - CASE_TYPE(math, OP_NEGATE, POOL_VECTOR2_ARRAY) CASE_TYPE(math, OP_NEGATE, POOL_VECTOR2I_ARRAY) - CASE_TYPE(math, OP_NEGATE, POOL_VECTOR3_ARRAY) - CASE_TYPE(math, OP_NEGATE, POOL_VECTOR3I_ARRAY) - CASE_TYPE(math, OP_NEGATE, POOL_VECTOR4_ARRAY) - CASE_TYPE(math, OP_NEGATE, POOL_VECTOR4I_ARRAY) CASE_TYPE(math, OP_NEGATE, POOL_COLOR_ARRAY) _RETURN_FAIL; } @@ -1276,21 +920,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MODULE, NIL) CASE_TYPE(math, OP_MODULE, BOOL) CASE_TYPE(math, OP_MODULE, REAL) - CASE_TYPE(math, OP_MODULE, RECT2) CASE_TYPE(math, OP_MODULE, RECT2I) - CASE_TYPE(math, OP_MODULE, VECTOR2) CASE_TYPE(math, OP_MODULE, VECTOR2I) - CASE_TYPE(math, OP_MODULE, VECTOR3) - CASE_TYPE(math, OP_MODULE, VECTOR3I) - CASE_TYPE(math, OP_MODULE, VECTOR4) - CASE_TYPE(math, OP_MODULE, VECTOR4I) - CASE_TYPE(math, OP_MODULE, PLANE) - CASE_TYPE(math, OP_MODULE, QUATERNION) - CASE_TYPE(math, OP_MODULE, AABB) - CASE_TYPE(math, OP_MODULE, BASIS) - CASE_TYPE(math, OP_MODULE, TRANSFORM) - CASE_TYPE(math, OP_MODULE, TRANSFORM2D) - CASE_TYPE(math, OP_MODULE, PROJECTION) CASE_TYPE(math, OP_MODULE, COLOR) CASE_TYPE(math, OP_MODULE, OBJECT) CASE_TYPE(math, OP_MODULE, STRING_NAME) @@ -1300,12 +931,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MODULE, POOL_INT_ARRAY) CASE_TYPE(math, OP_MODULE, POOL_REAL_ARRAY) CASE_TYPE(math, OP_MODULE, POOL_STRING_ARRAY) - CASE_TYPE(math, OP_MODULE, POOL_VECTOR2_ARRAY) CASE_TYPE(math, OP_MODULE, POOL_VECTOR2I_ARRAY) - CASE_TYPE(math, OP_MODULE, POOL_VECTOR3_ARRAY) - CASE_TYPE(math, OP_MODULE, POOL_VECTOR3I_ARRAY) - CASE_TYPE(math, OP_MODULE, POOL_VECTOR4_ARRAY) - CASE_TYPE(math, OP_MODULE, POOL_VECTOR4I_ARRAY) CASE_TYPE(math, OP_MODULE, POOL_COLOR_ARRAY) _RETURN_FAIL; } @@ -1428,50 +1054,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, void Variant::set_named(const StringName &p_index, const Variant &p_value, bool *r_valid) { bool valid = false; switch (type) { - case RECT2: { - if (p_value.type == Variant::VECTOR2) { - Rect2 *v = reinterpret_cast(_data._mem); - //scalar name - if (p_index == CoreStringNames::singleton->position) { - v->position = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->size) { - v->size = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->end) { - v->size = *reinterpret_cast(p_value._data._mem) - v->position; - valid = true; - } - } else if (p_value.type == Variant::VECTOR2I) { - Rect2 *v = reinterpret_cast(_data._mem); - //scalar name - if (p_index == CoreStringNames::singleton->position) { - v->position = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->size) { - v->size = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->end) { - v->size = *reinterpret_cast(p_value._data._mem) - v->position; - valid = true; - } - } - } break; case RECT2I: { - if (p_value.type == Variant::VECTOR2) { - Rect2i *v = reinterpret_cast(_data._mem); - //scalar name - if (p_index == CoreStringNames::singleton->position) { - v->position = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->size) { - v->size = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->end) { - v->size = *reinterpret_cast(p_value._data._mem) - v->position; - valid = true; - } - } else if (p_value.type == Variant::VECTOR2I) { + if (p_value.type == Variant::VECTOR2I) { Rect2i *v = reinterpret_cast(_data._mem); //scalar name if (p_index == CoreStringNames::singleton->position) { @@ -1486,28 +1070,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } } break; - case VECTOR2: { - if (p_value.type == Variant::INT) { - Vector2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Vector2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; - valid = true; - } - } - - } break; case VECTOR2I: { if (p_value.type == Variant::INT) { Vector2i *v = reinterpret_cast(_data._mem); @@ -1529,323 +1091,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } - } break; - case VECTOR3: { - if (p_value.type == Variant::INT) { - Vector3 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Vector3 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; - valid = true; - } - } - - } break; - case VECTOR3I: { - if (p_value.type == Variant::INT) { - Vector3i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Vector3i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; - valid = true; - } - } - - } break; - case VECTOR4: { - if (p_value.type == Variant::INT) { - Vector4 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Vector4 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._real; - valid = true; - } - } - - } break; - case VECTOR4I: { - if (p_value.type == Variant::INT) { - Vector4i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Vector4i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._real; - valid = true; - } - } - - } break; - case PLANE: { - if (p_value.type == Variant::INT) { - Plane *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->normal.x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->normal.y = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->normal.z = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->d) { - v->d = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Plane *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->normal.x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->normal.y = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->normal.z = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->d) { - v->d = p_value._data._real; - valid = true; - } - - } else if (p_value.type == Variant::VECTOR3) { - Plane *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->normal) { - v->normal = *reinterpret_cast(p_value._data._mem); - valid = true; - } - } - - } break; - case QUATERNION: { - if (p_value.type == Variant::INT) { - Quaternion *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._int; - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._int; - valid = true; - } - } else if (p_value.type == Variant::REAL) { - Quaternion *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._real; - valid = true; - } - } - - } break; // 10 - case AABB: { - if (p_value.type == Variant::VECTOR3) { - ::AABB *v = _data._aabb; - //scalar name - if (p_index == CoreStringNames::singleton->position) { - v->position = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->size) { - v->size = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->end) { - v->size = *reinterpret_cast(p_value._data._mem) - v->position; - valid = true; - } - } else if (p_value.type == Variant::VECTOR3I) { - ::AABB *v = _data._aabb; - //scalar name - if (p_index == CoreStringNames::singleton->position) { - v->position = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->size) { - v->size = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->end) { - v->size = Vector3(*reinterpret_cast(p_value._data._mem)) - v->position; - valid = true; - } - } - } break; - case BASIS: { - if (p_value.type == Variant::VECTOR3) { - Basis *v = _data._basis; - //scalar name - if (p_index == CoreStringNames::singleton->x) { - v->set_axis(0, *reinterpret_cast(p_value._data._mem)); - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->set_axis(1, *reinterpret_cast(p_value._data._mem)); - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->set_axis(2, *reinterpret_cast(p_value._data._mem)); - valid = true; - } - } else if (p_value.type == Variant::VECTOR3I) { - Basis *v = _data._basis; - //scalar name - if (p_index == CoreStringNames::singleton->x) { - v->set_axis(0, *reinterpret_cast(p_value._data._mem)); - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->set_axis(1, *reinterpret_cast(p_value._data._mem)); - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->set_axis(2, *reinterpret_cast(p_value._data._mem)); - valid = true; - } - } - } break; - case TRANSFORM: { - if (p_value.type == Variant::BASIS && p_index == CoreStringNames::singleton->basis) { - _data._transform->basis = *p_value._data._basis; - valid = true; - } else if (p_value.type == Variant::VECTOR3 && p_index == CoreStringNames::singleton->origin) { - _data._transform->origin = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_value.type == Variant::VECTOR3I && p_index == CoreStringNames::singleton->origin) { - _data._transform->origin = *reinterpret_cast(p_value._data._mem); - valid = true; - } - - } break; - case TRANSFORM2D: { - if (p_value.type == Variant::VECTOR2) { - Transform2D *v = _data._transform2d; - if (p_index == CoreStringNames::singleton->x) { - v->columns[0] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->columns[1] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->origin) { - v->columns[2] = *reinterpret_cast(p_value._data._mem); - valid = true; - } - } else if (p_value.type == Variant::VECTOR2I) { - Transform2D *v = _data._transform2d; - if (p_index == CoreStringNames::singleton->x) { - v->columns[0] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->columns[1] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->origin) { - v->columns[2] = *reinterpret_cast(p_value._data._mem); - valid = true; - } - } - - } break; - case PROJECTION: { - if (p_value.type == Variant::VECTOR4) { - Projection *v = _data._projection; - if (p_index == CoreStringNames::singleton->x) { - v->matrix[0] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->y) { - v->matrix[1] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->z) { - v->matrix[2] = *reinterpret_cast(p_value._data._mem); - valid = true; - } else if (p_index == CoreStringNames::singleton->w) { - v->matrix[3] = *reinterpret_cast(p_value._data._mem); - valid = true; - } - } - } break; case COLOR: { if (p_value.type == Variant::INT) { @@ -1950,17 +1195,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { *r_valid = true; } switch (type) { - case RECT2: { - const Rect2 *v = reinterpret_cast(_data._mem); - //scalar name - if (p_index == CoreStringNames::singleton->position) { - return v->position; - } else if (p_index == CoreStringNames::singleton->size) { - return v->size; - } else if (p_index == CoreStringNames::singleton->end) { - return v->size + v->position; - } - } break; case RECT2I: { const Rect2i *v = reinterpret_cast(_data._mem); //scalar name @@ -1972,15 +1206,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { return v->size + v->position; } } break; - case VECTOR2: { - const Vector2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->y; - } - - } break; case VECTOR2I: { const Vector2i *v = reinterpret_cast(_data._mem); if (p_index == CoreStringNames::singleton->x) { @@ -1989,137 +1214,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { return v->y; } - } break; - case VECTOR3: { - const Vector3 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - return v->z; - } - - } break; - case VECTOR3I: { - const Vector3i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - return v->z; - } - - } break; - case VECTOR4: { - const Vector4 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - return v->z; - } else if (p_index == CoreStringNames::singleton->w) { - return v->w; - } - - } break; - case VECTOR4I: { - const Vector4i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - return v->z; - } else if (p_index == CoreStringNames::singleton->w) { - return v->w; - } - - } break; - case PLANE: { - const Plane *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->normal.x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->normal.y; - } else if (p_index == CoreStringNames::singleton->z) { - return v->normal.z; - } else if (p_index == CoreStringNames::singleton->d) { - return v->d; - } else if (p_index == CoreStringNames::singleton->normal) { - return v->normal; - } - - } break; - case QUATERNION: { - const Quaternion *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - return v->z; - } else if (p_index == CoreStringNames::singleton->w) { - return v->w; - } - - } break; // 10 - case AABB: { - const ::AABB *v = _data._aabb; - //scalar name - if (p_index == CoreStringNames::singleton->position) { - return v->position; - } else if (p_index == CoreStringNames::singleton->size) { - return v->size; - } else if (p_index == CoreStringNames::singleton->end) { - return v->size + v->position; - } - } break; - case BASIS: { - const Basis *v = _data._basis; - //scalar name - if (p_index == CoreStringNames::singleton->x) { - return v->get_axis(0); - } else if (p_index == CoreStringNames::singleton->y) { - return v->get_axis(1); - } else if (p_index == CoreStringNames::singleton->z) { - return v->get_axis(2); - } - - } break; - case TRANSFORM: { - if (p_index == CoreStringNames::singleton->basis) { - return _data._transform->basis; - } else if (p_index == CoreStringNames::singleton->origin) { - return _data._transform->origin; - } - - } break; - case TRANSFORM2D: { - const Transform2D *v = _data._transform2d; - if (p_index == CoreStringNames::singleton->x) { - return v->columns[0]; - } else if (p_index == CoreStringNames::singleton->y) { - return v->columns[1]; - } else if (p_index == CoreStringNames::singleton->origin) { - return v->columns[2]; - } - - } break; - case PROJECTION: { - const Projection *v = _data._projection; - if (p_index == CoreStringNames::singleton->x) { - return v->matrix[0]; - } else if (p_index == CoreStringNames::singleton->y) { - return v->matrix[1]; - } else if (p_index == CoreStringNames::singleton->z) { - return v->matrix[2]; - } else if (p_index == CoreStringNames::singleton->w) { - return v->matrix[3]; - } - } break; case COLOR: { const Color *v = reinterpret_cast(_data._mem); @@ -2270,50 +1364,8 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } break; - case RECT2: { - if (p_value.type == Variant::VECTOR2 || p_value.type == Variant::VECTOR2I) { - if (p_index.get_type() == Variant::STRING) { - //scalar name - - const String *str = reinterpret_cast(p_index._data._mem); - Rect2 *v = reinterpret_cast(_data._mem); - if (*str == "position") { - valid = true; - v->position = p_value; - return; - } else if (*str == "size") { - valid = true; - v->size = p_value; - return; - } else if (*str == "end") { - valid = true; - v->size = Vector2(p_value) - v->position; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Rect2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->position) { - valid = true; - v->position = p_value; - return; - } else if (p_index == CoreStringNames::singleton->size) { - valid = true; - v->size = p_value; - return; - } else if (p_index == CoreStringNames::singleton->end) { - valid = true; - v->size = Vector2(p_value) - v->position; - return; - } - } - } else { - return; - } - } break; //7 case RECT2I: { - if (p_value.type == Variant::VECTOR2 || p_value.type == Variant::VECTOR2I) { + if (p_value.type == Variant::VECTOR2I) { if (p_index.get_type() == Variant::STRING) { //scalar name @@ -2330,7 +1382,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } else if (*str == "end") { valid = true; //TODO fix - v->size = Vector2i(Vector2(p_value)) - v->position; + v->size = Vector2i(p_value) - v->position; return; } } else if (p_index.get_type() == Variant::STRING_NAME) { @@ -2347,7 +1399,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } else if (p_index == CoreStringNames::singleton->end) { valid = true; - v->size = Vector2(p_value) - v->position; + v->size = Vector2i(p_value) - v->position; return; } } @@ -2355,53 +1407,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } } break; - case VECTOR2: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - // scalar index - int idx = p_index; - - if (idx < 0) { - idx += 2; - } - if (idx >= 0 && idx < 2) { - Vector2 *v = reinterpret_cast(_data._mem); - valid = true; - (*v)[idx] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - - const String *str = reinterpret_cast(p_index._data._mem); - Vector2 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - v->x = p_value; - return; - } else if (*str == "y") { - valid = true; - v->y = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Vector2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->y = p_value; - return; - } - } - } break; // 5 case VECTOR2I: { if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { return; @@ -2450,654 +1455,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; //6 - - case VECTOR3: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 3; - } - if (idx >= 0 && idx < 3) { - Vector3 *v = reinterpret_cast(_data._mem); - valid = true; - (*v)[idx] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - Vector3 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - v->x = p_value; - return; - } else if (*str == "y") { - valid = true; - v->y = p_value; - return; - } else if (*str == "z") { - valid = true; - v->z = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Vector3 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->y = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->z = p_value; - return; - } - } - - } break; - case VECTOR3I: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 3; - } - if (idx >= 0 && idx < 3) { - Vector3i *v = reinterpret_cast(_data._mem); - valid = true; - (*v)[idx] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - Vector3 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - v->x = p_value; - return; - } else if (*str == "y") { - valid = true; - v->y = p_value; - return; - } else if (*str == "z") { - valid = true; - v->z = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Vector3i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->y = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->z = p_value; - return; - } - } - - } break; - case VECTOR4: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 4; - } - if (idx >= 0 && idx < 4) { - Vector4 *v = reinterpret_cast(_data._mem); - valid = true; - (*v)[idx] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - Vector4 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - v->x = p_value; - return; - } else if (*str == "y") { - valid = true; - v->y = p_value; - return; - } else if (*str == "z") { - valid = true; - v->z = p_value; - return; - } else if (*str == "w") { - valid = true; - v->w = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Vector4 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->y = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->z = p_value; - return; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - v->w = p_value; - return; - } - } - } break; - case VECTOR4I: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 4; - } - if (idx >= 0 && idx < 4) { - Vector4i *v = reinterpret_cast(_data._mem); - valid = true; - (*v)[idx] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - Vector4 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - v->x = p_value; - return; - } else if (*str == "y") { - valid = true; - v->y = p_value; - return; - } else if (*str == "z") { - valid = true; - v->z = p_value; - return; - } else if (*str == "w") { - valid = true; - v->w = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Vector4i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->y = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->z = p_value; - return; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - v->w = p_value; - return; - } - } - - } break; - case PLANE: { - if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - Plane *v = reinterpret_cast(_data._mem); - if (*str == "x") { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - valid = true; - v->normal.x = p_value; - return; - } else if (*str == "y") { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - valid = true; - v->normal.y = p_value; - return; - } else if (*str == "z") { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - valid = true; - v->normal.z = p_value; - return; - } else if (*str == "normal") { - if (p_value.type != Variant::VECTOR3) { - return; - } - - valid = true; - v->normal = p_value; - return; - } else if (*str == "d") { - valid = true; - v->d = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Plane *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - valid = true; - v->normal.x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - valid = true; - v->normal.y = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - valid = true; - v->normal.z = p_value; - return; - } else if (p_index == CoreStringNames::singleton->normal) { - if (p_value.type != Variant::VECTOR3) { - return; - } - - valid = true; - v->normal = p_value; - return; - } else if (p_index == CoreStringNames::singleton->d) { - valid = true; - v->d = p_value; - return; - } - } - - } break; - case QUATERNION: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { - return; - } - - if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast(p_index._data._mem); - Quaternion *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - v->x = p_value; - return; - } else if (*str == "y") { - valid = true; - v->y = p_value; - return; - } else if (*str == "z") { - valid = true; - v->z = p_value; - return; - } else if (*str == "w") { - valid = true; - v->w = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - Quaternion *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->x = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->y = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->z = p_value; - return; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - v->w = p_value; - return; - } - } - - } break; // 10 - case AABB: { - if (p_value.type != Variant::VECTOR3) { - return; - } - - if (p_index.get_type() == Variant::STRING) { - //scalar name - - const String *str = reinterpret_cast(p_index._data._mem); - ::AABB *v = _data._aabb; - if (*str == "position") { - valid = true; - v->position = p_value; - return; - } else if (*str == "size") { - valid = true; - v->size = p_value; - return; - } else if (*str == "end") { - valid = true; - v->size = Vector3(p_value) - v->position; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - ::AABB *v = _data._aabb; - if (p_index == CoreStringNames::singleton->position) { - valid = true; - v->position = p_value; - return; - } else if (p_index == CoreStringNames::singleton->size) { - valid = true; - v->size = p_value; - return; - } else if (p_index == CoreStringNames::singleton->end) { - valid = true; - v->size = Vector3(p_value) - v->position; - return; - } - } - } break; - case BASIS: { - if (p_value.type != Variant::VECTOR3) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - int index = p_index; - - if (index < 0) { - index += 3; - } - if (index >= 0 && index < 3) { - Basis *v = _data._basis; - - valid = true; - v->set_axis(index, p_value); - return; - } - } else if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast(p_index._data._mem); - Basis *v = _data._basis; - - if (*str == "x") { - valid = true; - v->set_axis(0, p_value); - return; - } else if (*str == "y") { - valid = true; - v->set_axis(1, p_value); - return; - } else if (*str == "z") { - valid = true; - v->set_axis(2, p_value); - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - Basis *v = _data._basis; - - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->set_axis(0, p_value); - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->set_axis(1, p_value); - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->set_axis(2, p_value); - return; - } - } - - } break; - case TRANSFORM: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - if (p_value.type != Variant::VECTOR3) { - return; - } - - int index = p_index; - - if (index < 0) { - index += 4; - } - if (index >= 0 && index < 4) { - Transform *v = _data._transform; - valid = true; - if (index == 3) { - v->origin = p_value; - } else { - v->basis.set_axis(index, p_value); - } - return; - } - } else if (p_index.get_type() == Variant::STRING) { - Transform *v = _data._transform; - const String *str = reinterpret_cast(p_index._data._mem); - - if (*str == "basis") { - if (p_value.type != Variant::BASIS) { - return; - } - valid = true; - v->basis = p_value; - return; - } - if (*str == "origin") { - if (p_value.type != Variant::VECTOR3) { - return; - } - valid = true; - v->origin = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - Transform *v = _data._transform; - - if (p_index == CoreStringNames::singleton->basis) { - if (p_value.type != Variant::BASIS) { - return; - } - valid = true; - v->basis = p_value; - return; - } - if (p_index == CoreStringNames::singleton->origin) { - if (p_value.type != Variant::VECTOR3) { - return; - } - valid = true; - v->origin = p_value; - return; - } - } - - } break; - case TRANSFORM2D: { - if (p_value.type != Variant::VECTOR2 || p_value.get_type() != Variant::VECTOR2I) { - return; - } - - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - int index = p_index; - - if (index < 0) { - index += 3; - } - if (index >= 0 && index < 3) { - Transform2D *v = _data._transform2d; - - valid = true; - v->columns[index] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - Transform2D *v = _data._transform2d; - if (*str == "x") { - valid = true; - v->columns[0] = p_value; - return; - } else if (*str == "y") { - valid = true; - v->columns[1] = p_value; - return; - } else if (*str == "origin") { - valid = true; - v->columns[2] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - Transform2D *v = _data._transform2d; - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->columns[0] = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->columns[1] = p_value; - return; - } else if (p_index == CoreStringNames::singleton->origin) { - valid = true; - v->columns[2] = p_value; - return; - } - } - - } break; - case PROJECTION: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - if (p_value.type != Variant::VECTOR4) { - return; - } - - int index = p_index; - - if (index < 0) { - index += 4; - } - if (index >= 0 && index < 4) { - Projection *v = _data._projection; - valid = true; - v->matrix[index] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING) { - Projection *v = _data._projection; - const String *str = reinterpret_cast(p_index._data._mem); - - if (p_value.type != Variant::VECTOR4) { - return; - } - - if (*str == "x") { - valid = true; - v->matrix[0] = p_value; - return; - } else if (*str == "y") { - valid = true; - v->matrix[1] = p_value; - return; - } else if (*str == "z") { - valid = true; - v->matrix[2] = p_value; - return; - } else if (*str == "w") { - valid = true; - v->matrix[3] = p_value; - return; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - Projection *v = _data._projection; - - if (p_value.type != Variant::VECTOR4) { - return; - } - - if (p_index == CoreStringNames::singleton->x) { - valid = true; - v->matrix[0] = p_value; - return; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - v->matrix[1] = p_value; - return; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - v->matrix[2] = p_value; - return; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - v->matrix[3] = p_value; - return; - } - } - - } break; case COLOR: { if (p_value.type != Variant::INT && p_value.type != Variant::REAL) { return; @@ -3243,8 +1600,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) DEFAULT_OP_DVECTOR_SET(POOL_INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT) DEFAULT_OP_DVECTOR_SET(POOL_REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT) DEFAULT_OP_DVECTOR_SET(POOL_STRING_ARRAY, String, p_value.type != Variant::STRING) - DEFAULT_OP_DVECTOR_SET(POOL_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25 - DEFAULT_OP_DVECTOR_SET(POOL_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3) + DEFAULT_OP_DVECTOR_SET(POOL_VECTOR2I_ARRAY, Vector2i, p_value.type != Variant::VECTOR2I) // 25 DEFAULT_OP_DVECTOR_SET(POOL_COLOR_ARRAY, Color, p_value.type != Variant::COLOR) default: return; @@ -3287,38 +1643,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; - case RECT2: { - if (p_index.get_type() == Variant::STRING) { - //scalar name - - const String *str = reinterpret_cast(p_index._data._mem); - const Rect2 *v = reinterpret_cast(_data._mem); - if (*str == "position") { - valid = true; - return v->position; - } else if (*str == "size") { - valid = true; - return v->size; - } else if (*str == "end") { - valid = true; - return v->size + v->position; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Rect2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->position) { - valid = true; - return v->position; - } else if (p_index == CoreStringNames::singleton->size) { - valid = true; - return v->size; - } else if (p_index == CoreStringNames::singleton->end) { - valid = true; - return v->size + v->position; - } - } - } break; case RECT2I: { if (p_index.get_type() == Variant::STRING) { //scalar name @@ -3351,44 +1675,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } } break; - case VECTOR2: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - // scalar index - int idx = p_index; - if (idx < 0) { - idx += 2; - } - if (idx >= 0 && idx < 2) { - const Vector2 *v = reinterpret_cast(_data._mem); - valid = true; - return (*v)[idx]; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - - const String *str = reinterpret_cast(p_index._data._mem); - const Vector2 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->x; - } else if (*str == "y") { - valid = true; - return v->y; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Vector2 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->y; - } - } - - } break; // 5 case VECTOR2I: { if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { // scalar index @@ -3427,470 +1713,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; // 6 - case VECTOR3: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 3; - } - if (idx >= 0 && idx < 3) { - const Vector3 *v = reinterpret_cast(_data._mem); - valid = true; - return (*v)[idx]; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - const Vector3 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->x; - } else if (*str == "y") { - valid = true; - return v->y; - } else if (*str == "z") { - valid = true; - return v->z; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Vector3 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->z; - } - } - - } break; - case VECTOR3I: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 3; - } - if (idx >= 0 && idx < 3) { - const Vector3i *v = reinterpret_cast(_data._mem); - valid = true; - return (*v)[idx]; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - const Vector3i *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->x; - } else if (*str == "y") { - valid = true; - return v->y; - } else if (*str == "z") { - valid = true; - return v->z; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Vector3i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->z; - } - } - - } break; - case VECTOR4: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 4; - } - if (idx >= 0 && idx < 4) { - const Vector4 *v = reinterpret_cast(_data._mem); - valid = true; - return (*v)[idx]; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - const Vector4 *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->x; - } else if (*str == "y") { - valid = true; - return v->y; - } else if (*str == "z") { - valid = true; - return v->z; - } else if (*str == "w") { - valid = true; - return v->w; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Vector4 *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->z; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - return v->w; - } - } - - } break; - case VECTOR4I: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - //scalar index - int idx = p_index; - if (idx < 0) { - idx += 4; - } - if (idx >= 0 && idx < 4) { - const Vector4i *v = reinterpret_cast(_data._mem); - valid = true; - return (*v)[idx]; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - const Vector4i *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->x; - } else if (*str == "y") { - valid = true; - return v->y; - } else if (*str == "z") { - valid = true; - return v->z; - } else if (*str == "w") { - valid = true; - return v->w; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - const Vector4i *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->z; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - return v->w; - } - } - - } break; - case PLANE: { - if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - const Plane *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->normal.x; - } else if (*str == "y") { - valid = true; - return v->normal.y; - } else if (*str == "z") { - valid = true; - return v->normal.z; - } else if (*str == "normal") { - valid = true; - return v->normal; - } else if (*str == "d") { - valid = true; - return v->d; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Plane *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->normal.x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->normal.y; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->normal.z; - } else if (p_index == CoreStringNames::singleton->normal) { - valid = true; - return v->normal; - } else if (p_index == CoreStringNames::singleton->d) { - valid = true; - return v->d; - } - } - - } break; - case QUATERNION: { - if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast(p_index._data._mem); - const Quaternion *v = reinterpret_cast(_data._mem); - if (*str == "x") { - valid = true; - return v->x; - } else if (*str == "y") { - valid = true; - return v->y; - } else if (*str == "z") { - valid = true; - return v->z; - } else if (*str == "w") { - valid = true; - return v->w; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - const Quaternion *v = reinterpret_cast(_data._mem); - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->x; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->y; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->z; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - return v->w; - } - } - - } break; // 10 - case AABB: { - if (p_index.get_type() == Variant::STRING) { - //scalar name - - const String *str = reinterpret_cast(p_index._data._mem); - const ::AABB *v = _data._aabb; - if (*str == "position") { - valid = true; - return v->position; - } else if (*str == "size") { - valid = true; - return v->size; - } else if (*str == "end") { - valid = true; - return v->size + v->position; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const ::AABB *v = _data._aabb; - if (p_index == CoreStringNames::singleton->position) { - valid = true; - return v->position; - } else if (p_index == CoreStringNames::singleton->size) { - valid = true; - return v->size; - } else if (p_index == CoreStringNames::singleton->end) { - valid = true; - return v->size + v->position; - } - } - } break; - case BASIS: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - int index = p_index; - if (index < 0) { - index += 3; - } - if (index >= 0 && index < 3) { - const Basis *v = _data._basis; - - valid = true; - return v->get_axis(index); - } - } else if (p_index.get_type() == Variant::STRING) { - const String *str = reinterpret_cast(p_index._data._mem); - const Basis *v = _data._basis; - - if (*str == "x") { - valid = true; - return v->get_axis(0); - } else if (*str == "y") { - valid = true; - return v->get_axis(1); - } else if (*str == "z") { - valid = true; - return v->get_axis(2); - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - const Basis *v = _data._basis; - - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->get_axis(0); - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->get_axis(1); - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->get_axis(2); - } - } - - } break; - case TRANSFORM: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - int index = p_index; - if (index < 0) { - index += 4; - } - if (index >= 0 && index < 4) { - const Transform *v = _data._transform; - valid = true; - return index == 3 ? v->origin : v->basis.get_axis(index); - } - } else if (p_index.get_type() == Variant::STRING) { - const Transform *v = _data._transform; - const String *str = reinterpret_cast(p_index._data._mem); - - if (*str == "basis") { - valid = true; - return v->basis; - } - if (*str == "origin") { - valid = true; - return v->origin; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - const Transform *v = _data._transform; - - if (p_index == CoreStringNames::singleton->basis) { - valid = true; - return v->basis; - } - if (p_index == CoreStringNames::singleton->origin) { - valid = true; - return v->origin; - } - } - - } break; - case TRANSFORM2D: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - int index = p_index; - - if (index < 0) { - index += 3; - } - if (index >= 0 && index < 3) { - const Transform2D *v = _data._transform2d; - - valid = true; - return v->columns[index]; - } - } else if (p_index.get_type() == Variant::STRING) { - //scalar name - const String *str = reinterpret_cast(p_index._data._mem); - const Transform2D *v = _data._transform2d; - if (*str == "x") { - valid = true; - return v->columns[0]; - } else if (*str == "y") { - valid = true; - return v->columns[1]; - } else if (*str == "origin") { - valid = true; - return v->columns[2]; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - //scalar name - - const Transform2D *v = _data._transform2d; - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->columns[0]; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->columns[1]; - } else if (p_index == CoreStringNames::singleton->origin) { - valid = true; - return v->columns[2]; - } - } - - } break; - case PROJECTION: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { - int index = p_index; - if (index < 0) { - index += 4; - } - if (index >= 0 && index < 4) { - const Projection *v = _data._projection; - valid = true; - return v->matrix[index]; - } - } else if (p_index.get_type() == Variant::STRING) { - const Projection *v = _data._projection; - const String *str = reinterpret_cast(p_index._data._mem); - - if (*str == "x") { - valid = true; - return v->matrix[0]; - } else if (*str == "y") { - valid = true; - return v->matrix[1]; - } else if (*str == "z") { - valid = true; - return v->matrix[2]; - } else if (*str == "w") { - valid = true; - return v->matrix[3]; - } - } else if (p_index.get_type() == Variant::STRING_NAME) { - const Projection *v = _data._projection; - - if (p_index == CoreStringNames::singleton->x) { - valid = true; - return v->matrix[0]; - } else if (p_index == CoreStringNames::singleton->y) { - valid = true; - return v->matrix[1]; - } else if (p_index == CoreStringNames::singleton->z) { - valid = true; - return v->matrix[2]; - } else if (p_index == CoreStringNames::singleton->w) { - valid = true; - return v->matrix[3]; - } - } - - } break; case COLOR: { if (p_index.get_type() == Variant::STRING) { const String *str = reinterpret_cast(p_index._data._mem); @@ -4008,12 +1830,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { DEFAULT_OP_DVECTOR_GET(POOL_INT_ARRAY, int) DEFAULT_OP_DVECTOR_GET(POOL_REAL_ARRAY, real_t) DEFAULT_OP_DVECTOR_GET(POOL_STRING_ARRAY, String) - DEFAULT_OP_DVECTOR_GET(POOL_VECTOR2_ARRAY, Vector2) DEFAULT_OP_DVECTOR_GET(POOL_VECTOR2I_ARRAY, Vector2i) - DEFAULT_OP_DVECTOR_GET(POOL_VECTOR3_ARRAY, Vector3) - DEFAULT_OP_DVECTOR_GET(POOL_VECTOR3I_ARRAY, Vector3i) - DEFAULT_OP_DVECTOR_GET(POOL_VECTOR4_ARRAY, Vector4) - DEFAULT_OP_DVECTOR_GET(POOL_VECTOR4I_ARRAY, Vector4i) DEFAULT_OP_DVECTOR_GET(POOL_COLOR_ARRAY, Color) default: return Variant(); @@ -4147,25 +1964,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } } break; //25 - case POOL_VECTOR2_ARRAY: { - if (p_index.get_type() == Variant::VECTOR2) { - Vector2 index = p_index; - const PoolVector *arr = reinterpret_cast *>(_data._mem); - - int l = arr->size(); - if (l) { - PoolVector::Read r = arr->read(); - for (int i = 0; i < l; i++) { - if (r[i] == index) { - return true; - } - } - } - - return false; - } - - } break; case POOL_VECTOR2I_ARRAY: { if (p_index.get_type() == Variant::VECTOR2I) { Vector2i index = p_index; @@ -4184,82 +1982,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { return false; } - } break; - case POOL_VECTOR3_ARRAY: { - if (p_index.get_type() == Variant::VECTOR3) { - Vector3 index = p_index; - const PoolVector *arr = reinterpret_cast *>(_data._mem); - - int l = arr->size(); - if (l) { - PoolVector::Read r = arr->read(); - for (int i = 0; i < l; i++) { - if (r[i] == index) { - return true; - } - } - } - - return false; - } - - } break; - case POOL_VECTOR3I_ARRAY: { - if (p_index.get_type() == Variant::VECTOR3I) { - Vector3i index = p_index; - const PoolVector *arr = reinterpret_cast *>(_data._mem); - - int l = arr->size(); - if (l) { - PoolVector::Read r = arr->read(); - for (int i = 0; i < l; i++) { - if (r[i] == index) { - return true; - } - } - } - - return false; - } - - } break; - case POOL_VECTOR4_ARRAY: { - if (p_index.get_type() == Variant::VECTOR4) { - Vector4 index = p_index; - const PoolVector *arr = reinterpret_cast *>(_data._mem); - - int l = arr->size(); - if (l) { - PoolVector::Read r = arr->read(); - for (int i = 0; i < l; i++) { - if (r[i] == index) { - return true; - } - } - } - - return false; - } - - } break; - case POOL_VECTOR4I_ARRAY: { - if (p_index.get_type() == Variant::VECTOR4I) { - Vector4i index = p_index; - const PoolVector *arr = reinterpret_cast *>(_data._mem); - - int l = arr->size(); - if (l) { - PoolVector::Read r = arr->read(); - for (int i = 0; i < l; i++) { - if (r[i] == index) { - return true; - } - } - } - - return false; - } - } break; case POOL_COLOR_ARRAY: { if (p_index.get_type() == Variant::COLOR) { @@ -4300,14 +2022,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { r_iter = 0; return _data._real > 0.0; } break; - case VECTOR2: { - int64_t from = reinterpret_cast(_data._mem)->x; - int64_t to = reinterpret_cast(_data._mem)->y; - - r_iter = from; - - return from < to; - } break; case VECTOR2I: { int64_t from = reinterpret_cast(_data._mem)->x; int64_t to = reinterpret_cast(_data._mem)->y; @@ -4316,38 +2030,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return from < to; } break; - case VECTOR3: { - int64_t from = reinterpret_cast(_data._mem)->x; - int64_t to = reinterpret_cast(_data._mem)->y; - int64_t step = reinterpret_cast(_data._mem)->z; - - r_iter = from; - - if (from == to) { - return false; - } else if (from < to) { - return step > 0; - } else { - return step < 0; - } - //return true; - } break; - case VECTOR3I: { - int64_t from = reinterpret_cast(_data._mem)->x; - int64_t to = reinterpret_cast(_data._mem)->y; - int64_t step = reinterpret_cast(_data._mem)->z; - - r_iter = from; - - if (from == to) { - return false; - } else if (from < to) { - return step > 0; - } else { - return step < 0; - } - //return true; - } break; case STRING: { const String *str = reinterpret_cast(_data._mem); if (str->empty()) { @@ -4410,14 +2092,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { r_iter = 0; return true; } break; - case POOL_VECTOR2_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - if (arr->size() == 0) { - return false; - } - r_iter = 0; - return true; - } break; case POOL_VECTOR2I_ARRAY: { const PoolVector *arr = reinterpret_cast *>(_data._mem); if (arr->size() == 0) { @@ -4426,38 +2100,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { r_iter = 0; return true; } break; - case POOL_VECTOR3_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - if (arr->size() == 0) { - return false; - } - r_iter = 0; - return true; - } break; - case POOL_VECTOR3I_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - if (arr->size() == 0) { - return false; - } - r_iter = 0; - return true; - } break; - case POOL_VECTOR4_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - if (arr->size() == 0) { - return false; - } - r_iter = 0; - return true; - } break; - case POOL_VECTOR4I_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - if (arr->size() == 0) { - return false; - } - r_iter = 0; - return true; - } break; case POOL_COLOR_ARRAY: { const PoolVector *arr = reinterpret_cast *>(_data._mem); if (arr->size() == 0) { @@ -4495,19 +2137,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { r_iter = idx; return true; } break; - case VECTOR2: { - int64_t to = reinterpret_cast(_data._mem)->y; - - int64_t idx = r_iter; - idx++; - - if (idx >= to) { - return false; - } - - r_iter = idx; - return true; - } break; case VECTOR2I: { int64_t to = reinterpret_cast(_data._mem)->y; @@ -4521,42 +2150,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { r_iter = idx; return true; } break; - case VECTOR3: { - int64_t to = reinterpret_cast(_data._mem)->y; - int64_t step = reinterpret_cast(_data._mem)->z; - - int64_t idx = r_iter; - idx += step; - - if (step < 0 && idx <= to) { - return false; - } - - if (step > 0 && idx >= to) { - return false; - } - - r_iter = idx; - return true; - } break; - case VECTOR3I: { - int64_t to = reinterpret_cast(_data._mem)->y; - int64_t step = reinterpret_cast(_data._mem)->z; - - int64_t idx = r_iter; - idx += step; - - if (step < 0 && idx <= to) { - return false; - } - - if (step > 0 && idx >= to) { - return false; - } - - r_iter = idx; - return true; - } break; case STRING: { const String *str = reinterpret_cast(_data._mem); int idx = r_iter; @@ -4631,16 +2224,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { r_iter = idx; return true; } break; - case POOL_VECTOR2_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; - idx++; - if (idx >= arr->size()) { - return false; - } - r_iter = idx; - return true; - } break; case POOL_VECTOR2I_ARRAY: { const PoolVector *arr = reinterpret_cast *>(_data._mem); int idx = r_iter; @@ -4651,46 +2234,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { r_iter = idx; return true; } break; - case POOL_VECTOR3_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; - idx++; - if (idx >= arr->size()) { - return false; - } - r_iter = idx; - return true; - } break; - case POOL_VECTOR3I_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; - idx++; - if (idx >= arr->size()) { - return false; - } - r_iter = idx; - return true; - } break; - case POOL_VECTOR4_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; - idx++; - if (idx >= arr->size()) { - return false; - } - r_iter = idx; - return true; - } break; - case POOL_VECTOR4I_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; - idx++; - if (idx >= arr->size()) { - return false; - } - r_iter = idx; - return true; - } break; case POOL_COLOR_ARRAY: { const PoolVector *arr = reinterpret_cast *>(_data._mem); int idx = r_iter; @@ -4718,18 +2261,9 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { case REAL: { return r_iter; } break; - case VECTOR2: { - return r_iter; - } break; case VECTOR2I: { return r_iter; } break; - case VECTOR3: { - return r_iter; - } break; - case VECTOR3I: { - return r_iter; - } break; case STRING: { const String *str = reinterpret_cast(_data._mem); return str->substr(r_iter, 1); @@ -4790,17 +2324,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { r_valid = false; return Variant(); } -#endif - return arr->get(idx); - } break; - case POOL_VECTOR2_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; -#ifdef DEBUG_ENABLED - if (idx < 0 || idx >= arr->size()) { - r_valid = false; - return Variant(); - } #endif return arr->get(idx); } break; @@ -4812,50 +2335,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { r_valid = false; return Variant(); } -#endif - return arr->get(idx); - } break; - case POOL_VECTOR3_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; -#ifdef DEBUG_ENABLED - if (idx < 0 || idx >= arr->size()) { - r_valid = false; - return Variant(); - } -#endif - return arr->get(idx); - } break; - case POOL_VECTOR3I_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; -#ifdef DEBUG_ENABLED - if (idx < 0 || idx >= arr->size()) { - r_valid = false; - return Variant(); - } -#endif - return arr->get(idx); - } break; - case POOL_VECTOR4_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; -#ifdef DEBUG_ENABLED - if (idx < 0 || idx >= arr->size()) { - r_valid = false; - return Variant(); - } -#endif - return arr->get(idx); - } break; - case POOL_VECTOR4I_ARRAY: { - const PoolVector *arr = reinterpret_cast *>(_data._mem); - int idx = r_iter; -#ifdef DEBUG_ENABLED - if (idx < 0 || idx >= arr->size()) { - r_valid = false; - return Variant(); - } #endif return arr->get(idx); } break; @@ -4922,12 +2401,6 @@ void Variant::sub(const Variant &a, const Variant &b, Variant &r_dst) { r_dst = ra - rb; } return; - case RECT2: { - const Rect2 *ra = reinterpret_cast(a._data._mem); - const Rect2 *rb = reinterpret_cast(b._data._mem); - r_dst = Rect2(ra->position - rb->position, ra->size - rb->size); - } - return; case RECT2I: { const Rect2i *ra = reinterpret_cast(a._data._mem); const Rect2i *rb = reinterpret_cast(b._data._mem); @@ -4944,10 +2417,6 @@ void Variant::sub(const Variant &a, const Variant &b, Variant &r_dst) { r_dst = Rect2i(int32_t(vax - vbx), int32_t(vay - vby), int32_t(vcx - vdx), int32_t(vcy - vdy)); } return; - case VECTOR2: { - r_dst = *reinterpret_cast(a._data._mem) - *reinterpret_cast(b._data._mem); - } - return; case VECTOR2I: { int32_t vax = reinterpret_cast(a._data._mem)->x; int32_t vbx = reinterpret_cast(b._data._mem)->x; @@ -4956,49 +2425,6 @@ void Variant::sub(const Variant &a, const Variant &b, Variant &r_dst) { r_dst = Vector2i(int32_t(vax - vbx), int32_t(vay - vby)); } return; - case VECTOR3: { - r_dst = *reinterpret_cast(a._data._mem) - *reinterpret_cast(b._data._mem); - } - return; - case VECTOR3I: { - int32_t vax = reinterpret_cast(a._data._mem)->x; - int32_t vbx = reinterpret_cast(b._data._mem)->x; - int32_t vay = reinterpret_cast(a._data._mem)->y; - int32_t vby = reinterpret_cast(b._data._mem)->y; - int32_t vaz = reinterpret_cast(a._data._mem)->z; - int32_t vbz = reinterpret_cast(b._data._mem)->z; - r_dst = Vector3i(int32_t(vax - vbx), int32_t(vay - vby), int32_t(vaz - vbz)); - } - return; - case VECTOR4: { - r_dst = *reinterpret_cast(a._data._mem) - *reinterpret_cast(b._data._mem); - } - return; - case VECTOR4I: { - int32_t vax = reinterpret_cast(a._data._mem)->x; - int32_t vbx = reinterpret_cast(b._data._mem)->x; - int32_t vay = reinterpret_cast(a._data._mem)->y; - int32_t vaw = reinterpret_cast(a._data._mem)->w; - int32_t vby = reinterpret_cast(b._data._mem)->y; - int32_t vaz = reinterpret_cast(a._data._mem)->z; - int32_t vbz = reinterpret_cast(b._data._mem)->z; - int32_t vbw = reinterpret_cast(b._data._mem)->w; - r_dst = Vector4i(int32_t(vax - vbx), int32_t(vay - vby), int32_t(vaz - vbz), int32_t(vaw - vbw)); - } - return; - case AABB: { - const ::AABB *ra = reinterpret_cast(a._data._mem); - const ::AABB *rb = reinterpret_cast(b._data._mem); - r_dst = ::AABB(ra->position - rb->position, ra->size - rb->size); - } - return; - case QUATERNION: { - Quaternion empty_rot; - const Quaternion *qa = reinterpret_cast(a._data._mem); - const Quaternion *qb = reinterpret_cast(b._data._mem); - r_dst = (*qb).inverse() * *qa; - } - return; case COLOR: { const Color *ca = reinterpret_cast(a._data._mem); const Color *cb = reinterpret_cast(b._data._mem); @@ -5049,55 +2475,16 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) r_dst = ra + rb * c; } return; - case RECT2: { - const Rect2 *ra = reinterpret_cast(a._data._mem); - const Rect2 *rb = reinterpret_cast(b._data._mem); - r_dst = Rect2(ra->position + rb->position * c, ra->size + rb->size * c); - } - return; case RECT2I: { const Rect2i *ra = reinterpret_cast(a._data._mem); const Rect2i *rb = reinterpret_cast(b._data._mem); - r_dst = Rect2(ra->position + rb->position * c, ra->size + rb->size * c); - } - return; - case VECTOR2: { - r_dst = *reinterpret_cast(a._data._mem) + *reinterpret_cast(b._data._mem) * c; + r_dst = Rect2i(ra->position + rb->position * c, ra->size + rb->size * c); } return; case VECTOR2I: { r_dst = *reinterpret_cast(a._data._mem) + *reinterpret_cast(b._data._mem) * c; } return; - case VECTOR3: { - r_dst = *reinterpret_cast(a._data._mem) + *reinterpret_cast(b._data._mem) * c; - } - return; - case VECTOR3I: { - r_dst = *reinterpret_cast(a._data._mem) + *reinterpret_cast(b._data._mem) * c; - } - return; - case VECTOR4: { - r_dst = *reinterpret_cast(a._data._mem) + *reinterpret_cast(b._data._mem) * c; - } - return; - case VECTOR4I: { - r_dst = *reinterpret_cast(a._data._mem) + *reinterpret_cast(b._data._mem) * c; - } - return; - case AABB: { - const ::AABB *ra = reinterpret_cast(a._data._mem); - const ::AABB *rb = reinterpret_cast(b._data._mem); - r_dst = ::AABB(ra->position + rb->position * c, ra->size + rb->size * c); - } - return; - case QUATERNION: { - Quaternion empty_rot; - const Quaternion *qa = reinterpret_cast(a._data._mem); - const Quaternion *qb = reinterpret_cast(b._data._mem); - r_dst = *qa * empty_rot.slerp(*qb, c); - } - return; case COLOR: { const Color *ca = reinterpret_cast(a._data._mem); const Color *cb = reinterpret_cast(b._data._mem); @@ -5194,62 +2581,14 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = dst; } return; - case RECT2: { - r_dst = Rect2(reinterpret_cast(a._data._mem)->position.linear_interpolate(reinterpret_cast(b._data._mem)->position, c), reinterpret_cast(a._data._mem)->size.linear_interpolate(reinterpret_cast(b._data._mem)->size, c)); - } - return; case RECT2I: { - r_dst = Rect2(reinterpret_cast(a._data._mem)->position.linear_interpolate(reinterpret_cast(b._data._mem)->position, c), reinterpret_cast(a._data._mem)->size.linear_interpolate(reinterpret_cast(b._data._mem)->size, c)); - } - return; - case VECTOR2: { - r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); + r_dst = Rect2i(reinterpret_cast(a._data._mem)->position.linear_interpolate(reinterpret_cast(b._data._mem)->position, c), reinterpret_cast(a._data._mem)->size.linear_interpolate(reinterpret_cast(b._data._mem)->size, c)); } return; case VECTOR2I: { r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); } return; - case VECTOR3: { - r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); - } - return; - case VECTOR3I: { - r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); - } - return; - case VECTOR4: { - r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); - } - return; - case VECTOR4I: { - r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); - } - return; - case PLANE: { - r_dst = a; - } - return; - case QUATERNION: { - r_dst = reinterpret_cast(a._data._mem)->slerp(*reinterpret_cast(b._data._mem), c); - } - return; - case AABB: { - r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c)); - } - return; - case BASIS: { - r_dst = Transform(*a._data._basis).interpolate_with(Transform(*b._data._basis), c).basis; - } - return; - case TRANSFORM: { - r_dst = a._data._transform->interpolate_with(*b._data._transform, c); - } - return; - case TRANSFORM2D: { - r_dst = a._data._transform2d->interpolate_with(*b._data._transform2d, c); - } - return; case COLOR: { r_dst = reinterpret_cast(a._data._mem)->linear_interpolate(*reinterpret_cast(b._data._mem), c); } @@ -5325,28 +2664,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = a; } return; - case POOL_VECTOR2_ARRAY: { - const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); - const PoolVector *arr_b = reinterpret_cast *>(b._data._mem); - int sz = arr_a->size(); - if (sz == 0 || arr_b->size() != sz) { - r_dst = a; - } else { - PoolVector v; - v.resize(sz); - { - PoolVector::Write vw = v.write(); - PoolVector::Read ar = arr_a->read(); - PoolVector::Read br = arr_b->read(); - - for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); - } - } - r_dst = v; - } - } - return; case POOL_VECTOR2I_ARRAY: { const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); const PoolVector *arr_b = reinterpret_cast *>(b._data._mem); @@ -5369,97 +2686,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } } return; - case POOL_VECTOR3_ARRAY: { - const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); - const PoolVector *arr_b = reinterpret_cast *>(b._data._mem); - int sz = arr_a->size(); - if (sz == 0 || arr_b->size() != sz) { - r_dst = a; - } else { - PoolVector v; - v.resize(sz); - { - PoolVector::Write vw = v.write(); - PoolVector::Read ar = arr_a->read(); - PoolVector::Read br = arr_b->read(); - - for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); - } - } - r_dst = v; - } - } - return; - case POOL_VECTOR3I_ARRAY: { - const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); - const PoolVector *arr_b = reinterpret_cast *>(b._data._mem); - int sz = arr_a->size(); - if (sz == 0 || arr_b->size() != sz) { - r_dst = a; - } else { - PoolVector v; - v.resize(sz); - { - PoolVector::Write vw = v.write(); - PoolVector::Read ar = arr_a->read(); - PoolVector::Read br = arr_b->read(); - - for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); - } - } - r_dst = v; - } - } - return; - case POOL_VECTOR4_ARRAY: { - const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); - const PoolVector *arr_b = reinterpret_cast *>(b._data._mem); - int sz = arr_a->size(); - if (sz == 0 || arr_b->size() != sz) { - r_dst = a; - } else { - PoolVector v; - v.resize(sz); - { - PoolVector::Write vw = v.write(); - PoolVector::Read ar = arr_a->read(); - PoolVector::Read br = arr_b->read(); - - for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); - } - } - r_dst = v; - } - } - return; - case POOL_VECTOR4I_ARRAY: { - /* - const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); - const PoolVector *arr_b = reinterpret_cast *>(b._data._mem); - int sz = arr_a->size(); - if (sz == 0 || arr_b->size() != sz) { - r_dst = a; - } else { - PoolVector v; - v.resize(sz); - { - PoolVector::Write vw = v.write(); - PoolVector::Read ar = arr_a->read(); - PoolVector::Read br = arr_b->read(); - - for (int i = 0; i < sz; i++) { - vw[i] = ar[i].lerp(br[i], c); - } - } - r_dst = v; - } - */ - r_dst = a; - } - return; case POOL_COLOR_ARRAY: { const PoolVector *arr_a = reinterpret_cast *>(a._data._mem); const PoolVector *arr_b = reinterpret_cast *>(b._data._mem);