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. --- modules/visual_script/visual_script_editor.cpp | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'modules/visual_script/visual_script_editor.cpp') diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 787f0b7f40..8d58cb9c4d 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -346,7 +346,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::BOOL: color = Color(0.55, 0.65, 0.94); break; case Variant::INT: color = Color(0.49, 0.78, 0.94); break; - case Variant::REAL: color = Color(0.38, 0.85, 0.96); break; + case Variant::FLOAT: color = Color(0.38, 0.85, 0.96); break; case Variant::STRING: color = Color(0.42, 0.65, 0.93); break; case Variant::VECTOR2: color = Color(0.74, 0.57, 0.95); break; @@ -367,8 +367,10 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::ARRAY: color = Color(0.88, 0.88, 0.88); break; case Variant::PACKED_BYTE_ARRAY: color = Color(0.67, 0.96, 0.78); break; - case Variant::PACKED_INT_ARRAY: color = Color(0.69, 0.86, 0.96); break; - case Variant::PACKED_REAL_ARRAY: color = Color(0.59, 0.91, 0.97); break; + case Variant::PACKED_INT32_ARRAY: color = Color(0.69, 0.86, 0.96); break; + case Variant::PACKED_FLOAT32_ARRAY: color = Color(0.59, 0.91, 0.97); break; + case Variant::PACKED_INT64_ARRAY: color = Color(0.69, 0.86, 0.96); break; + case Variant::PACKED_FLOAT64_ARRAY: color = Color(0.59, 0.91, 0.97); break; case Variant::PACKED_STRING_ARRAY: color = Color(0.62, 0.77, 0.95); break; case Variant::PACKED_VECTOR2_ARRAY: color = Color(0.82, 0.7, 0.96); break; case Variant::PACKED_VECTOR3_ARRAY: color = Color(0.87, 0.61, 0.95); break; @@ -383,7 +385,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::BOOL: color = Color(0.43, 0.56, 0.92); break; case Variant::INT: color = Color(0.31, 0.7, 0.91); break; - case Variant::REAL: color = Color(0.15, 0.8, 0.94); break; + case Variant::FLOAT: color = Color(0.15, 0.8, 0.94); break; case Variant::STRING: color = Color(0.27, 0.56, 0.91); break; case Variant::VECTOR2: color = Color(0.68, 0.46, 0.93); break; @@ -404,8 +406,10 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::ARRAY: color = Color(0.45, 0.45, 0.45); break; case Variant::PACKED_BYTE_ARRAY: color = Color(0.38, 0.92, 0.6); break; - case Variant::PACKED_INT_ARRAY: color = Color(0.38, 0.73, 0.92); break; - case Variant::PACKED_REAL_ARRAY: color = Color(0.25, 0.83, 0.95); break; + case Variant::PACKED_INT32_ARRAY: color = Color(0.38, 0.73, 0.92); break; + case Variant::PACKED_FLOAT32_ARRAY: color = Color(0.25, 0.83, 0.95); break; + case Variant::PACKED_INT64_ARRAY: color = Color(0.38, 0.73, 0.92); break; + case Variant::PACKED_FLOAT64_ARRAY: color = Color(0.25, 0.83, 0.95); break; case Variant::PACKED_STRING_ARRAY: color = Color(0.38, 0.62, 0.92); break; case Variant::PACKED_VECTOR2_ARRAY: color = Color(0.62, 0.36, 0.92); break; case Variant::PACKED_VECTOR3_ARRAY: color = Color(0.79, 0.35, 0.92); break; @@ -521,8 +525,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Control::get_icon("Dictionary", "EditorIcons"), Control::get_icon("Array", "EditorIcons"), Control::get_icon("PackedByteArray", "EditorIcons"), - Control::get_icon("PackedIntArray", "EditorIcons"), - Control::get_icon("PackedRealArray", "EditorIcons"), + Control::get_icon("PackedInt32Array", "EditorIcons"), + Control::get_icon("PackedFloat32Array", "EditorIcons"), Control::get_icon("PackedStringArray", "EditorIcons"), Control::get_icon("PackedVector2Array", "EditorIcons"), Control::get_icon("PackedVector3Array", "EditorIcons"), @@ -977,8 +981,8 @@ void VisualScriptEditor::_update_members() { Control::get_icon("Dictionary", "EditorIcons"), Control::get_icon("Array", "EditorIcons"), Control::get_icon("PackedByteArray", "EditorIcons"), - Control::get_icon("PackedIntArray", "EditorIcons"), - Control::get_icon("PackedRealArray", "EditorIcons"), + Control::get_icon("PackedInt32Array", "EditorIcons"), + Control::get_icon("PackedFloat32Array", "EditorIcons"), Control::get_icon("PackedStringArray", "EditorIcons"), Control::get_icon("PackedVector2Array", "EditorIcons"), Control::get_icon("PackedVector3Array", "EditorIcons"), @@ -2910,8 +2914,8 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, if (to_type != Variant::NIL && from_type != Variant::NIL && to_type != from_type) { // add a constructor node between the ports bool exceptions = false; // true if there are any exceptions - exceptions = exceptions || (to_type == Variant::INT && from_type == Variant::REAL); - exceptions = exceptions || (to_type == Variant::REAL && from_type == Variant::INT); + exceptions = exceptions || (to_type == Variant::INT && from_type == Variant::FLOAT); + exceptions = exceptions || (to_type == Variant::FLOAT && from_type == Variant::INT); if (Variant::can_convert(from_type, to_type) && !exceptions) { MethodInfo mi; mi.name = Variant::get_type_name(to_type); -- cgit v1.2.3