diff options
author | Juan Linietsky <juan@godotengine.org> | 2020-02-24 15:20:53 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-25 12:55:53 +0100 |
commit | 33b5c571995cce60a21784ac33fcf958640ed1e2 (patch) | |
tree | b6f087b46a88fe8e2bac093c521da829108714f5 /core/variant.h | |
parent | c19488bd895f911f37bf2c03624d05ea8d0ec1ee (diff) | |
download | redot-engine-33b5c571995cce60a21784ac33fcf958640ed1e2.tar.gz |
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.
Diffstat (limited to 'core/variant.h')
-rw-r--r-- | core/variant.h | 32 |
1 files changed, 20 insertions, 12 deletions
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<uint8_t> PackedByteArray; -typedef Vector<int> PackedIntArray; -typedef Vector<real_t> PackedRealArray; +typedef Vector<int32_t> PackedInt32Array; +typedef Vector<int64_t> PackedInt64Array; +typedef Vector<float> PackedFloat32Array; +typedef Vector<double> PackedFloat64Array; typedef Vector<String> PackedStringArray; typedef Vector<Vector2> PackedVector2Array; typedef Vector<Vector3> 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<uint8_t>() const; - operator Vector<int>() const; - operator Vector<real_t>() const; + operator Vector<int32_t>() const; + operator Vector<int64_t>() const; + operator Vector<float>() const; + operator Vector<double>() const; operator Vector<String>() const; operator Vector<Vector3>() const; operator Vector<Color>() const; @@ -349,9 +355,11 @@ public: Variant(const Array &p_array); Variant(const Vector<Plane> &p_array); // helper - Variant(const Vector<uint8_t> &p_raw_array); - Variant(const Vector<int> &p_int_array); - Variant(const Vector<real_t> &p_real_array); + Variant(const Vector<uint8_t> &p_byte_array); + Variant(const Vector<int32_t> &p_int32_array); + Variant(const Vector<int64_t> &p_int64_array); + Variant(const Vector<float> &p_float32_array); + Variant(const Vector<double> &p_float64_array); Variant(const Vector<String> &p_string_array); Variant(const Vector<Vector3> &p_vector3_array); Variant(const Vector<Color> &p_color_array); |