From 33b5c571995cce60a21784ac33fcf958640ed1e2 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 24 Feb 2020 15:20:53 -0300 Subject: Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT. - Renames PackedIntArray to PackedInt32Array. - Renames PackedFloatArray to PackedFloat32Array. - Adds PackedInt64Array and PackedFloat64Array. - Renames Variant::REAL to Variant::FLOAT for consistency. Packed arrays are for storing large amount of data and creating stuff like meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of memory. That said, many users requested the ability to have 64 bits packed arrays for their games, so this is just an optional added type. For Variant, the float datatype is always 64 bits, and exposed as `float`. We still have `real_t` which is the datatype that can change from 32 to 64 bits depending on a compile flag (not entirely working right now, but that's the idea). It affects math related datatypes and code only. Neither Variant nor PackedArray make use of real_t, which is only intended for math precision, so the term is removed from there to keep only float. --- core/variant.h | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'core/variant.h') diff --git a/core/variant.h b/core/variant.h index c126540001..9ab25b9406 100644 --- a/core/variant.h +++ b/core/variant.h @@ -58,8 +58,10 @@ struct PropertyInfo; struct MethodInfo; typedef Vector PackedByteArray; -typedef Vector PackedIntArray; -typedef Vector PackedRealArray; +typedef Vector PackedInt32Array; +typedef Vector PackedInt64Array; +typedef Vector PackedFloat32Array; +typedef Vector PackedFloat64Array; typedef Vector PackedStringArray; typedef Vector PackedVector2Array; typedef Vector PackedVector3Array; @@ -82,7 +84,7 @@ public: // atomic types BOOL, INT, - REAL, + FLOAT, STRING, // math types @@ -112,8 +114,10 @@ public: ARRAY, // arrays PACKED_BYTE_ARRAY, // 20 - PACKED_INT_ARRAY, - PACKED_REAL_ARRAY, + PACKED_INT32_ARRAY, + PACKED_INT64_ARRAY, + PACKED_FLOAT32_ARRAY, + PACKED_FLOAT64_ARRAY, PACKED_STRING_ARRAY, PACKED_VECTOR2_ARRAY, PACKED_VECTOR3_ARRAY, // 25 @@ -201,7 +205,7 @@ private: union { bool _bool; int64_t _int; - double _real; + double _float; Transform2D *_transform2d; ::AABB *_aabb; Basis *_basis; @@ -224,7 +228,7 @@ public: bool is_ref() const; _FORCE_INLINE_ bool is_num() const { - return type == INT || type == REAL; + return type == INT || type == FLOAT; }; _FORCE_INLINE_ bool is_array() const { return type >= ARRAY; @@ -284,8 +288,10 @@ public: operator Array() 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; @@ -349,9 +355,11 @@ public: Variant(const Array &p_array); Variant(const Vector &p_array); // helper - Variant(const Vector &p_raw_array); - Variant(const Vector &p_int_array); - Variant(const Vector &p_real_array); + Variant(const Vector &p_byte_array); + Variant(const Vector &p_int32_array); + Variant(const Vector &p_int64_array); + Variant(const Vector &p_float32_array); + Variant(const Vector &p_float64_array); Variant(const Vector &p_string_array); Variant(const Vector &p_vector3_array); Variant(const Vector &p_color_array); -- cgit v1.2.3