diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 4 | ||||
-rw-r--r-- | core/compressed_translation.cpp | 4 | ||||
-rw-r--r-- | core/global_constants.cpp | 8 | ||||
-rw-r--r-- | core/io/json.cpp | 8 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 119 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 111 | ||||
-rw-r--r-- | core/math/a_star.cpp | 4 | ||||
-rw-r--r-- | core/math/expression.cpp | 10 | ||||
-rw-r--r-- | core/method_ptrcall.h | 6 | ||||
-rw-r--r-- | core/os/input_event.cpp | 12 | ||||
-rw-r--r-- | core/os/main_loop.cpp | 4 | ||||
-rw-r--r-- | core/packed_data_container.cpp | 8 | ||||
-rw-r--r-- | core/type_info.h | 24 | ||||
-rw-r--r-- | core/variant.cpp | 408 | ||||
-rw-r--r-- | core/variant.h | 32 | ||||
-rw-r--r-- | core/variant_call.cpp | 304 | ||||
-rw-r--r-- | core/variant_op.cpp | 640 | ||||
-rw-r--r-- | core/variant_parser.cpp | 116 |
18 files changed, 1235 insertions, 587 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index f5a351f16a..c1cf061854 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -3101,8 +3101,8 @@ void _Engine::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_hint"), "set_editor_hint", "is_editor_hint"); ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations_per_second"), "set_iterations_per_second", "get_iterations_per_second"); ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_scale"), "set_time_scale", "get_time_scale"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_scale"), "set_time_scale", "get_time_scale"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix"); } _Engine *_Engine::singleton = NULL; diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index ea84ded3b4..ed307fd3ac 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -279,8 +279,8 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const { void PHashTranslation::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->push_back(PropertyInfo(Variant::PACKED_INT_ARRAY, "hash_table")); - p_list->push_back(PropertyInfo(Variant::PACKED_INT_ARRAY, "bucket_table")); + p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "hash_table")); + p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "bucket_table")); p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "strings")); p_list->push_back(PropertyInfo(Variant::OBJECT, "load_from", PROPERTY_HINT_RESOURCE_TYPE, "Translation", PROPERTY_USAGE_EDITOR)); } diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 3de36dcb9d..73db723c65 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -594,7 +594,7 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NIL", Variant::NIL); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BOOL", Variant::BOOL); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT", Variant::INT); - BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL", Variant::REAL); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL", Variant::FLOAT); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING", Variant::STRING); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2", Variant::VECTOR2); // 5 BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT2", Variant::RECT2); @@ -615,8 +615,10 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY); // 20 BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_ARRAY", Variant::ARRAY); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RAW_ARRAY", Variant::PACKED_BYTE_ARRAY); - BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT_ARRAY", Variant::PACKED_INT_ARRAY); - BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL_ARRAY", Variant::PACKED_REAL_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT32_ARRAY", Variant::PACKED_INT32_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT64_ARRAY", Variant::PACKED_INT64_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_FLOAT32_ARRAY", Variant::PACKED_FLOAT32_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_FLOAT64_ARRAY", Variant::PACKED_FLOAT64_ARRAY); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_ARRAY", Variant::PACKED_STRING_ARRAY); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::PACKED_VECTOR2_ARRAY); // 25 BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3_ARRAY", Variant::PACKED_VECTOR3_ARRAY); diff --git a/core/io/json.cpp b/core/io/json.cpp index 08a147032f..3a0edceb81 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -70,9 +70,11 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ case Variant::NIL: return "null"; case Variant::BOOL: return p_var.operator bool() ? "true" : "false"; case Variant::INT: return itos(p_var); - case Variant::REAL: return rtos(p_var); - case Variant::PACKED_INT_ARRAY: - case Variant::PACKED_REAL_ARRAY: + case Variant::FLOAT: return rtos(p_var); + case Variant::PACKED_INT32_ARRAY: + case Variant::PACKED_INT64_ARRAY: + case Variant::PACKED_FLOAT32_ARRAY: + case Variant::PACKED_FLOAT64_ARRAY: case Variant::PACKED_STRING_ARRAY: case Variant::ARRAY: { diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index e97c26e05d..0b815b2c7b 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -147,7 +147,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } } break; - case Variant::REAL: { + case Variant::FLOAT: { if (type & ENCODE_FLAG_64) { ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA); @@ -621,7 +621,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); int32_t count = decode_uint32(buf); @@ -630,12 +630,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_MUL_OF(count, 4, ERR_INVALID_DATA); ERR_FAIL_COND_V(count < 0 || count * 4 > len, ERR_INVALID_DATA); - Vector<int> data; + Vector<int32_t> data; if (count) { //const int*rbuf=(const int*)buf; data.resize(count); - int *w = data.ptrw(); + int32_t *w = data.ptrw(); for (int32_t i = 0; i < count; i++) { w[i] = decode_uint32(&buf[i * 4]); @@ -643,11 +643,37 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } r_variant = Variant(data); if (r_len) { - (*r_len) += 4 + count * sizeof(int); + (*r_len) += 4 + count * sizeof(int32_t); } } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_INT64_ARRAY: { + + ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); + int64_t count = decode_uint64(buf); + buf += 4; + len -= 4; + ERR_FAIL_MUL_OF(count, 8, ERR_INVALID_DATA); + ERR_FAIL_COND_V(count < 0 || count * 8 > len, ERR_INVALID_DATA); + + Vector<int64_t> data; + + if (count) { + //const int*rbuf=(const int*)buf; + data.resize(count); + int64_t *w = data.ptrw(); + for (int64_t i = 0; i < count; i++) { + + w[i] = decode_uint64(&buf[i * 8]); + } + } + r_variant = Variant(data); + if (r_len) { + (*r_len) += 4 + count * sizeof(int64_t); + } + + } break; + case Variant::PACKED_FLOAT32_ARRAY: { ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); int32_t count = decode_uint32(buf); @@ -674,6 +700,33 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } } break; + case Variant::PACKED_FLOAT64_ARRAY: { + + ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); + int64_t count = decode_uint64(buf); + buf += 4; + len -= 4; + ERR_FAIL_MUL_OF(count, 8, ERR_INVALID_DATA); + ERR_FAIL_COND_V(count < 0 || count * 8 > len, ERR_INVALID_DATA); + + Vector<double> data; + + if (count) { + //const double*rbuf=(const double*)buf; + data.resize(count); + double *w = data.ptrw(); + for (int64_t i = 0; i < count; i++) { + + w[i] = decode_double(&buf[i * 8]); + } + } + r_variant = data; + + if (r_len) { + (*r_len) += 4 + count * sizeof(double); + } + + } break; case Variant::PACKED_STRING_ARRAY: { ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); @@ -851,7 +904,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo flags |= ENCODE_FLAG_64; } } break; - case Variant::REAL: { + case Variant::FLOAT: { double d = p_variant; float f = d; @@ -918,7 +971,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; } } break; - case Variant::REAL: { + case Variant::FLOAT: { if (flags & ENCODE_FLAG_64) { if (buf) { @@ -1333,33 +1386,50 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo } } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { - Vector<int> data = p_variant; + Vector<int32_t> data = p_variant; int datalen = data.size(); int datasize = sizeof(int32_t); if (buf) { encode_uint32(datalen, buf); buf += 4; - const int *r = data.ptr(); - for (int i = 0; i < datalen; i++) + const int32_t *r = data.ptr(); + for (int32_t i = 0; i < datalen; i++) encode_uint32(r[i], &buf[i * datasize]); } r_len += 4 + datalen * datasize; } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_INT64_ARRAY: { + + Vector<int64_t> data = p_variant; + int datalen = data.size(); + int datasize = sizeof(int64_t); + + if (buf) { + encode_uint64(datalen, buf); + buf += 4; + const int64_t *r = data.ptr(); + for (int64_t i = 0; i < datalen; i++) + encode_uint64(r[i], &buf[i * datasize]); + } + + r_len += 4 + datalen * datasize; + + } break; + case Variant::PACKED_FLOAT32_ARRAY: { - Vector<real_t> data = p_variant; + Vector<float> data = p_variant; int datalen = data.size(); - int datasize = sizeof(real_t); + int datasize = sizeof(float); if (buf) { encode_uint32(datalen, buf); buf += 4; - const real_t *r = data.ptr(); + const float *r = data.ptr(); for (int i = 0; i < datalen; i++) encode_float(r[i], &buf[i * datasize]); } @@ -1367,6 +1437,23 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4 + datalen * datasize; } break; + case Variant::PACKED_FLOAT64_ARRAY: { + + Vector<double> data = p_variant; + int datalen = data.size(); + int datasize = sizeof(double); + + if (buf) { + encode_uint32(datalen, buf); + buf += 4; + const double *r = data.ptr(); + for (int i = 0; i < datalen; i++) + encode_double(r[i], &buf[i * datasize]); + } + + r_len += 4 + datalen * datasize; + + } break; case Variant::PACKED_STRING_ARRAY: { Vector<String> data = p_variant; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 518323c5c4..8c343a0f43 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -46,7 +46,7 @@ enum { VARIANT_NIL = 1, VARIANT_BOOL = 2, VARIANT_INT = 3, - VARIANT_REAL = 4, + VARIANT_FLOAT = 4, VARIANT_STRING = 5, VARIANT_VECTOR2 = 10, VARIANT_RECT2 = 11, @@ -65,8 +65,8 @@ enum { VARIANT_DICTIONARY = 26, VARIANT_ARRAY = 30, VARIANT_RAW_ARRAY = 31, - VARIANT_INT_ARRAY = 32, - VARIANT_REAL_ARRAY = 33, + VARIANT_INT32_ARRAY = 32, + VARIANT_FLOAT32_ARRAY = 33, VARIANT_STRING_ARRAY = 34, VARIANT_VECTOR3_ARRAY = 35, VARIANT_COLOR_ARRAY = 36, @@ -79,6 +79,8 @@ enum { VARIANT_VECTOR2I = 45, VARIANT_RECT2I = 46, VARIANT_VECTOR3I = 47, + VARIANT_INT64_ARRAY = 48, + VARIANT_FLOAT64_ARRAY = 49, OBJECT_EMPTY = 0, OBJECT_EXTERNAL_RESOURCE = 1, OBJECT_INTERNAL_RESOURCE = 2, @@ -142,7 +144,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = int64_t(f->get_64()); } break; - case VARIANT_REAL: { + case VARIANT_FLOAT: { r_v = f->get_real(); } break; @@ -452,14 +454,14 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = array; } break; - case VARIANT_INT_ARRAY: { + case VARIANT_INT32_ARRAY: { uint32_t len = f->get_32(); - Vector<int> array; + Vector<int32_t> array; array.resize(len); - int *w = array.ptrw(); - f->get_buffer((uint8_t *)w, len * 4); + int32_t *w = array.ptrw(); + f->get_buffer((uint8_t *)w, len * sizeof(int32_t)); #ifdef BIG_ENDIAN_ENABLED { uint32_t *ptr = (uint32_t *)w.ptr(); @@ -473,14 +475,35 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = array; } break; - case VARIANT_REAL_ARRAY: { + case VARIANT_INT64_ARRAY: { uint32_t len = f->get_32(); - Vector<real_t> array; + Vector<int64_t> array; array.resize(len); - real_t *w = array.ptrw(); - f->get_buffer((uint8_t *)w, len * sizeof(real_t)); + int64_t *w = array.ptrw(); + f->get_buffer((uint8_t *)w, len * sizeof(int64_t)); +#ifdef BIG_ENDIAN_ENABLED + { + uint64_t *ptr = (uint64_t *)w.ptr(); + for (int i = 0; i < len; i++) { + + ptr[i] = BSWAP64(ptr[i]); + } + } + +#endif + + r_v = array; + } break; + case VARIANT_FLOAT32_ARRAY: { + + uint32_t len = f->get_32(); + + Vector<float> array; + array.resize(len); + float *w = array.ptrw(); + f->get_buffer((uint8_t *)w, len * sizeof(float)); #ifdef BIG_ENDIAN_ENABLED { uint32_t *ptr = (uint32_t *)w.ptr(); @@ -494,6 +517,27 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = array; } break; + case VARIANT_FLOAT64_ARRAY: { + + uint32_t len = f->get_32(); + + Vector<double> array; + array.resize(len); + double *w = array.ptrw(); + f->get_buffer((uint8_t *)w, len * sizeof(double)); +#ifdef BIG_ENDIAN_ENABLED + { + uint64_t *ptr = (uint64_t *)w.ptr(); + for (int i = 0; i < len; i++) { + + ptr[i] = BSWAP64(ptr[i]); + } + } + +#endif + + r_v = array; + } break; case VARIANT_STRING_ARRAY: { uint32_t len = f->get_32(); @@ -1293,7 +1337,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia } } break; - case Variant::REAL: { + case Variant::FLOAT: { double d = p_property; float fl = d; @@ -1302,7 +1346,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia f->store_double(d); } else { - f->store_32(VARIANT_REAL); + f->store_32(VARIANT_FLOAT); f->store_real(fl); } @@ -1573,29 +1617,52 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia _pad_buffer(f, len); } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { - f->store_32(VARIANT_INT_ARRAY); - Vector<int> arr = p_property; + f->store_32(VARIANT_INT32_ARRAY); + Vector<int32_t> arr = p_property; int len = arr.size(); f->store_32(len); - const int *r = arr.ptr(); + const int32_t *r = arr.ptr(); for (int i = 0; i < len; i++) f->store_32(r[i]); } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_INT64_ARRAY: { - f->store_32(VARIANT_REAL_ARRAY); - Vector<real_t> arr = p_property; + f->store_32(VARIANT_INT64_ARRAY); + Vector<int64_t> arr = p_property; int len = arr.size(); f->store_32(len); - const real_t *r = arr.ptr(); + const int64_t *r = arr.ptr(); + for (int i = 0; i < len; i++) + f->store_64(r[i]); + + } break; + case Variant::PACKED_FLOAT32_ARRAY: { + + f->store_32(VARIANT_FLOAT32_ARRAY); + Vector<float> arr = p_property; + int len = arr.size(); + f->store_32(len); + const float *r = arr.ptr(); for (int i = 0; i < len; i++) { f->store_real(r[i]); } } break; + case Variant::PACKED_FLOAT64_ARRAY: { + + f->store_32(VARIANT_FLOAT64_ARRAY); + Vector<double> arr = p_property; + int len = arr.size(); + f->store_32(len); + const double *r = arr.ptr(); + for (int i = 0; i < len; i++) { + f->store_double(r[i]); + } + + } break; case Variant::PACKED_STRING_ARRAY: { f->store_32(VARIANT_STRING_ARRAY); diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index b26903e45a..847d4d8681 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -576,8 +576,8 @@ void AStar::_bind_methods() { ClassDB::bind_method(D_METHOD("get_point_path", "from_id", "to_id"), &AStar::get_point_path); ClassDB::bind_method(D_METHOD("get_id_path", "from_id", "to_id"), &AStar::get_id_path); - BIND_VMETHOD(MethodInfo(Variant::REAL, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); - BIND_VMETHOD(MethodInfo(Variant::REAL, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); + BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); + BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); } AStar::AStar() { diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 2728da616e..058673b681 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -212,7 +212,7 @@ int Expression::get_func_argument_count(BuiltinFunc p_func) { if (!p_inputs[m_arg]->is_num()) { \ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; \ r_error.argument = m_arg; \ - r_error.expected = Variant::REAL; \ + r_error.expected = Variant::FLOAT; \ return; \ } @@ -314,7 +314,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant int64_t i = *p_inputs[0]; *r_return = ABS(i); - } else if (p_inputs[0]->get_type() == Variant::REAL) { + } else if (p_inputs[0]->get_type() == Variant::FLOAT) { real_t r = *p_inputs[0]; *r_return = Math::abs(r); @@ -322,7 +322,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; - r_error.expected = Variant::REAL; + r_error.expected = Variant::FLOAT; } } break; case MATH_SIGN: { @@ -331,7 +331,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant int64_t i = *p_inputs[0]; *r_return = i < 0 ? -1 : (i > 0 ? +1 : 0); - } else if (p_inputs[0]->get_type() == Variant::REAL) { + } else if (p_inputs[0]->get_type() == Variant::FLOAT) { real_t r = *p_inputs[0]; *r_return = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0); @@ -339,7 +339,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; - r_error.expected = Variant::REAL; + r_error.expected = Variant::FLOAT; } } break; case MATH_POW: { diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index 7e21c2cc24..3db186ca69 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -133,8 +133,10 @@ MAKE_PTRARG(Callable); MAKE_PTRARG(Signal); MAKE_PTRARG(Array); MAKE_PTRARG(PackedByteArray); -MAKE_PTRARG(PackedIntArray); -MAKE_PTRARG(PackedRealArray); +MAKE_PTRARG(PackedInt32Array); +MAKE_PTRARG(PackedInt64Array); +MAKE_PTRARG(PackedFloat32Array); +MAKE_PTRARG(PackedFloat64Array); MAKE_PTRARG(PackedStringArray); MAKE_PTRARG(PackedVector2Array); MAKE_PTRARG(PackedVector3Array); diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 7d1ae872f4..3cb9c2c1c2 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -541,7 +541,7 @@ void InputEventMouseButton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_doubleclick", "doubleclick"), &InputEventMouseButton::set_doubleclick); ClassDB::bind_method(D_METHOD("is_doubleclick"), &InputEventMouseButton::is_doubleclick); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor"); ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick"); @@ -702,7 +702,7 @@ void InputEventMouseMotion::_bind_methods() { ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tilt"), "set_tilt", "get_tilt"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); } @@ -780,7 +780,7 @@ void InputEventJoypadMotion::_bind_methods() { ClassDB::bind_method(D_METHOD("get_axis_value"), &InputEventJoypadMotion::get_axis_value); ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "axis_value"), "set_axis_value", "get_axis_value"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "axis_value"), "set_axis_value", "get_axis_value"); } InputEventJoypadMotion::InputEventJoypadMotion() { @@ -861,7 +861,7 @@ void InputEventJoypadButton::_bind_methods() { // ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventJoypadButton::is_pressed); ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); } @@ -1100,7 +1100,7 @@ void InputEventAction::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "action"), "set_action", "get_action"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength"); } InputEventAction::InputEventAction() { @@ -1162,7 +1162,7 @@ void InputEventMagnifyGesture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor); ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor"); } InputEventMagnifyGesture::InputEventMagnifyGesture() { diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 61bcb7dd32..ab43ce4af7 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -44,8 +44,8 @@ void MainLoop::_bind_methods() { BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); BIND_VMETHOD(MethodInfo("_input_text", PropertyInfo(Variant::STRING, "text"))); BIND_VMETHOD(MethodInfo("_initialize")); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::REAL, "delta"))); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::REAL, "delta"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::FLOAT, "delta"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta"))); BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "from_screen"))); BIND_VMETHOD(MethodInfo("_finalize")); diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index 6a4fac971c..b82a366ef2 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -230,7 +230,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd case Variant::NIL: case Variant::BOOL: case Variant::INT: - case Variant::REAL: + case Variant::FLOAT: case Variant::VECTOR2: case Variant::RECT2: case Variant::VECTOR3: @@ -241,8 +241,10 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd case Variant::BASIS: case Variant::TRANSFORM: case Variant::PACKED_BYTE_ARRAY: - case Variant::PACKED_INT_ARRAY: - case Variant::PACKED_REAL_ARRAY: + case Variant::PACKED_INT32_ARRAY: + case Variant::PACKED_INT64_ARRAY: + case Variant::PACKED_FLOAT32_ARRAY: + case Variant::PACKED_FLOAT64_ARRAY: case Variant::PACKED_STRING_ARRAY: case Variant::PACKED_VECTOR2_ARRAY: case Variant::PACKED_VECTOR3_ARRAY: diff --git a/core/type_info.h b/core/type_info.h index 6861531fbd..5dacf67de4 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -137,8 +137,8 @@ MAKE_TYPE_INFO_WITH_META(int32_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_I MAKE_TYPE_INFO_WITH_META(uint64_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_UINT64) MAKE_TYPE_INFO_WITH_META(int64_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_INT64) MAKE_TYPE_INFO(wchar_t, Variant::INT) -MAKE_TYPE_INFO_WITH_META(float, Variant::REAL, GodotTypeInfo::METADATA_REAL_IS_FLOAT) -MAKE_TYPE_INFO_WITH_META(double, Variant::REAL, GodotTypeInfo::METADATA_REAL_IS_DOUBLE) +MAKE_TYPE_INFO_WITH_META(float, Variant::FLOAT, GodotTypeInfo::METADATA_REAL_IS_FLOAT) +MAKE_TYPE_INFO_WITH_META(double, Variant::FLOAT, GodotTypeInfo::METADATA_REAL_IS_DOUBLE) MAKE_TYPE_INFO(String, Variant::STRING) MAKE_TYPE_INFO(Vector2, Variant::VECTOR2) @@ -159,8 +159,10 @@ MAKE_TYPE_INFO(Signal, Variant::SIGNAL) MAKE_TYPE_INFO(Dictionary, Variant::DICTIONARY) MAKE_TYPE_INFO(Array, Variant::ARRAY) MAKE_TYPE_INFO(PackedByteArray, Variant::PACKED_BYTE_ARRAY) -MAKE_TYPE_INFO(PackedIntArray, Variant::PACKED_INT_ARRAY) -MAKE_TYPE_INFO(PackedRealArray, Variant::PACKED_REAL_ARRAY) +MAKE_TYPE_INFO(PackedInt32Array, Variant::PACKED_INT32_ARRAY) +MAKE_TYPE_INFO(PackedInt64Array, Variant::PACKED_INT64_ARRAY) +MAKE_TYPE_INFO(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) +MAKE_TYPE_INFO(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) MAKE_TYPE_INFO(PackedStringArray, Variant::PACKED_STRING_ARRAY) MAKE_TYPE_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) MAKE_TYPE_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) @@ -221,20 +223,6 @@ MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY) MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY) MAKE_TEMPLATE_TYPE_INFO(Vector, StringName, Variant::PACKED_STRING_ARRAY) -/* -MAKE_TEMPLATE_TYPE_INFO(Vector, uint8_t, Variant::PACKED_BYTE_ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, int, Variant::PACKED_INT_ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, float, Variant::PACKED_REAL_ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, String, Variant::PACKED_STRING_ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, Vector2, Variant::PACKED_VECTOR2_ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, Vector3, Variant::PACKED_VECTOR3_ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, Color, Variant::PACKED_COLOR_ARRAY) - - -MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY) -MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY) -*/ - template <typename T> struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> { static const Variant::Type VARIANT_TYPE = Variant::OBJECT; diff --git a/core/variant.cpp b/core/variant.cpp index 1e09df98c7..7bdaab8fa8 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -57,7 +57,7 @@ String Variant::get_type_name(Variant::Type p_type) { return "int"; } break; - case REAL: { + case FLOAT: { return "float"; @@ -175,14 +175,24 @@ String Variant::get_type_name(Variant::Type p_type) { return "PackedByteArray"; } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { - return "PackedIntArray"; + return "PackedInt32Array"; } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { - return "PackedRealArray"; + return "PackedInt64Array"; + + } break; + case PACKED_FLOAT32_ARRAY: { + + return "PackedFloat32Array"; + + } break; + case PACKED_FLOAT64_ARRAY: { + + return "PackedFloat64Array"; } break; case PACKED_STRING_ARRAY: { @@ -230,7 +240,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { static const Type valid[] = { INT, - REAL, + FLOAT, STRING, NIL, }; @@ -241,7 +251,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { static const Type valid[] = { BOOL, - REAL, + FLOAT, STRING, NIL, }; @@ -249,7 +259,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; - case REAL: { + case FLOAT: { static const Type valid[] = { BOOL, @@ -425,9 +435,11 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { static const Type valid[] = { PACKED_BYTE_ARRAY, - PACKED_INT_ARRAY, + PACKED_INT32_ARRAY, + PACKED_INT64_ARRAY, + PACKED_FLOAT32_ARRAY, + PACKED_FLOAT64_ARRAY, PACKED_STRING_ARRAY, - PACKED_REAL_ARRAY, PACKED_COLOR_ARRAY, PACKED_VECTOR2_ARRAY, PACKED_VECTOR3_ARRAY, @@ -446,7 +458,15 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { + + static const Type valid[] = { + ARRAY, + NIL + }; + valid_types = valid; + } break; + case PACKED_INT64_ARRAY: { static const Type valid[] = { ARRAY, @@ -454,7 +474,16 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { }; valid_types = valid; } break; - case PACKED_REAL_ARRAY: { + case PACKED_FLOAT32_ARRAY: { + + static const Type valid[] = { + ARRAY, + NIL + }; + + valid_types = valid; + } break; + case PACKED_FLOAT64_ARRAY: { static const Type valid[] = { ARRAY, @@ -547,7 +576,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type static const Type valid[] = { INT, - REAL, + FLOAT, //STRING, NIL, }; @@ -558,7 +587,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type static const Type valid[] = { BOOL, - REAL, + FLOAT, //STRING, NIL, }; @@ -566,7 +595,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; - case REAL: { + case FLOAT: { static const Type valid[] = { BOOL, @@ -743,9 +772,11 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type static const Type valid[] = { PACKED_BYTE_ARRAY, - PACKED_INT_ARRAY, + PACKED_INT32_ARRAY, + PACKED_INT64_ARRAY, + PACKED_FLOAT32_ARRAY, + PACKED_FLOAT64_ARRAY, PACKED_STRING_ARRAY, - PACKED_REAL_ARRAY, PACKED_COLOR_ARRAY, PACKED_VECTOR2_ARRAY, PACKED_VECTOR3_ARRAY, @@ -764,7 +795,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { static const Type valid[] = { ARRAY, @@ -772,7 +803,24 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type }; valid_types = valid; } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { + + static const Type valid[] = { + ARRAY, + NIL + }; + valid_types = valid; + } break; + case PACKED_FLOAT32_ARRAY: { + + static const Type valid[] = { + ARRAY, + NIL + }; + + valid_types = valid; + } break; + case PACKED_FLOAT64_ARRAY: { static const Type valid[] = { ARRAY, @@ -882,9 +930,9 @@ bool Variant::is_zero() const { return _data._int == 0; } break; - case REAL: { + case FLOAT: { - return _data._real == 0; + return _data._float == 0; } break; case STRING: { @@ -1008,14 +1056,24 @@ bool Variant::is_zero() const { return PackedArrayRef<uint8_t>::get_array(_data.packed_array).size() == 0; } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { return PackedArrayRef<int32_t>::get_array(_data.packed_array).size() == 0; } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { + + return PackedArrayRef<int64_t>::get_array(_data.packed_array).size() == 0; + + } break; + case PACKED_FLOAT32_ARRAY: { - return PackedArrayRef<real_t>::get_array(_data.packed_array).size() == 0; + return PackedArrayRef<float>::get_array(_data.packed_array).size() == 0; + + } break; + case PACKED_FLOAT64_ARRAY: { + + return PackedArrayRef<double>::get_array(_data.packed_array).size() == 0; } break; case PACKED_STRING_ARRAY: { @@ -1063,9 +1121,9 @@ bool Variant::is_one() const { return _data._int == 1; } break; - case REAL: { + case FLOAT: { - return _data._real == 1; + return _data._float == 1; } break; case VECTOR2: { @@ -1131,7 +1189,7 @@ void Variant::reference(const Variant &p_variant) { case NIL: case BOOL: case INT: - case REAL: + case FLOAT: break; default: clear(); @@ -1154,9 +1212,9 @@ void Variant::reference(const Variant &p_variant) { _data._int = p_variant._data._int; } break; - case REAL: { + case FLOAT: { - _data._real = p_variant._data._real; + _data._float = p_variant._data._float; } break; case STRING: { @@ -1281,7 +1339,7 @@ void Variant::reference(const Variant &p_variant) { } } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { _data.packed_array = static_cast<PackedArrayRef<int32_t> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { @@ -1289,11 +1347,27 @@ void Variant::reference(const Variant &p_variant) { } } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { + + _data.packed_array = static_cast<PackedArrayRef<int64_t> *>(p_variant._data.packed_array)->reference(); + if (!_data.packed_array) { + _data.packed_array = PackedArrayRef<int64_t>::create(); + } + + } break; + case PACKED_FLOAT32_ARRAY: { + + _data.packed_array = static_cast<PackedArrayRef<float> *>(p_variant._data.packed_array)->reference(); + if (!_data.packed_array) { + _data.packed_array = PackedArrayRef<float>::create(); + } + + } break; + case PACKED_FLOAT64_ARRAY: { - _data.packed_array = static_cast<PackedArrayRef<real_t> *>(p_variant._data.packed_array)->reference(); + _data.packed_array = static_cast<PackedArrayRef<double> *>(p_variant._data.packed_array)->reference(); if (!_data.packed_array) { - _data.packed_array = PackedArrayRef<real_t>::create(); + _data.packed_array = PackedArrayRef<double>::create(); } } break; @@ -1339,7 +1413,7 @@ void Variant::zero() { case NIL: break; case BOOL: this->_data._bool = false; break; case INT: this->_data._int = 0; break; - case REAL: this->_data._real = 0; break; + case FLOAT: this->_data._float = 0; break; case VECTOR2: *reinterpret_cast<Vector2 *>(this->_data._mem) = Vector2(); break; case VECTOR2I: *reinterpret_cast<Vector2i *>(this->_data._mem) = Vector2i(); break; case RECT2: *reinterpret_cast<Rect2 *>(this->_data._mem) = Rect2(); break; @@ -1432,11 +1506,19 @@ void Variant::clear() { PackedArrayRefBase::destroy(_data.packed_array); } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { PackedArrayRefBase::destroy(_data.packed_array); } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { + + PackedArrayRefBase::destroy(_data.packed_array); + } break; + case PACKED_FLOAT32_ARRAY: { + + PackedArrayRefBase::destroy(_data.packed_array); + } break; + case PACKED_FLOAT64_ARRAY: { PackedArrayRefBase::destroy(_data.packed_array); } break; @@ -1470,7 +1552,7 @@ Variant::operator signed int() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1485,7 +1567,7 @@ Variant::operator unsigned int() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1501,7 +1583,7 @@ Variant::operator int64_t() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int64(); default: { @@ -1518,7 +1600,7 @@ Variant::operator long unsigned int() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._real; case STRING: return operator String().to_int(); default: { @@ -1537,7 +1619,7 @@ Variant::operator uint64_t() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1564,7 +1646,7 @@ Variant::operator signed long() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._real; case STRING: return operator String().to_int(); default: { @@ -1582,7 +1664,7 @@ Variant::operator unsigned long() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._real; case STRING: return operator String().to_int(); default: { @@ -1601,7 +1683,7 @@ Variant::operator signed short() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1616,7 +1698,7 @@ Variant::operator unsigned short() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1631,7 +1713,7 @@ Variant::operator signed char() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1646,7 +1728,7 @@ Variant::operator unsigned char() const { case NIL: return 0; case BOOL: return _data._bool ? 1 : 0; case INT: return _data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_int(); default: { @@ -1667,7 +1749,7 @@ Variant::operator float() const { case NIL: return 0; case BOOL: return _data._bool ? 1.0 : 0.0; case INT: return (float)_data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_double(); default: { @@ -1682,7 +1764,7 @@ Variant::operator double() const { case NIL: return 0; case BOOL: return _data._bool ? 1.0 : 0.0; case INT: return (double)_data._int; - case REAL: return _data._real; + case FLOAT: return _data._float; case STRING: return operator String().to_double(); default: { @@ -1725,7 +1807,7 @@ String Variant::stringify(List<const void *> &stack) const { case NIL: return "Null"; case BOOL: return _data._bool ? "True" : "False"; case INT: return itos(_data._int); - case REAL: return rtos(_data._real); + case FLOAT: return rtos(_data._float); case STRING: return *reinterpret_cast<const String *>(_data._mem); case VECTOR2: return "(" + operator Vector2() + ")"; case VECTOR2I: return "(" + operator Vector2i() + ")"; @@ -1847,9 +1929,9 @@ String Variant::stringify(List<const void *> &stack) const { str += "]"; return str; } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { - Vector<int> vec = operator Vector<int>(); + Vector<int32_t> vec = operator Vector<int32_t>(); String str("["); for (int i = 0; i < vec.size(); i++) { @@ -1860,9 +1942,35 @@ String Variant::stringify(List<const void *> &stack) const { str += "]"; return str; } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { - Vector<real_t> vec = operator Vector<real_t>(); + Vector<int64_t> vec = operator Vector<int64_t>(); + String str("["); + for (int i = 0; i < vec.size(); i++) { + + if (i > 0) + str += ", "; + str = str + itos(vec[i]); + } + str += "]"; + return str; + } break; + case PACKED_FLOAT32_ARRAY: { + + Vector<float> vec = operator Vector<float>(); + String str("["); + for (int i = 0; i < vec.size(); i++) { + + if (i > 0) + str += ", "; + str = str + rtos(vec[i]); + } + str += "]"; + return str; + } break; + case PACKED_FLOAT64_ARRAY: { + + Vector<double> vec = operator Vector<double>(); String str("["); for (int i = 0; i < vec.size(); i++) { @@ -2218,11 +2326,17 @@ inline DA _convert_array_from_variant(const Variant &p_variant) { case Variant::PACKED_BYTE_ARRAY: { return _convert_array<DA, Vector<uint8_t> >(p_variant.operator Vector<uint8_t>()); } - case Variant::PACKED_INT_ARRAY: { - return _convert_array<DA, Vector<int> >(p_variant.operator Vector<int>()); + case Variant::PACKED_INT32_ARRAY: { + return _convert_array<DA, Vector<int32_t> >(p_variant.operator Vector<int32_t>()); } - case Variant::PACKED_REAL_ARRAY: { - return _convert_array<DA, Vector<real_t> >(p_variant.operator Vector<real_t>()); + case Variant::PACKED_INT64_ARRAY: { + return _convert_array<DA, Vector<int64_t> >(p_variant.operator Vector<int64_t>()); + } + case Variant::PACKED_FLOAT32_ARRAY: { + return _convert_array<DA, Vector<float> >(p_variant.operator Vector<float>()); + } + case Variant::PACKED_FLOAT64_ARRAY: { + return _convert_array<DA, Vector<double> >(p_variant.operator Vector<double>()); } case Variant::PACKED_STRING_ARRAY: { return _convert_array<DA, Vector<String> >(p_variant.operator Vector<String>()); @@ -2257,19 +2371,35 @@ Variant::operator Vector<uint8_t>() const { else return _convert_array_from_variant<Vector<uint8_t> >(*this); } -Variant::operator Vector<int>() const { +Variant::operator Vector<int32_t>() const { - if (type == PACKED_INT_ARRAY) + if (type == PACKED_INT32_ARRAY) return static_cast<PackedArrayRef<int32_t> *>(_data.packed_array)->array; else return _convert_array_from_variant<Vector<int> >(*this); } -Variant::operator Vector<real_t>() const { +Variant::operator Vector<int64_t>() const { - if (type == PACKED_REAL_ARRAY) - return static_cast<PackedArrayRef<real_t> *>(_data.packed_array)->array; + if (type == PACKED_INT64_ARRAY) + return static_cast<PackedArrayRef<int64_t> *>(_data.packed_array)->array; else - return _convert_array_from_variant<Vector<real_t> >(*this); + return _convert_array_from_variant<Vector<int64_t> >(*this); +} + +Variant::operator Vector<float>() const { + + if (type == PACKED_FLOAT32_ARRAY) + return static_cast<PackedArrayRef<float> *>(_data.packed_array)->array; + else + return _convert_array_from_variant<Vector<float> >(*this); +} + +Variant::operator Vector<double>() const { + + if (type == PACKED_FLOAT64_ARRAY) + return static_cast<PackedArrayRef<double> *>(_data.packed_array)->array; + else + return _convert_array_from_variant<Vector<double> >(*this); } Variant::operator Vector<String>() const { @@ -2388,7 +2518,7 @@ Variant::operator Orientation() const { Variant::operator IP_Address() const { - if (type == PACKED_REAL_ARRAY || type == PACKED_INT_ARRAY || type == PACKED_BYTE_ARRAY) { + if (type == PACKED_FLOAT32_ARRAY || type == PACKED_INT32_ARRAY || type == PACKED_FLOAT64_ARRAY || type == PACKED_INT64_ARRAY || type == PACKED_BYTE_ARRAY) { Vector<int> addr = operator Vector<int>(); if (addr.size() == 4) { @@ -2472,13 +2602,13 @@ Variant::Variant(unsigned char p_char) { } Variant::Variant(float p_float) { - type = REAL; - _data._real = p_float; + type = FLOAT; + _data._float = p_float; } Variant::Variant(double p_double) { - type = REAL; - _data._real = p_double; + type = FLOAT; + _data._float = p_double; } Variant::Variant(const ObjectID &p_id) { @@ -2670,22 +2800,36 @@ Variant::Variant(const Vector<RID> &p_array) { } } -Variant::Variant(const Vector<uint8_t> &p_raw_array) { +Variant::Variant(const Vector<uint8_t> &p_byte_array) { type = PACKED_BYTE_ARRAY; - _data.packed_array = PackedArrayRef<uint8_t>::create(p_raw_array); + _data.packed_array = PackedArrayRef<uint8_t>::create(p_byte_array); +} +Variant::Variant(const Vector<int32_t> &p_int32_array) { + + type = PACKED_INT32_ARRAY; + _data.packed_array = PackedArrayRef<int32_t>::create(p_int32_array); +} + +Variant::Variant(const Vector<int64_t> &p_int64_array) { + + type = PACKED_INT64_ARRAY; + _data.packed_array = PackedArrayRef<int64_t>::create(p_int64_array); } -Variant::Variant(const Vector<int> &p_int_array) { - type = PACKED_INT_ARRAY; - _data.packed_array = PackedArrayRef<int32_t>::create(p_int_array); +Variant::Variant(const Vector<float> &p_float32_array) { + + type = PACKED_FLOAT32_ARRAY; + _data.packed_array = PackedArrayRef<float>::create(p_float32_array); } -Variant::Variant(const Vector<real_t> &p_real_array) { - type = PACKED_REAL_ARRAY; - _data.packed_array = PackedArrayRef<real_t>::create(p_real_array); +Variant::Variant(const Vector<double> &p_float64_array) { + + type = PACKED_FLOAT64_ARRAY; + _data.packed_array = PackedArrayRef<double>::create(p_float64_array); } + Variant::Variant(const Vector<String> &p_string_array) { type = PACKED_STRING_ARRAY; @@ -2777,9 +2921,9 @@ void Variant::operator=(const Variant &p_variant) { _data._int = p_variant._data._int; } break; - case REAL: { + case FLOAT: { - _data._real = p_variant._data._real; + _data._float = p_variant._data._float; } break; case STRING: { @@ -2900,13 +3044,21 @@ void Variant::operator=(const Variant &p_variant) { _data.packed_array = PackedArrayRef<uint8_t>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { _data.packed_array = PackedArrayRef<int32_t>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; - case PACKED_REAL_ARRAY: { + case PACKED_INT64_ARRAY: { - _data.packed_array = PackedArrayRef<real_t>::reference_from(_data.packed_array, p_variant._data.packed_array); + _data.packed_array = PackedArrayRef<int64_t>::reference_from(_data.packed_array, p_variant._data.packed_array); + } break; + case PACKED_FLOAT32_ARRAY: { + + _data.packed_array = PackedArrayRef<float>::reference_from(_data.packed_array, p_variant._data.packed_array); + } break; + case PACKED_FLOAT64_ARRAY: { + + _data.packed_array = PackedArrayRef<double>::reference_from(_data.packed_array, p_variant._data.packed_array); } break; case PACKED_STRING_ARRAY: { @@ -2962,9 +3114,9 @@ uint32_t Variant::hash() const { return _data._int; } break; - case REAL: { + case FLOAT: { - return hash_djb2_one_float(_data._real); + return hash_djb2_one_float(_data._float); } break; case STRING: { @@ -3140,26 +3292,51 @@ uint32_t Variant::hash() const { } } break; - case PACKED_INT_ARRAY: { + case PACKED_INT32_ARRAY: { const Vector<int32_t> &arr = PackedArrayRef<int32_t>::get_array(_data.packed_array); int len = arr.size(); if (likely(len)) { - const int *r = arr.ptr(); - return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int)); + const int32_t *r = arr.ptr(); + return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int32_t)); + } else { + return hash_djb2_one_64(0); + } + + } break; + case PACKED_INT64_ARRAY: { + + const Vector<int64_t> &arr = PackedArrayRef<int64_t>::get_array(_data.packed_array); + int len = arr.size(); + if (likely(len)) { + const int64_t *r = arr.ptr(); + return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int64_t)); } else { return hash_djb2_one_64(0); } } break; - case PACKED_REAL_ARRAY: { + case PACKED_FLOAT32_ARRAY: { - const Vector<real_t> &arr = PackedArrayRef<real_t>::get_array(_data.packed_array); + const Vector<float> &arr = PackedArrayRef<float>::get_array(_data.packed_array); int len = arr.size(); if (likely(len)) { - const real_t *r = arr.ptr(); - return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(real_t)); + const float *r = arr.ptr(); + return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(float)); + } else { + return hash_djb2_one_float(0.0); + } + + } break; + case PACKED_FLOAT64_ARRAY: { + + const Vector<double> &arr = PackedArrayRef<double>::get_array(_data.packed_array); + int len = arr.size(); + + if (likely(len)) { + const double *r = arr.ptr(); + return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(double)); } else { return hash_djb2_one_float(0.0); } @@ -3266,21 +3443,21 @@ uint32_t Variant::hash() const { (hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \ (hash_compare_scalar((p_lhs).a, (p_rhs).a)) -#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \ - const Vector<p_type> &l = *reinterpret_cast<const Vector<p_type> *>(p_lhs); \ - const Vector<p_type> &r = *reinterpret_cast<const Vector<p_type> *>(p_rhs); \ - \ - if (l.size() != r.size()) \ - return false; \ - \ - const p_type *lr = l.ptr(); \ - const p_type *rr = r.ptr(); \ - \ - for (int i = 0; i < l.size(); ++i) { \ - if (!p_compare_func((lr[i]), (rr[i]))) \ - return false; \ - } \ - \ +#define hash_compare_packed_array(p_lhs, p_rhs, p_type, p_compare_func) \ + const Vector<p_type> &l = PackedArrayRef<p_type>::get_array(p_lhs); \ + const Vector<p_type> &r = PackedArrayRef<p_type>::get_array(p_rhs); \ + \ + if (l.size() != r.size()) \ + return false; \ + \ + const p_type *lr = l.ptr(); \ + const p_type *rr = r.ptr(); \ + \ + for (int i = 0; i < l.size(); ++i) { \ + if (!p_compare_func((lr[i]), (rr[i]))) \ + return false; \ + } \ + \ return true bool Variant::hash_compare(const Variant &p_variant) const { @@ -3288,8 +3465,8 @@ bool Variant::hash_compare(const Variant &p_variant) const { return false; switch (type) { - case REAL: { - return hash_compare_scalar(_data._real, p_variant._data._real); + case FLOAT: { + return hash_compare_scalar(_data._float, p_variant._data._float); } break; case VECTOR2: { @@ -3413,20 +3590,25 @@ bool Variant::hash_compare(const Variant &p_variant) const { return true; } break; - case PACKED_REAL_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, real_t, hash_compare_scalar); + // This is for floating point comparisons only. + case PACKED_FLOAT32_ARRAY: { + hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, float, hash_compare_scalar); + } break; + + case PACKED_FLOAT64_ARRAY: { + hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, double, hash_compare_scalar); } break; case PACKED_VECTOR2_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2, hash_compare_vector2); + hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, Vector2, hash_compare_vector2); } break; case PACKED_VECTOR3_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3, hash_compare_vector3); + hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, Vector3, hash_compare_vector3); } break; case PACKED_COLOR_ARRAY: { - hash_compare_pool_array(_data._mem, p_variant._data._mem, Color, hash_compare_color); + hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, Color, hash_compare_color); } break; default: 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); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index a876cff180..e82b491e4b 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -704,29 +704,53 @@ struct _VariantCall { VCALL_PARRMEM0(PackedByteArray, uint8_t, invert); VCALL_PARRMEM2R(PackedByteArray, uint8_t, subarray); - VCALL_PARRMEM0R(PackedIntArray, int32_t, size); - VCALL_PARRMEM0R(PackedIntArray, int32_t, empty); - VCALL_PARRMEM2(PackedIntArray, int32_t, set); - VCALL_PARRMEM1R(PackedIntArray, int32_t, get); - VCALL_PARRMEM1(PackedIntArray, int32_t, push_back); - VCALL_PARRMEM1(PackedIntArray, int32_t, resize); - VCALL_PARRMEM2R(PackedIntArray, int32_t, insert); - VCALL_PARRMEM1(PackedIntArray, int32_t, remove); - VCALL_PARRMEM1(PackedIntArray, int32_t, append); - VCALL_PARRMEM1(PackedIntArray, int32_t, append_array); - VCALL_PARRMEM0(PackedIntArray, int32_t, invert); - - VCALL_PARRMEM0R(PackedRealArray, real_t, size); - VCALL_PARRMEM0R(PackedRealArray, real_t, empty); - VCALL_PARRMEM2(PackedRealArray, real_t, set); - VCALL_PARRMEM1R(PackedRealArray, real_t, get); - VCALL_PARRMEM1(PackedRealArray, real_t, push_back); - VCALL_PARRMEM1(PackedRealArray, real_t, resize); - VCALL_PARRMEM2R(PackedRealArray, real_t, insert); - VCALL_PARRMEM1(PackedRealArray, real_t, remove); - VCALL_PARRMEM1(PackedRealArray, real_t, append); - VCALL_PARRMEM1(PackedRealArray, real_t, append_array); - VCALL_PARRMEM0(PackedRealArray, real_t, invert); + VCALL_PARRMEM0R(PackedInt32Array, int32_t, size); + VCALL_PARRMEM0R(PackedInt32Array, int32_t, empty); + VCALL_PARRMEM2(PackedInt32Array, int32_t, set); + VCALL_PARRMEM1R(PackedInt32Array, int32_t, get); + VCALL_PARRMEM1(PackedInt32Array, int32_t, push_back); + VCALL_PARRMEM1(PackedInt32Array, int32_t, resize); + VCALL_PARRMEM2R(PackedInt32Array, int32_t, insert); + VCALL_PARRMEM1(PackedInt32Array, int32_t, remove); + VCALL_PARRMEM1(PackedInt32Array, int32_t, append); + VCALL_PARRMEM1(PackedInt32Array, int32_t, append_array); + VCALL_PARRMEM0(PackedInt32Array, int32_t, invert); + + VCALL_PARRMEM0R(PackedInt64Array, int64_t, size); + VCALL_PARRMEM0R(PackedInt64Array, int64_t, empty); + VCALL_PARRMEM2(PackedInt64Array, int64_t, set); + VCALL_PARRMEM1R(PackedInt64Array, int64_t, get); + VCALL_PARRMEM1(PackedInt64Array, int64_t, push_back); + VCALL_PARRMEM1(PackedInt64Array, int64_t, resize); + VCALL_PARRMEM2R(PackedInt64Array, int64_t, insert); + VCALL_PARRMEM1(PackedInt64Array, int64_t, remove); + VCALL_PARRMEM1(PackedInt64Array, int64_t, append); + VCALL_PARRMEM1(PackedInt64Array, int64_t, append_array); + VCALL_PARRMEM0(PackedInt64Array, int64_t, invert); + + VCALL_PARRMEM0R(PackedFloat32Array, float, size); + VCALL_PARRMEM0R(PackedFloat32Array, float, empty); + VCALL_PARRMEM2(PackedFloat32Array, float, set); + VCALL_PARRMEM1R(PackedFloat32Array, float, get); + VCALL_PARRMEM1(PackedFloat32Array, float, push_back); + VCALL_PARRMEM1(PackedFloat32Array, float, resize); + VCALL_PARRMEM2R(PackedFloat32Array, float, insert); + VCALL_PARRMEM1(PackedFloat32Array, float, remove); + VCALL_PARRMEM1(PackedFloat32Array, float, append); + VCALL_PARRMEM1(PackedFloat32Array, float, append_array); + VCALL_PARRMEM0(PackedFloat32Array, float, invert); + + VCALL_PARRMEM0R(PackedFloat64Array, double, size); + VCALL_PARRMEM0R(PackedFloat64Array, double, empty); + VCALL_PARRMEM2(PackedFloat64Array, double, set); + VCALL_PARRMEM1R(PackedFloat64Array, double, get); + VCALL_PARRMEM1(PackedFloat64Array, double, push_back); + VCALL_PARRMEM1(PackedFloat64Array, double, resize); + VCALL_PARRMEM2R(PackedFloat64Array, double, insert); + VCALL_PARRMEM1(PackedFloat64Array, double, remove); + VCALL_PARRMEM1(PackedFloat64Array, double, append); + VCALL_PARRMEM1(PackedFloat64Array, double, append_array); + VCALL_PARRMEM0(PackedFloat64Array, double, invert); VCALL_PARRMEM0R(PackedStringArray, String, size); VCALL_PARRMEM0R(PackedStringArray, String, empty); @@ -1261,7 +1285,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i // atomic types case BOOL: return Variant(false); case INT: return 0; - case REAL: return 0.0f; + case FLOAT: return 0.0f; case STRING: return String(); @@ -1293,8 +1317,10 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case ARRAY: return Array(); // 20 case PACKED_BYTE_ARRAY: return PackedByteArray(); - case PACKED_INT_ARRAY: return PackedIntArray(); - case PACKED_REAL_ARRAY: return PackedRealArray(); + case PACKED_INT32_ARRAY: return PackedInt32Array(); + case PACKED_INT64_ARRAY: return PackedInt64Array(); + case PACKED_FLOAT32_ARRAY: return PackedFloat32Array(); + case PACKED_FLOAT64_ARRAY: return PackedFloat64Array(); case PACKED_STRING_ARRAY: return PackedStringArray(); case PACKED_VECTOR2_ARRAY: return PackedVector2Array(); // 25 @@ -1319,7 +1345,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case INT: { return (int64_t(*p_args[0])); } - case REAL: { + case FLOAT: { return real_t(*p_args[0]); } case STRING: { @@ -1359,8 +1385,10 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i // arrays case PACKED_BYTE_ARRAY: return (PackedByteArray(*p_args[0])); - case PACKED_INT_ARRAY: return (PackedIntArray(*p_args[0])); - case PACKED_REAL_ARRAY: return (PackedRealArray(*p_args[0])); + case PACKED_INT32_ARRAY: return (PackedInt32Array(*p_args[0])); + case PACKED_INT64_ARRAY: return (PackedInt64Array(*p_args[0])); + case PACKED_FLOAT32_ARRAY: return (PackedFloat32Array(*p_args[0])); + case PACKED_FLOAT64_ARRAY: return (PackedFloat64Array(*p_args[0])); case PACKED_STRING_ARRAY: return (PackedStringArray(*p_args[0])); case PACKED_VECTOR2_ARRAY: return (PackedVector2Array(*p_args[0])); // 25 @@ -1697,7 +1725,7 @@ void register_variant_methods() { ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray()); ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray()); ADDFUNC0R(STRING, PACKED_STRING_ARRAY, String, bigrams, varray()); - ADDFUNC1R(STRING, REAL, String, similarity, STRING, "text", varray()); + ADDFUNC1R(STRING, FLOAT, String, similarity, STRING, "text", varray()); ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}")); ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray()); @@ -1707,7 +1735,7 @@ void register_variant_methods() { ADDFUNC0R(STRING, STRING, String, capitalize, varray()); ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, rsplit, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); - ADDFUNC2R(STRING, PACKED_REAL_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true)); + ADDFUNC2R(STRING, PACKED_FLOAT32_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true)); ADDFUNC0R(STRING, STRING, String, to_upper, varray()); ADDFUNC0R(STRING, STRING, String, to_lower, varray()); @@ -1754,7 +1782,7 @@ void register_variant_methods() { ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray()); ADDFUNC0R(STRING, BOOL, String, is_valid_filename, varray()); ADDFUNC0R(STRING, INT, String, to_int, varray()); - ADDFUNC0R(STRING, REAL, String, to_float, varray()); + ADDFUNC0R(STRING, FLOAT, String, to_float, varray()); ADDFUNC0R(STRING, INT, String, hex_to_int, varray()); ADDFUNC1R(STRING, STRING, String, pad_decimals, INT, "digits", varray()); ADDFUNC1R(STRING, STRING, String, pad_zeros, INT, "digits", varray()); @@ -1764,45 +1792,45 @@ void register_variant_methods() { ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_ascii, varray()); ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_utf8, varray()); - ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray()); - ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray()); - ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray()); + ADDFUNC0R(VECTOR2, FLOAT, Vector2, angle, varray()); + ADDFUNC1R(VECTOR2, FLOAT, Vector2, angle_to, VECTOR2, "to", varray()); + ADDFUNC1R(VECTOR2, FLOAT, Vector2, angle_to_point, VECTOR2, "to", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, direction_to, VECTOR2, "b", varray()); - ADDFUNC1R(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray()); - ADDFUNC1R(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray()); - ADDFUNC0R(VECTOR2, REAL, Vector2, length, varray()); - ADDFUNC0R(VECTOR2, REAL, Vector2, length_squared, varray()); + ADDFUNC1R(VECTOR2, FLOAT, Vector2, distance_to, VECTOR2, "to", varray()); + ADDFUNC1R(VECTOR2, FLOAT, Vector2, distance_squared_to, VECTOR2, "to", varray()); + ADDFUNC0R(VECTOR2, FLOAT, Vector2, length, varray()); + ADDFUNC0R(VECTOR2, FLOAT, Vector2, length_squared, varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray()); ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray()); ADDFUNC1R(VECTOR2, BOOL, Vector2, is_equal_approx, VECTOR2, "v", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, REAL, "mod", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, FLOAT, "mod", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", REAL, "t", varray()); - ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", REAL, "delta", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray()); + ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", FLOAT, "t", varray()); + ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", FLOAT, "delta", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, FLOAT, "phi", varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, floor, varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, ceil, varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, round, varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray()); - ADDFUNC0R(VECTOR2, REAL, Vector2, aspect, varray()); - ADDFUNC1R(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray()); + ADDFUNC0R(VECTOR2, FLOAT, Vector2, aspect, varray()); + ADDFUNC1R(VECTOR2, FLOAT, Vector2, dot, VECTOR2, "with", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray()); - ADDFUNC1R(VECTOR2, REAL, Vector2, cross, VECTOR2, "with", varray()); + ADDFUNC1R(VECTOR2, FLOAT, Vector2, cross, VECTOR2, "with", varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray()); + ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, FLOAT, "length", varray()); ADDFUNC0R(VECTOR2, VECTOR2, Vector2, sign, varray()); - ADDFUNC0R(VECTOR2I, REAL, Vector2i, aspect, varray()); + ADDFUNC0R(VECTOR2I, FLOAT, Vector2i, aspect, varray()); ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, sign, varray()); ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, abs, varray()); - ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray()); + ADDFUNC0R(RECT2, FLOAT, Rect2, get_area, varray()); ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray()); ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray()); ADDFUNC1R(RECT2, BOOL, Rect2, is_equal_approx, RECT2, "rect", varray()); @@ -1811,9 +1839,9 @@ void register_variant_methods() { ADDFUNC1R(RECT2, RECT2, Rect2, clip, RECT2, "b", varray()); ADDFUNC1R(RECT2, RECT2, Rect2, merge, RECT2, "b", varray()); ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray()); - ADDFUNC1R(RECT2, RECT2, Rect2, grow, REAL, "by", varray()); - ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray()); - ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray()); + ADDFUNC1R(RECT2, RECT2, Rect2, grow, FLOAT, "by", varray()); + ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", FLOAT, "by", varray()); + ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, FLOAT, "left", FLOAT, "top", FLOAT, "right", FLOAT, " bottom", varray()); ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray()); ADDFUNC0R(RECT2I, INT, Rect2i, get_area, varray()); @@ -1831,23 +1859,23 @@ void register_variant_methods() { ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray()); ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray()); - ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray()); + ADDFUNC1R(VECTOR3, FLOAT, Vector3, angle_to, VECTOR3, "to", varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, direction_to, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray()); - ADDFUNC0R(VECTOR3, REAL, Vector3, length, varray()); - ADDFUNC0R(VECTOR3, REAL, Vector3, length_squared, varray()); + ADDFUNC1R(VECTOR3, FLOAT, Vector3, distance_to, VECTOR3, "b", varray()); + ADDFUNC1R(VECTOR3, FLOAT, Vector3, distance_squared_to, VECTOR3, "b", varray()); + ADDFUNC0R(VECTOR3, FLOAT, Vector3, length, varray()); + ADDFUNC0R(VECTOR3, FLOAT, Vector3, length_squared, varray()); ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray()); ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray()); ADDFUNC1R(VECTOR3, BOOL, Vector3, is_equal_approx, VECTOR3, "v", varray()); ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", REAL, "t", varray()); - ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", REAL, "delta", varray()); - ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", FLOAT, "t", varray()); + ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", FLOAT, "delta", varray()); + ADDFUNC1R(VECTOR3, FLOAT, Vector3, dot, VECTOR3, "b", varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray()); ADDFUNC1R(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray()); ADDFUNC0R(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray()); @@ -1855,7 +1883,7 @@ void register_variant_methods() { ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray()); ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray()); ADDFUNC0R(VECTOR3, VECTOR3, Vector3, round, varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmod, REAL, "mod", varray()); + ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmod, FLOAT, "mod", varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmodv, VECTOR3, "modv", varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, project, VECTOR3, "b", varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray()); @@ -1872,27 +1900,27 @@ void register_variant_methods() { ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray()); ADDFUNC1R(PLANE, BOOL, Plane, is_equal_approx, PLANE, "plane", varray()); ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray()); - ADDFUNC1R(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray()); - ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON)); + ADDFUNC1R(PLANE, FLOAT, Plane, distance_to, VECTOR3, "point", varray()); + ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", FLOAT, "epsilon", varray(CMP_EPSILON)); ADDFUNC1R(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray()); ADDFUNC2R(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray()); ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray()); ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray()); - ADDFUNC0R(QUAT, REAL, Quat, length, varray()); - ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray()); + ADDFUNC0R(QUAT, FLOAT, Quat, length, varray()); + ADDFUNC0R(QUAT, FLOAT, Quat, length_squared, varray()); ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray()); ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray()); ADDFUNC1R(QUAT, BOOL, Quat, is_equal_approx, QUAT, "quat", varray()); ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray()); - ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray()); + ADDFUNC1R(QUAT, FLOAT, Quat, dot, QUAT, "b", varray()); ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray()); - ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray()); - ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray()); - ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray()); + ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", FLOAT, "t", varray()); + ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", FLOAT, "t", varray()); + ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", FLOAT, "t", varray()); ADDFUNC0R(QUAT, VECTOR3, Quat, get_euler, varray()); ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray()); - ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray()); + ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", FLOAT, "angle", varray()); ADDFUNC0R(COLOR, INT, Color, to_argb32, varray()); ADDFUNC0R(COLOR, INT, Color, to_abgr32, varray()); @@ -1902,12 +1930,12 @@ void register_variant_methods() { ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray()); ADDFUNC0R(COLOR, COLOR, Color, inverted, varray()); ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray()); - ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray()); + ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", FLOAT, "t", varray()); ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray()); - ADDFUNC1R(COLOR, COLOR, Color, lightened, REAL, "amount", varray()); - ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray()); + ADDFUNC1R(COLOR, COLOR, Color, lightened, FLOAT, "amount", varray()); + ADDFUNC1R(COLOR, COLOR, Color, darkened, FLOAT, "amount", varray()); ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true)); - ADDFUNC4R(COLOR, COLOR, Color, from_hsv, REAL, "h", REAL, "s", REAL, "v", REAL, "a", varray(1.0)); + ADDFUNC4R(COLOR, COLOR, Color, from_hsv, FLOAT, "h", FLOAT, "s", FLOAT, "v", FLOAT, "a", varray(1.0)); ADDFUNC1R(COLOR, BOOL, Color, is_equal_approx, COLOR, "color", varray()); ADDFUNC0R(_RID, INT, RID, get_id, varray()); @@ -2001,27 +2029,49 @@ void register_variant_methods() { ADDFUNC1R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, compress, INT, "compression_mode", varray(0)); ADDFUNC2R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0)); - ADDFUNC0R(PACKED_INT_ARRAY, INT, PackedIntArray, size, varray()); - ADDFUNC0R(PACKED_INT_ARRAY, BOOL, PackedIntArray, empty, varray()); - ADDFUNC2(PACKED_INT_ARRAY, NIL, PackedIntArray, set, INT, "idx", INT, "integer", varray()); - ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, push_back, INT, "integer", varray()); - ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, append, INT, "integer", varray()); - ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, append_array, PACKED_INT_ARRAY, "array", varray()); - ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_INT_ARRAY, INT, PackedIntArray, insert, INT, "idx", INT, "integer", varray()); - ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, resize, INT, "idx", varray()); - ADDFUNC0(PACKED_INT_ARRAY, NIL, PackedIntArray, invert, varray()); - - ADDFUNC0R(PACKED_REAL_ARRAY, INT, PackedRealArray, size, varray()); - ADDFUNC0R(PACKED_REAL_ARRAY, BOOL, PackedRealArray, empty, varray()); - ADDFUNC2(PACKED_REAL_ARRAY, NIL, PackedRealArray, set, INT, "idx", REAL, "value", varray()); - ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, push_back, REAL, "value", varray()); - ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, append, REAL, "value", varray()); - ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, append_array, PACKED_REAL_ARRAY, "array", varray()); - ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_REAL_ARRAY, INT, PackedRealArray, insert, INT, "idx", REAL, "value", varray()); - ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, resize, INT, "idx", varray()); - ADDFUNC0(PACKED_REAL_ARRAY, NIL, PackedRealArray, invert, varray()); + ADDFUNC0R(PACKED_INT32_ARRAY, INT, PackedInt32Array, size, varray()); + ADDFUNC0R(PACKED_INT32_ARRAY, BOOL, PackedInt32Array, empty, varray()); + ADDFUNC2(PACKED_INT32_ARRAY, NIL, PackedInt32Array, set, INT, "idx", INT, "integer", varray()); + ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, push_back, INT, "integer", varray()); + ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, append, INT, "integer", varray()); + ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, append_array, PACKED_INT32_ARRAY, "array", varray()); + ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, remove, INT, "idx", varray()); + ADDFUNC2R(PACKED_INT32_ARRAY, INT, PackedInt32Array, insert, INT, "idx", INT, "integer", varray()); + ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, resize, INT, "idx", varray()); + ADDFUNC0(PACKED_INT32_ARRAY, NIL, PackedInt32Array, invert, varray()); + + ADDFUNC0R(PACKED_INT64_ARRAY, INT, PackedInt64Array, size, varray()); + ADDFUNC0R(PACKED_INT64_ARRAY, BOOL, PackedInt64Array, empty, varray()); + ADDFUNC2(PACKED_INT64_ARRAY, NIL, PackedInt64Array, set, INT, "idx", INT, "integer", varray()); + ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, push_back, INT, "integer", varray()); + ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, append, INT, "integer", varray()); + ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, append_array, PACKED_INT64_ARRAY, "array", varray()); + ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, remove, INT, "idx", varray()); + ADDFUNC2R(PACKED_INT64_ARRAY, INT, PackedInt64Array, insert, INT, "idx", INT, "integer", varray()); + ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, resize, INT, "idx", varray()); + ADDFUNC0(PACKED_INT64_ARRAY, NIL, PackedInt64Array, invert, varray()); + + ADDFUNC0R(PACKED_FLOAT32_ARRAY, INT, PackedFloat32Array, size, varray()); + ADDFUNC0R(PACKED_FLOAT32_ARRAY, BOOL, PackedFloat32Array, empty, varray()); + ADDFUNC2(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, set, INT, "idx", FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, push_back, FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, append, FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, append_array, PACKED_FLOAT32_ARRAY, "array", varray()); + ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, remove, INT, "idx", varray()); + ADDFUNC2R(PACKED_FLOAT32_ARRAY, INT, PackedFloat32Array, insert, INT, "idx", FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, resize, INT, "idx", varray()); + ADDFUNC0(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, invert, varray()); + + ADDFUNC0R(PACKED_FLOAT64_ARRAY, INT, PackedFloat64Array, size, varray()); + ADDFUNC0R(PACKED_FLOAT64_ARRAY, BOOL, PackedFloat64Array, empty, varray()); + ADDFUNC2(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, set, INT, "idx", FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, push_back, FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, append, FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, append_array, PACKED_FLOAT64_ARRAY, "array", varray()); + ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, remove, INT, "idx", varray()); + ADDFUNC2R(PACKED_FLOAT64_ARRAY, INT, PackedFloat64Array, insert, INT, "idx", FLOAT, "value", varray()); + ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, resize, INT, "idx", varray()); + ADDFUNC0(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, invert, varray()); ADDFUNC0R(PACKED_STRING_ARRAY, INT, PackedStringArray, size, varray()); ADDFUNC0R(PACKED_STRING_ARRAY, BOOL, PackedStringArray, empty, varray()); @@ -2069,7 +2119,7 @@ void register_variant_methods() { //pointerbased - ADDFUNC0R(AABB, REAL, AABB, get_area, varray()); + ADDFUNC0R(AABB, FLOAT, AABB, get_area, varray()); ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray()); ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray()); ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray()); @@ -2081,94 +2131,94 @@ void register_variant_methods() { ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray()); ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray()); ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray()); - ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray()); + ADDFUNC1R(AABB, AABB, AABB, grow, FLOAT, "by", varray()); ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray()); ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray()); ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray()); - ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray()); + ADDFUNC0R(AABB, FLOAT, AABB, get_longest_axis_size, varray()); ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray()); ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray()); - ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray()); + ADDFUNC0R(AABB, FLOAT, AABB, get_shortest_axis_size, varray()); ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray()); - ADDFUNC0R(TRANSFORM2D, REAL, Transform2D, get_rotation, varray()); + ADDFUNC0R(TRANSFORM2D, FLOAT, Transform2D, get_rotation, varray()); ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray()); ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray()); - ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray()); + ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, FLOAT, "phi", varray()); ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray()); ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray()); ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform, NIL, "v", varray()); ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform_inv, NIL, "v", varray()); ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform, VECTOR2, "v", varray()); ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform_inv, VECTOR2, "v", varray()); - ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray()); + ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", FLOAT, "weight", varray()); ADDFUNC1R(TRANSFORM2D, BOOL, Transform2D, is_equal_approx, TRANSFORM2D, "transform", varray()); ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray()); ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray()); ADDFUNC0R(BASIS, BASIS, Basis, orthonormalized, varray()); - ADDFUNC0R(BASIS, REAL, Basis, determinant, varray()); - ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray()); + ADDFUNC0R(BASIS, FLOAT, Basis, determinant, varray()); + ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); ADDFUNC1R(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); ADDFUNC0R(BASIS, VECTOR3, Basis, get_scale, varray()); ADDFUNC0R(BASIS, VECTOR3, Basis, get_euler, varray()); - ADDFUNC1R(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray()); - ADDFUNC1R(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray()); - ADDFUNC1R(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray()); + ADDFUNC1R(BASIS, FLOAT, Basis, tdotx, VECTOR3, "with", varray()); + ADDFUNC1R(BASIS, FLOAT, Basis, tdoty, VECTOR3, "with", varray()); + ADDFUNC1R(BASIS, FLOAT, Basis, tdotz, VECTOR3, "with", varray()); ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray()); ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray()); ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray()); - ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", REAL, "t", varray()); - ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", REAL, "epsilon", varray(CMP_EPSILON)); // TODO: Replace in 4.0, see other TODO. + ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", FLOAT, "t", varray()); + ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", FLOAT, "epsilon", varray(CMP_EPSILON)); // TODO: Replace in 4.0, see other TODO. ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray()); ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray()); ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray()); ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray()); - ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray()); + ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray()); ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "offset", varray()); ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray()); - ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray()); + ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", FLOAT, "weight", varray()); ADDFUNC1R(TRANSFORM, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray()); ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray()); ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray()); /* REGISTER CONSTRUCTORS */ - _VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::REAL, "y", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::FLOAT, "y", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::Vector2i_init1, Variant::VECTOR2I, "x", Variant::INT, "y", Variant::INT); _VariantCall::add_constructor(_VariantCall::Rect2_init1, Variant::RECT2, "position", Variant::VECTOR2, "size", Variant::VECTOR2); - _VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::REAL, "y", Variant::REAL, "width", Variant::REAL, "height", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::FLOAT, "y", Variant::FLOAT, "width", Variant::FLOAT, "height", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::Rect2i_init1, Variant::RECT2I, "position", Variant::VECTOR2, "size", Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Rect2i_init2, Variant::RECT2I, "x", Variant::INT, "y", Variant::INT, "width", Variant::INT, "height", Variant::INT); - _VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::REAL, "position", Variant::VECTOR2); + _VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::FLOAT, "position", Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Transform2D_init3, Variant::TRANSFORM2D, "x_axis", Variant::VECTOR2, "y_axis", Variant::VECTOR2, "origin", Variant::VECTOR2); - _VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::FLOAT, "y", Variant::FLOAT, "z", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::Vector3i_init1, Variant::VECTOR3I, "x", Variant::INT, "y", Variant::INT, "z", Variant::INT); - _VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::REAL, "b", Variant::REAL, "c", Variant::REAL, "d", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::FLOAT, "b", Variant::FLOAT, "c", Variant::FLOAT, "d", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::Plane_init2, Variant::PLANE, "v1", Variant::VECTOR3, "v2", Variant::VECTOR3, "v3", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL, "w", Variant::REAL); - _VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::FLOAT, "y", Variant::FLOAT, "z", Variant::FLOAT, "w", Variant::FLOAT); + _VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::Quat_init3, Variant::QUAT, "euler", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL); - _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::FLOAT, "g", Variant::FLOAT, "b", Variant::FLOAT, "a", Variant::FLOAT); + _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::FLOAT, "g", Variant::FLOAT, "b", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::FLOAT); _VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 37f890e069..8bdd8389dc 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -41,7 +41,7 @@ #define CASE_TYPE_ALL_BUT_INT(PREFIX, OP) \ CASE_TYPE(PREFIX, OP, NIL) \ CASE_TYPE(PREFIX, OP, BOOL) \ - CASE_TYPE(PREFIX, OP, REAL) \ + CASE_TYPE(PREFIX, OP, FLOAT) \ CASE_TYPE(PREFIX, OP, STRING) \ CASE_TYPE(PREFIX, OP, VECTOR2) \ CASE_TYPE(PREFIX, OP, VECTOR2I) \ @@ -65,8 +65,10 @@ CASE_TYPE(PREFIX, OP, DICTIONARY) \ CASE_TYPE(PREFIX, OP, ARRAY) \ CASE_TYPE(PREFIX, OP, PACKED_BYTE_ARRAY) \ - CASE_TYPE(PREFIX, OP, PACKED_INT_ARRAY) \ - CASE_TYPE(PREFIX, OP, PACKED_REAL_ARRAY) \ + CASE_TYPE(PREFIX, OP, PACKED_INT32_ARRAY) \ + CASE_TYPE(PREFIX, OP, PACKED_INT64_ARRAY) \ + CASE_TYPE(PREFIX, OP, PACKED_FLOAT32_ARRAY) \ + CASE_TYPE(PREFIX, OP, PACKED_FLOAT64_ARRAY) \ CASE_TYPE(PREFIX, OP, PACKED_STRING_ARRAY) \ CASE_TYPE(PREFIX, OP, PACKED_VECTOR2_ARRAY) \ CASE_TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY) \ @@ -80,7 +82,7 @@ TYPE(PREFIX, OP, NIL), \ TYPE(PREFIX, OP, BOOL), \ TYPE(PREFIX, OP, INT), \ - TYPE(PREFIX, OP, REAL), \ + TYPE(PREFIX, OP, FLOAT), \ TYPE(PREFIX, OP, STRING), \ TYPE(PREFIX, OP, VECTOR2), \ TYPE(PREFIX, OP, VECTOR2I), \ @@ -104,8 +106,10 @@ TYPE(PREFIX, OP, DICTIONARY), \ TYPE(PREFIX, OP, ARRAY), \ TYPE(PREFIX, OP, PACKED_BYTE_ARRAY), \ - TYPE(PREFIX, OP, PACKED_INT_ARRAY), \ - TYPE(PREFIX, OP, PACKED_REAL_ARRAY), \ + TYPE(PREFIX, OP, PACKED_INT32_ARRAY), \ + TYPE(PREFIX, OP, PACKED_INT64_ARRAY), \ + TYPE(PREFIX, OP, PACKED_FLOAT32_ARRAY), \ + TYPE(PREFIX, OP, PACKED_FLOAT64_ARRAY), \ TYPE(PREFIX, OP, PACKED_STRING_ARRAY), \ TYPE(PREFIX, OP, PACKED_VECTOR2_ARRAY), \ TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY), \ @@ -177,21 +181,21 @@ bool Variant::booleanize() const { return; \ } -#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _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); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \ + if (p_b.type == FLOAT) _RETURN(p_a._data.m_type m_op p_b._data._float); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _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 == NIL) _RETURN(!(p_b.type m_op NIL)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \ + if (p_b.type == FLOAT) _RETURN(p_a._data.m_type m_op p_b._data._float); \ + if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \ + \ + _RETURN_FAIL \ }; #ifdef DEBUG_ENABLED @@ -204,23 +208,23 @@ bool Variant::booleanize() const { } \ _RETURN(p_a._data.m_type / p_b._data._int); \ } \ - if (p_b.type == REAL) { \ - if (p_b._data._real == 0) { \ + if (p_b.type == FLOAT) { \ + if (p_b._data._float == 0) { \ r_valid = false; \ _RETURN("Division By Zero"); \ } \ - _RETURN(p_a._data.m_type / p_b._data._real); \ + _RETURN(p_a._data.m_type / p_b._data._float); \ } \ \ _RETURN_FAIL \ }; #else -#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _RETURN(p_a._data.m_type / p_b._data._int); \ - if (p_b.type == REAL) _RETURN(p_a._data.m_type / p_b._data._real); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) _RETURN(p_a._data.m_type / p_b._data._int); \ + if (p_b.type == FLOAT) _RETURN(p_a._data.m_type / p_b._data._float); \ + \ + _RETURN_FAIL \ }; #endif @@ -237,7 +241,7 @@ bool Variant::booleanize() const { #define DEFAULT_OP_NUM_VEC(m_prefix, m_op_name, m_name, m_op, m_type) \ CASE_TYPE(m_prefix, m_op_name, m_name) { \ if (p_b.type == INT) _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 == FLOAT) _RETURN(p_a._data.m_type m_op p_b._data._float); \ if (p_b.type == VECTOR2) _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector2 *>(p_b._data._mem)); \ if (p_b.type == VECTOR3) _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector3 *>(p_b._data._mem)); \ if (p_b.type == VECTOR2I) _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector2 *>(p_b._data._mem)); \ @@ -332,7 +336,7 @@ bool Variant::booleanize() const { CASE_TYPE(m_prefix, m_op_name, m_name) { \ if (p_b.type == m_name) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const m_type *>(p_b._data._mem)); \ if (p_b.type == INT) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._int); \ - if (p_b.type == REAL) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._real); \ + if (p_b.type == FLOAT) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._float); \ \ _RETURN_FAIL \ } @@ -496,7 +500,7 @@ 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_NUM_NULL(math, OP_EQUAL, FLOAT, ==, _float); DEFAULT_OP_STR_NULL(math, OP_EQUAL, STRING, ==, String); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR2, ==, Vector2); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR2I, ==, Vector2i); @@ -516,8 +520,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, _RID, ==, RID); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_BYTE_ARRAY, uint8_t); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT_ARRAY, int); - DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_REAL_ARRAY, real_t); + DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT32_ARRAY, int32_t); + DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT64_ARRAY, int64_t); + DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_FLOAT32_ARRAY, float); + DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_FLOAT64_ARRAY, double); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_STRING_ARRAY, String); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_VECTOR3_ARRAY, Vector3); @@ -593,7 +599,7 @@ 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_NUM_NULL(math, OP_NOT_EQUAL, FLOAT, !=, _float); DEFAULT_OP_STR_NULL(math, OP_NOT_EQUAL, STRING, !=, String); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR2, !=, Vector2); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR2I, !=, Vector2i); @@ -613,8 +619,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, _RID, !=, RID); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_BYTE_ARRAY, uint8_t); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT_ARRAY, int); - DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_REAL_ARRAY, real_t); + DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT32_ARRAY, int32_t); + DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT64_ARRAY, int64_t); + DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_FLOAT32_ARRAY, float); + DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_FLOAT64_ARRAY, double); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_STRING_ARRAY, String); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_VECTOR3_ARRAY, Vector3); @@ -664,7 +672,7 @@ 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_NUM(math, OP_LESS, FLOAT, <, _float); DEFAULT_OP_STR(math, OP_LESS, STRING, <, String); DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2, <, Vector2); DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2I, <, Vector2i); @@ -672,8 +680,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR3I, <, Vector3i); DEFAULT_OP_LOCALMEM(math, OP_LESS, _RID, <, RID); DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_BYTE_ARRAY, uint8_t); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT_ARRAY, int); - DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_REAL_ARRAY, real_t); + DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT32_ARRAY, int32_t); + DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT64_ARRAY, int64_t); + DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_FLOAT32_ARRAY, float); + DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_FLOAT64_ARRAY, double); DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_STRING_ARRAY, String); DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_VECTOR2_ARRAY, Vector3); DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_VECTOR3_ARRAY, Vector3); @@ -703,7 +713,7 @@ 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_NUM(math, OP_LESS_EQUAL, FLOAT, <=, _float); 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); @@ -730,8 +740,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS_EQUAL, DICTIONARY) CASE_TYPE(math, OP_LESS_EQUAL, ARRAY) CASE_TYPE(math, OP_LESS_EQUAL, PACKED_BYTE_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT_ARRAY); - CASE_TYPE(math, OP_LESS_EQUAL, PACKED_REAL_ARRAY); + CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT32_ARRAY); + CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT64_ARRAY); + CASE_TYPE(math, OP_LESS_EQUAL, PACKED_FLOAT32_ARRAY); + CASE_TYPE(math, OP_LESS_EQUAL, PACKED_FLOAT64_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, PACKED_STRING_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, PACKED_VECTOR2_ARRAY); CASE_TYPE(math, OP_LESS_EQUAL, PACKED_VECTOR3_ARRAY); @@ -779,7 +791,7 @@ 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_NUM(math, OP_GREATER, FLOAT, >, _float); 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); @@ -787,8 +799,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR3I, <, Vector3i); DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, _RID, <, RID); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_BYTE_ARRAY, uint8_t); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT_ARRAY, int); - DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_REAL_ARRAY, real_t); + DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT32_ARRAY, int32_t); + DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT64_ARRAY, int64_t); + DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_FLOAT32_ARRAY, float); + DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_FLOAT64_ARRAY, double); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_STRING_ARRAY, String); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_VECTOR2_ARRAY, Vector3); DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_VECTOR3_ARRAY, Vector3); @@ -821,7 +835,7 @@ 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_NUM(math, OP_GREATER_EQUAL, FLOAT, >=, _float); 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); @@ -848,8 +862,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER_EQUAL, DICTIONARY) CASE_TYPE(math, OP_GREATER_EQUAL, ARRAY) CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_BYTE_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT_ARRAY); - CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_REAL_ARRAY); + CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT32_ARRAY); + CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT64_ARRAY); + CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_FLOAT32_ARRAY); + CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_FLOAT64_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_STRING_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_VECTOR2_ARRAY); CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_VECTOR3_ARRAY); @@ -876,7 +892,7 @@ 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_NUM(math, OP_ADD, FLOAT, +, _float); DEFAULT_OP_STR(math, OP_ADD, STRING, +, String); DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2, +, Vector2); DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2I, +, Vector2i); @@ -886,8 +902,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM(math, OP_ADD, COLOR, +, Color); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_BYTE_ARRAY, uint8_t); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT_ARRAY, int); - DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_REAL_ARRAY, real_t); + DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT32_ARRAY, int32_t); + DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT64_ARRAY, int64_t); + DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_FLOAT32_ARRAY, float); + DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_FLOAT64_ARRAY, double); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_STRING_ARRAY, String); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_VECTOR2_ARRAY, Vector2); DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_VECTOR3_ARRAY, Vector3); @@ -915,7 +933,7 @@ 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_NUM(math, OP_SUBTRACT, FLOAT, -, _float); DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2, -, Vector2); DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2I, -, Vector2i); DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3, -, Vector3); @@ -943,8 +961,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SUBTRACT, DICTIONARY) CASE_TYPE(math, OP_SUBTRACT, ARRAY) CASE_TYPE(math, OP_SUBTRACT, PACKED_BYTE_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, PACKED_INT_ARRAY); - CASE_TYPE(math, OP_SUBTRACT, PACKED_REAL_ARRAY); + CASE_TYPE(math, OP_SUBTRACT, PACKED_INT32_ARRAY); + CASE_TYPE(math, OP_SUBTRACT, PACKED_INT64_ARRAY); + CASE_TYPE(math, OP_SUBTRACT, PACKED_FLOAT32_ARRAY); + CASE_TYPE(math, OP_SUBTRACT, PACKED_FLOAT64_ARRAY); CASE_TYPE(math, OP_SUBTRACT, PACKED_STRING_ARRAY); CASE_TYPE(math, OP_SUBTRACT, PACKED_VECTOR2_ARRAY); CASE_TYPE(math, OP_SUBTRACT, PACKED_VECTOR3_ARRAY); @@ -973,8 +993,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, case QUAT: { _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * *reinterpret_cast<const Quat *>(p_b._data._mem)); } - case REAL: { - _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._real); + case FLOAT: { + _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._float); } default: _RETURN_FAIL; } @@ -1005,7 +1025,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, } DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, INT, *, _int); - DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, REAL, *, _real); + DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, FLOAT, *, _float); 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); @@ -1029,8 +1049,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MULTIPLY, DICTIONARY) CASE_TYPE(math, OP_MULTIPLY, ARRAY) CASE_TYPE(math, OP_MULTIPLY, PACKED_BYTE_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, PACKED_INT_ARRAY); - CASE_TYPE(math, OP_MULTIPLY, PACKED_REAL_ARRAY); + CASE_TYPE(math, OP_MULTIPLY, PACKED_INT32_ARRAY); + CASE_TYPE(math, OP_MULTIPLY, PACKED_INT64_ARRAY); + CASE_TYPE(math, OP_MULTIPLY, PACKED_FLOAT32_ARRAY); + CASE_TYPE(math, OP_MULTIPLY, PACKED_FLOAT64_ARRAY); CASE_TYPE(math, OP_MULTIPLY, PACKED_STRING_ARRAY); CASE_TYPE(math, OP_MULTIPLY, PACKED_VECTOR2_ARRAY); CASE_TYPE(math, OP_MULTIPLY, PACKED_VECTOR3_ARRAY); @@ -1040,19 +1062,19 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, SWITCH_OP(math, OP_DIVIDE, p_a.type) { CASE_TYPE(math, OP_DIVIDE, QUAT) { - if (p_b.type != REAL) + if (p_b.type != FLOAT) _RETURN_FAIL; #ifdef DEBUG_ENABLED - if (p_b._data._real == 0) { + if (p_b._data._float == 0) { r_valid = false; _RETURN("Division By Zero"); } #endif - _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._real); + _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._float); } DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, INT, _int); - DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, REAL, _real); + DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, FLOAT, _float); 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); @@ -1079,8 +1101,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_DIVIDE, DICTIONARY) CASE_TYPE(math, OP_DIVIDE, ARRAY) CASE_TYPE(math, OP_DIVIDE, PACKED_BYTE_ARRAY); - CASE_TYPE(math, OP_DIVIDE, PACKED_INT_ARRAY); - CASE_TYPE(math, OP_DIVIDE, PACKED_REAL_ARRAY); + CASE_TYPE(math, OP_DIVIDE, PACKED_INT32_ARRAY); + CASE_TYPE(math, OP_DIVIDE, PACKED_INT64_ARRAY); + CASE_TYPE(math, OP_DIVIDE, PACKED_FLOAT32_ARRAY); + CASE_TYPE(math, OP_DIVIDE, PACKED_FLOAT64_ARRAY); CASE_TYPE(math, OP_DIVIDE, PACKED_STRING_ARRAY); CASE_TYPE(math, OP_DIVIDE, PACKED_VECTOR2_ARRAY); CASE_TYPE(math, OP_DIVIDE, PACKED_VECTOR3_ARRAY); @@ -1090,7 +1114,7 @@ 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_NUM_POS(math, OP_POSITIVE, FLOAT, _float); 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, PLANE, Plane); @@ -1118,8 +1142,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_POSITIVE, DICTIONARY) CASE_TYPE(math, OP_POSITIVE, ARRAY) CASE_TYPE(math, OP_POSITIVE, PACKED_BYTE_ARRAY) - CASE_TYPE(math, OP_POSITIVE, PACKED_INT_ARRAY) - CASE_TYPE(math, OP_POSITIVE, PACKED_REAL_ARRAY) + CASE_TYPE(math, OP_POSITIVE, PACKED_INT32_ARRAY) + CASE_TYPE(math, OP_POSITIVE, PACKED_INT64_ARRAY) + CASE_TYPE(math, OP_POSITIVE, PACKED_FLOAT32_ARRAY) + CASE_TYPE(math, OP_POSITIVE, PACKED_FLOAT64_ARRAY) CASE_TYPE(math, OP_POSITIVE, PACKED_STRING_ARRAY) CASE_TYPE(math, OP_POSITIVE, PACKED_VECTOR2_ARRAY) CASE_TYPE(math, OP_POSITIVE, PACKED_VECTOR3_ARRAY) @@ -1129,7 +1155,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, SWITCH_OP(math, OP_NEGATE, p_a.type) { DEFAULT_OP_NUM_NEG(math, OP_NEGATE, INT, _int); - DEFAULT_OP_NUM_NEG(math, OP_NEGATE, REAL, _real); + DEFAULT_OP_NUM_NEG(math, OP_NEGATE, FLOAT, _float); DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2, Vector2); DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2I, Vector2i); @@ -1158,8 +1184,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_NEGATE, DICTIONARY) CASE_TYPE(math, OP_NEGATE, ARRAY) CASE_TYPE(math, OP_NEGATE, PACKED_BYTE_ARRAY) - CASE_TYPE(math, OP_NEGATE, PACKED_INT_ARRAY) - CASE_TYPE(math, OP_NEGATE, PACKED_REAL_ARRAY) + CASE_TYPE(math, OP_NEGATE, PACKED_INT32_ARRAY) + CASE_TYPE(math, OP_NEGATE, PACKED_INT64_ARRAY) + CASE_TYPE(math, OP_NEGATE, PACKED_FLOAT32_ARRAY) + CASE_TYPE(math, OP_NEGATE, PACKED_FLOAT64_ARRAY) CASE_TYPE(math, OP_NEGATE, PACKED_STRING_ARRAY) CASE_TYPE(math, OP_NEGATE, PACKED_VECTOR2_ARRAY) CASE_TYPE(math, OP_NEGATE, PACKED_VECTOR3_ARRAY) @@ -1201,7 +1229,7 @@ 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, FLOAT) CASE_TYPE(math, OP_MODULE, VECTOR2) CASE_TYPE(math, OP_MODULE, VECTOR2I) CASE_TYPE(math, OP_MODULE, RECT2) @@ -1225,8 +1253,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MODULE, DICTIONARY) CASE_TYPE(math, OP_MODULE, ARRAY) CASE_TYPE(math, OP_MODULE, PACKED_BYTE_ARRAY) - CASE_TYPE(math, OP_MODULE, PACKED_INT_ARRAY) - CASE_TYPE(math, OP_MODULE, PACKED_REAL_ARRAY) + CASE_TYPE(math, OP_MODULE, PACKED_INT32_ARRAY) + CASE_TYPE(math, OP_MODULE, PACKED_INT64_ARRAY) + CASE_TYPE(math, OP_MODULE, PACKED_FLOAT32_ARRAY) + CASE_TYPE(math, OP_MODULE, PACKED_FLOAT64_ARRAY) CASE_TYPE(math, OP_MODULE, PACKED_STRING_ARRAY) CASE_TYPE(math, OP_MODULE, PACKED_VECTOR2_ARRAY) CASE_TYPE(math, OP_MODULE, PACKED_VECTOR3_ARRAY) @@ -1363,13 +1393,13 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->y = p_value._data._int; valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Vector2 *v = reinterpret_cast<Vector2 *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; + v->x = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; + v->y = p_value._data._float; valid = true; } } @@ -1385,13 +1415,13 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->y = p_value._data._int; valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Vector2i *v = reinterpret_cast<Vector2i *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; + v->x = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; + v->y = p_value._data._float; valid = true; } } @@ -1462,16 +1492,16 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->z = p_value._data._int; valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; + v->x = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; + v->y = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; + v->z = p_value._data._float; valid = true; } } @@ -1491,16 +1521,16 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->z = p_value._data._int; valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; + v->x = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; + v->y = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; + v->z = p_value._data._float; valid = true; } } @@ -1523,19 +1553,19 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->d = p_value._data._int; valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Plane *v = reinterpret_cast<Plane *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { - v->normal.x = p_value._data._real; + v->normal.x = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->y) { - v->normal.y = p_value._data._real; + v->normal.y = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->z) { - v->normal.z = p_value._data._real; + v->normal.z = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->d) { - v->d = p_value._data._real; + v->d = p_value._data._float; valid = true; } @@ -1565,19 +1595,19 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->w = p_value._data._int; valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Quat *v = reinterpret_cast<Quat *>(_data._mem); if (p_index == CoreStringNames::singleton->x) { - v->x = p_value._data._real; + v->x = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->y) { - v->y = p_value._data._real; + v->y = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->z) { - v->z = p_value._data._real; + v->z = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->w) { - v->w = p_value._data._real; + v->w = p_value._data._float; valid = true; } } @@ -1666,40 +1696,40 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool v->set_hsv(v->get_h(), v->get_v(), p_value._data._int, v->a); valid = true; } - } else if (p_value.type == Variant::REAL) { + } else if (p_value.type == Variant::FLOAT) { Color *v = reinterpret_cast<Color *>(_data._mem); if (p_index == CoreStringNames::singleton->r) { - v->r = p_value._data._real; + v->r = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->g) { - v->g = p_value._data._real; + v->g = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->b) { - v->b = p_value._data._real; + v->b = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->a) { - v->a = p_value._data._real; + v->a = p_value._data._float; valid = true; } else if (p_index == CoreStringNames::singleton->r8) { - v->r = p_value._data._real / 255.0; + v->r = p_value._data._float / 255.0; valid = true; } else if (p_index == CoreStringNames::singleton->g8) { - v->g = p_value._data._real / 255.0; + v->g = p_value._data._float / 255.0; valid = true; } else if (p_index == CoreStringNames::singleton->b8) { - v->b = p_value._data._real / 255.0; + v->b = p_value._data._float / 255.0; valid = true; } else if (p_index == CoreStringNames::singleton->a8) { - v->a = p_value._data._real / 255.0; + v->a = p_value._data._float / 255.0; valid = true; } else if (p_index == CoreStringNames::singleton->h) { - v->set_hsv(p_value._data._real, v->get_s(), v->get_v(), v->a); + v->set_hsv(p_value._data._float, v->get_s(), v->get_v(), v->a); valid = true; } else if (p_index == CoreStringNames::singleton->s) { - v->set_hsv(v->get_h(), p_value._data._real, v->get_v(), v->a); + v->set_hsv(v->get_h(), p_value._data._float, v->get_v(), v->a); valid = true; } else if (p_index == CoreStringNames::singleton->v) { - v->set_hsv(v->get_h(), v->get_s(), p_value._data._real, v->a); + v->set_hsv(v->get_h(), v->get_s(), p_value._data._float, v->a); valid = true; } } @@ -1934,28 +1964,28 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { return Variant(); } -#define DEFAULT_OP_ARRAY_CMD(m_name, m_type, skip_test, cmd) \ - case m_name: { \ - skip_test; \ - \ - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { \ - int index = p_index; \ - m_type *arr = reinterpret_cast<m_type *>(_data._mem); \ - \ - if (index < 0) \ - index += arr->size(); \ - if (index >= 0 && index < arr->size()) { \ - valid = true; \ - cmd; \ - } \ - } \ +#define DEFAULT_OP_ARRAY_CMD(m_name, m_type, skip_test, cmd) \ + case m_name: { \ + skip_test; \ + \ + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \ + int index = p_index; \ + m_type *arr = reinterpret_cast<m_type *>(_data._mem); \ + \ + if (index < 0) \ + index += arr->size(); \ + if (index >= 0 && index < arr->size()) { \ + valid = true; \ + cmd; \ + } \ + } \ } break; #define DEFAULT_OP_DVECTOR_SET(m_name, m_type, skip_cond) \ case m_name: { \ if (skip_cond) return; \ \ - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { \ + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \ int index = p_index; \ Vector<m_type> *arr = PackedArrayRef<m_type>::get_array_ptr(_data.packed_array); \ \ @@ -1971,7 +2001,7 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { #define DEFAULT_OP_DVECTOR_GET(m_name, m_type) \ case m_name: { \ \ - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { \ + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \ int index = p_index; \ const Vector<m_type> *arr = &PackedArrayRef<m_type>::get_array(_data.packed_array); \ \ @@ -2001,12 +2031,12 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) case INT: { return; } break; - case REAL: { + case FLOAT: { return; } break; case STRING: { - if (p_index.type != Variant::INT && p_index.type != Variant::REAL) + if (p_index.type != Variant::INT && p_index.type != Variant::FLOAT) return; int idx = p_index; @@ -2018,7 +2048,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; String chr; - if (p_value.type == Variant::INT || p_value.type == Variant::REAL) { + if (p_value.type == Variant::INT || p_value.type == Variant::FLOAT) { chr = String::chr(p_value); } else if (p_value.type == Variant::STRING) { @@ -2035,10 +2065,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR2: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { // scalar index int idx = p_index; @@ -2070,10 +2100,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; // 5 case VECTOR2I: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { // scalar index int idx = p_index; @@ -2158,7 +2188,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) if (p_value.type != Variant::VECTOR2) return; - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { int index = p_index; @@ -2194,10 +2224,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR3: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //scalar index int idx = p_index; if (idx < 0) @@ -2232,10 +2262,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case VECTOR3I: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //scalar index int idx = p_index; if (idx < 0) @@ -2275,21 +2305,21 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) const String *str = reinterpret_cast<const String *>(p_index._data._mem); Plane *v = reinterpret_cast<Plane *>(_data._mem); if (*str == "x") { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; valid = true; v->normal.x = p_value; return; } else if (*str == "y") { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; valid = true; v->normal.y = p_value; return; } else if (*str == "z") { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; valid = true; @@ -2312,7 +2342,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case QUAT: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; if (p_index.get_type() == Variant::STRING) { @@ -2369,7 +2399,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) if (p_value.type != Variant::VECTOR3) return; - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { int index = p_index; @@ -2405,7 +2435,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case TRANSFORM: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { if (p_value.type != Variant::VECTOR3) return; @@ -2448,7 +2478,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } break; case COLOR: { - if (p_value.type != Variant::INT && p_value.type != Variant::REAL) + if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) return; if (p_index.get_type() == Variant::STRING) { @@ -2551,9 +2581,11 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } break; DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return ) // 20 - DEFAULT_OP_DVECTOR_SET(PACKED_BYTE_ARRAY, uint8_t, p_value.type != Variant::REAL && p_value.type != Variant::INT) - DEFAULT_OP_DVECTOR_SET(PACKED_INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT) - DEFAULT_OP_DVECTOR_SET(PACKED_REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT) + DEFAULT_OP_DVECTOR_SET(PACKED_BYTE_ARRAY, uint8_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT) + DEFAULT_OP_DVECTOR_SET(PACKED_INT32_ARRAY, int32_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT) + DEFAULT_OP_DVECTOR_SET(PACKED_INT64_ARRAY, int64_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT) + DEFAULT_OP_DVECTOR_SET(PACKED_FLOAT32_ARRAY, float, p_value.type != Variant::FLOAT && p_value.type != Variant::INT) + DEFAULT_OP_DVECTOR_SET(PACKED_FLOAT64_ARRAY, double, p_value.type != Variant::FLOAT && p_value.type != Variant::INT) DEFAULT_OP_DVECTOR_SET(PACKED_STRING_ARRAY, String, p_value.type != Variant::STRING) DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25 DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3) @@ -2581,12 +2613,12 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { case INT: { return Variant(); } break; - case REAL: { + case FLOAT: { return Variant(); } break; case STRING: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //string index int idx = p_index; @@ -2603,7 +2635,7 @@ 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) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { // scalar index int idx = p_index; if (idx < 0) @@ -2631,7 +2663,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; // 5 case VECTOR2I: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { // scalar index int idx = p_index; if (idx < 0) @@ -2697,7 +2729,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case VECTOR3: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //scalar index int idx = p_index; if (idx < 0) @@ -2728,7 +2760,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case VECTOR3I: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { //scalar index int idx = p_index; if (idx < 0) @@ -2759,7 +2791,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case TRANSFORM2D: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { int index = p_index; @@ -2857,7 +2889,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case BASIS: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { int index = p_index; if (index < 0) @@ -2888,7 +2920,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; case TRANSFORM: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { int index = p_index; if (index < 0) @@ -3004,8 +3036,10 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } break; DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) // 20 DEFAULT_OP_DVECTOR_GET(PACKED_BYTE_ARRAY, uint8_t) - DEFAULT_OP_DVECTOR_GET(PACKED_INT_ARRAY, int) - DEFAULT_OP_DVECTOR_GET(PACKED_REAL_ARRAY, real_t) + DEFAULT_OP_DVECTOR_GET(PACKED_INT32_ARRAY, int32_t) + DEFAULT_OP_DVECTOR_GET(PACKED_INT64_ARRAY, int64_t) + DEFAULT_OP_DVECTOR_GET(PACKED_FLOAT32_ARRAY, float) + DEFAULT_OP_DVECTOR_GET(PACKED_FLOAT64_ARRAY, double) DEFAULT_OP_DVECTOR_GET(PACKED_STRING_ARRAY, String) DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR2_ARRAY, Vector2) // 25 DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR3_ARRAY, Vector3) @@ -3086,7 +3120,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } break; case PACKED_BYTE_ARRAY: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { int index = p_index; const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array); @@ -3103,14 +3137,49 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { } } break; - case PACKED_INT_ARRAY: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + case PACKED_INT32_ARRAY: { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { - int index = p_index; - const Vector<int> *arr = &PackedArrayRef<int>::get_array(_data.packed_array); + int32_t index = p_index; + const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array); + int32_t l = arr->size(); + if (l) { + const int32_t *r = arr->ptr(); + for (int32_t i = 0; i < l; i++) { + if (r[i] == index) + return true; + } + } + + return false; + } + } break; + case PACKED_INT64_ARRAY: { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { + + int64_t index = p_index; + const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array); + int64_t l = arr->size(); + if (l) { + const int64_t *r = arr->ptr(); + for (int64_t i = 0; i < l; i++) { + if (r[i] == index) + return true; + } + } + + return false; + } + } break; + case PACKED_FLOAT32_ARRAY: { + + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { + + real_t index = p_index; + const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array); int l = arr->size(); if (l) { - const int *r = arr->ptr(); + const float *r = arr->ptr(); for (int i = 0; i < l; i++) { if (r[i] == index) return true; @@ -3119,16 +3188,17 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const { return false; } + } break; - case PACKED_REAL_ARRAY: { + case PACKED_FLOAT64_ARRAY: { - if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { + if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { real_t index = p_index; - const Vector<real_t> *arr = &PackedArrayRef<real_t>::get_array(_data.packed_array); + const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array); int l = arr->size(); if (l) { - const real_t *r = arr->ptr(); + const double *r = arr->ptr(); for (int i = 0; i < l; i++) { if (r[i] == index) return true; @@ -3229,8 +3299,8 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { switch (type) { case VECTOR2: { - p_list->push_back(PropertyInfo(Variant::REAL, "x")); - p_list->push_back(PropertyInfo(Variant::REAL, "y")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); } break; // 5 case VECTOR2I: { @@ -3255,9 +3325,9 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } break; case VECTOR3: { - p_list->push_back(PropertyInfo(Variant::REAL, "x")); - p_list->push_back(PropertyInfo(Variant::REAL, "y")); - p_list->push_back(PropertyInfo(Variant::REAL, "z")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "z")); } break; case VECTOR3I: { @@ -3277,18 +3347,18 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { case PLANE: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "normal")); - p_list->push_back(PropertyInfo(Variant::REAL, "x")); - p_list->push_back(PropertyInfo(Variant::REAL, "y")); - p_list->push_back(PropertyInfo(Variant::REAL, "z")); - p_list->push_back(PropertyInfo(Variant::REAL, "d")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "z")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "d")); } break; case QUAT: { - p_list->push_back(PropertyInfo(Variant::REAL, "x")); - p_list->push_back(PropertyInfo(Variant::REAL, "y")); - p_list->push_back(PropertyInfo(Variant::REAL, "z")); - p_list->push_back(PropertyInfo(Variant::REAL, "w")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "x")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "y")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "z")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "w")); } break; // 10 case AABB: { @@ -3310,13 +3380,13 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } break; case COLOR: { - p_list->push_back(PropertyInfo(Variant::REAL, "r")); - p_list->push_back(PropertyInfo(Variant::REAL, "g")); - p_list->push_back(PropertyInfo(Variant::REAL, "b")); - p_list->push_back(PropertyInfo(Variant::REAL, "a")); - p_list->push_back(PropertyInfo(Variant::REAL, "h")); - p_list->push_back(PropertyInfo(Variant::REAL, "s")); - p_list->push_back(PropertyInfo(Variant::REAL, "v")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "r")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "g")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "b")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "a")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "h")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "s")); + p_list->push_back(PropertyInfo(Variant::FLOAT, "v")); p_list->push_back(PropertyInfo(Variant::INT, "r8")); p_list->push_back(PropertyInfo(Variant::INT, "g8")); p_list->push_back(PropertyInfo(Variant::INT, "b8")); @@ -3359,8 +3429,10 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } break; case ARRAY: // 20 case PACKED_BYTE_ARRAY: - case PACKED_INT_ARRAY: - case PACKED_REAL_ARRAY: + case PACKED_INT32_ARRAY: + case PACKED_INT64_ARRAY: + case PACKED_FLOAT32_ARRAY: + case PACKED_FLOAT64_ARRAY: case PACKED_STRING_ARRAY: case PACKED_VECTOR2_ARRAY: // 25 case PACKED_VECTOR3_ARRAY: @@ -3381,9 +3453,9 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { r_iter = 0; return _data._int > 0; } break; - case REAL: { + case FLOAT: { r_iter = 0; - return _data._real > 0.0; + return _data._float > 0.0; } break; case VECTOR2: { int64_t from = reinterpret_cast<const Vector2 *>(_data._mem)->x; @@ -3476,16 +3548,32 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return true; } break; - case PACKED_INT_ARRAY: { - const Vector<int> *arr = &PackedArrayRef<int>::get_array(_data.packed_array); + case PACKED_INT32_ARRAY: { + const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array); if (arr->size() == 0) return false; r_iter = 0; return true; } break; - case PACKED_REAL_ARRAY: { - const Vector<real_t> *arr = &PackedArrayRef<real_t>::get_array(_data.packed_array); + case PACKED_INT64_ARRAY: { + const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array); + if (arr->size() == 0) + return false; + r_iter = 0; + return true; + + } break; + case PACKED_FLOAT32_ARRAY: { + const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array); + if (arr->size() == 0) + return false; + r_iter = 0; + return true; + + } break; + case PACKED_FLOAT64_ARRAY: { + const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array); if (arr->size() == 0) return false; r_iter = 0; @@ -3543,10 +3631,10 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { r_iter = idx; return true; } break; - case REAL: { + case FLOAT: { int64_t idx = r_iter; idx++; - if (idx >= _data._real) + if (idx >= _data._float) return false; r_iter = idx; return true; @@ -3653,8 +3741,28 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; - case PACKED_INT_ARRAY: { - const Vector<int> *arr = &PackedArrayRef<int>::get_array(_data.packed_array); + case PACKED_INT32_ARRAY: { + const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array); + int32_t idx = r_iter; + idx++; + if (idx >= arr->size()) + return false; + r_iter = idx; + return true; + + } break; + case PACKED_INT64_ARRAY: { + const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array); + int64_t idx = r_iter; + idx++; + if (idx >= arr->size()) + return false; + r_iter = idx; + return true; + + } break; + case PACKED_FLOAT32_ARRAY: { + const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array); int idx = r_iter; idx++; if (idx >= arr->size()) @@ -3663,8 +3771,8 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; - case PACKED_REAL_ARRAY: { - const Vector<real_t> *arr = &PackedArrayRef<real_t>::get_array(_data.packed_array); + case PACKED_FLOAT64_ARRAY: { + const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array); int idx = r_iter; idx++; if (idx >= arr->size()) @@ -3728,7 +3836,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { return r_iter; } break; - case REAL: { + case FLOAT: { return r_iter; } break; @@ -3801,8 +3909,30 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { #endif return arr->get(idx); } break; - case PACKED_INT_ARRAY: { - const Vector<int> *arr = &PackedArrayRef<int>::get_array(_data.packed_array); + case PACKED_INT32_ARRAY: { + const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array); + int32_t idx = r_iter; +#ifdef DEBUG_ENABLED + if (idx < 0 || idx >= arr->size()) { + r_valid = false; + return Variant(); + } +#endif + return arr->get(idx); + } break; + case PACKED_INT64_ARRAY: { + const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array); + int64_t idx = r_iter; +#ifdef DEBUG_ENABLED + if (idx < 0 || idx >= arr->size()) { + r_valid = false; + return Variant(); + } +#endif + return arr->get(idx); + } break; + case PACKED_FLOAT32_ARRAY: { + const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array); int idx = r_iter; #ifdef DEBUG_ENABLED if (idx < 0 || idx >= arr->size()) { @@ -3812,8 +3942,8 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { #endif return arr->get(idx); } break; - case PACKED_REAL_ARRAY: { - const Vector<real_t> *arr = &PackedArrayRef<real_t>::get_array(_data.packed_array); + case PACKED_FLOAT64_ARRAY: { + const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array); int idx = r_iter; #ifdef DEBUG_ENABLED if (idx < 0 || idx >= arr->size()) { @@ -3923,9 +4053,9 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) r_dst = int(va + vb * c + 0.5); } return; - case REAL: { - double ra = a._data._real; - double rb = b._data._real; + case FLOAT: { + double ra = a._data._float; + double rb = b._data._float; r_dst = ra + rb * c; } return; @@ -4042,9 +4172,9 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = int(va + (vb - va) * c); } return; - case REAL: { - real_t va = a._data._real; - real_t vb = b._data._real; + case FLOAT: { + real_t va = a._data._float; + real_t vb = b._data._float; r_dst = va + (vb - va) * c; } return; @@ -4193,21 +4323,73 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = a; } return; - case PACKED_INT_ARRAY: { - const Vector<int> *arr_a = &PackedArrayRef<int>::get_array(a._data.packed_array); - const Vector<int> *arr_b = &PackedArrayRef<int>::get_array(b._data.packed_array); + case PACKED_INT32_ARRAY: { + const Vector<int32_t> *arr_a = &PackedArrayRef<int32_t>::get_array(a._data.packed_array); + const Vector<int32_t> *arr_b = &PackedArrayRef<int32_t>::get_array(b._data.packed_array); + int32_t sz = arr_a->size(); + if (sz == 0 || arr_b->size() != sz) { + + r_dst = a; + } else { + + Vector<int32_t> v; + v.resize(sz); + { + int32_t *vw = v.ptrw(); + const int32_t *ar = arr_a->ptr(); + const int32_t *br = arr_b->ptr(); + + Variant va; + for (int32_t i = 0; i < sz; i++) { + Variant::interpolate(ar[i], br[i], c, va); + vw[i] = va; + } + } + r_dst = v; + } + } + return; + case PACKED_INT64_ARRAY: { + const Vector<int64_t> *arr_a = &PackedArrayRef<int64_t>::get_array(a._data.packed_array); + const Vector<int64_t> *arr_b = &PackedArrayRef<int64_t>::get_array(b._data.packed_array); + int64_t sz = arr_a->size(); + if (sz == 0 || arr_b->size() != sz) { + + r_dst = a; + } else { + + Vector<int64_t> v; + v.resize(sz); + { + int64_t *vw = v.ptrw(); + const int64_t *ar = arr_a->ptr(); + const int64_t *br = arr_b->ptr(); + + Variant va; + for (int64_t i = 0; i < sz; i++) { + Variant::interpolate(ar[i], br[i], c, va); + vw[i] = va; + } + } + r_dst = v; + } + } + return; + case PACKED_FLOAT32_ARRAY: { + const Vector<float> *arr_a = &PackedArrayRef<float>::get_array(a._data.packed_array); + const Vector<float> *arr_b = &PackedArrayRef<float>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { r_dst = a; } else { - Vector<int> v; + Vector<float> v; v.resize(sz); { - int *vw = v.ptrw(); - const int *ar = arr_a->ptr(); - const int *br = arr_b->ptr(); + float *vw = v.ptrw(); + const float *ar = arr_a->ptr(); + const float *br = arr_b->ptr(); Variant va; for (int i = 0; i < sz; i++) { @@ -4219,21 +4401,21 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } } return; - case PACKED_REAL_ARRAY: { - const Vector<real_t> *arr_a = &PackedArrayRef<real_t>::get_array(a._data.packed_array); - const Vector<real_t> *arr_b = &PackedArrayRef<real_t>::get_array(b._data.packed_array); + case PACKED_FLOAT64_ARRAY: { + const Vector<double> *arr_a = &PackedArrayRef<double>::get_array(a._data.packed_array); + const Vector<double> *arr_b = &PackedArrayRef<double>::get_array(b._data.packed_array); int sz = arr_a->size(); if (sz == 0 || arr_b->size() != sz) { r_dst = a; } else { - Vector<real_t> v; + Vector<double> v; v.resize(sz); { - real_t *vw = v.ptrw(); - const real_t *ar = arr_a->ptr(); - const real_t *br = arr_b->ptr(); + double *vw = v.ptrw(); + const double *ar = arr_a->ptr(); + const double *br = arr_b->ptr(); Variant va; for (int i = 0; i < sz; i++) { diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 56d33c10f4..12fd9976bd 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -941,20 +941,41 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return OK; - } else if (id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") { + } else if (id == "PackedInt32Array" || id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") { - Vector<int> args; - Error err = _parse_construct<int>(p_stream, args, line, r_err_str); + Vector<int32_t> args; + Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str); if (err) return err; - Vector<int> arr; + Vector<int32_t> arr; { - int len = args.size(); + int32_t len = args.size(); arr.resize(len); - int *w = arr.ptrw(); - for (int i = 0; i < len; i++) { - w[i] = int(args[i]); + int32_t *w = arr.ptrw(); + for (int32_t i = 0; i < len; i++) { + w[i] = int32_t(args[i]); + } + } + + value = arr; + + return OK; + + } else if (id == "PackedInt64Array") { + + Vector<int64_t> args; + Error err = _parse_construct<int64_t>(p_stream, args, line, r_err_str); + if (err) + return err; + + Vector<int64_t> arr; + { + int64_t len = args.size(); + arr.resize(len); + int64_t *w = arr.ptrw(); + for (int64_t i = 0; i < len; i++) { + w[i] = int64_t(args[i]); } } @@ -962,7 +983,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return OK; - } else if (id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") { + } else if (id == "PackedFloat32Array" || id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") { Vector<float> args; Error err = _parse_construct<float>(p_stream, args, line, r_err_str); @@ -982,6 +1003,26 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = arr; return OK; + } else if (id == "PackedFloat64Array") { + + Vector<double> args; + Error err = _parse_construct<double>(p_stream, args, line, r_err_str); + if (err) + return err; + + Vector<double> arr; + { + int len = args.size(); + arr.resize(len); + double *w = arr.ptrw(); + for (int i = 0; i < len; i++) { + w[i] = args[i]; + } + } + + value = arr; + + return OK; } else if (id == "PackedStringArray" || id == "PoolStringArray" || id == "StringArray") { get_token(p_stream, token, line, r_err_str); @@ -1455,7 +1496,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, itos(p_variant.operator int64_t())); } break; - case Variant::REAL: { + case Variant::FLOAT: { String s = rtosfix(p_variant.operator real_t()); if (s.find(".") == -1 && s.find("e") == -1) @@ -1715,14 +1756,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, " )"); } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedIntArray( "); - Vector<int> data = p_variant; - int len = data.size(); - const int *ptr = data.ptr(); + p_store_string_func(p_store_string_ud, "PackedInt32Array( "); + Vector<int32_t> data = p_variant; + int32_t len = data.size(); + const int32_t *ptr = data.ptr(); - for (int i = 0; i < len; i++) { + for (int32_t i = 0; i < len; i++) { if (i > 0) p_store_string_func(p_store_string_ud, ", "); @@ -1733,12 +1774,47 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, " )"); } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_INT64_ARRAY: { + + p_store_string_func(p_store_string_ud, "PackedInt64Array( "); + Vector<int64_t> data = p_variant; + int64_t len = data.size(); + const int64_t *ptr = data.ptr(); + + for (int64_t i = 0; i < len; i++) { + + if (i > 0) + p_store_string_func(p_store_string_ud, ", "); + + p_store_string_func(p_store_string_ud, itos(ptr[i])); + } + + p_store_string_func(p_store_string_ud, " )"); + + } break; + case Variant::PACKED_FLOAT32_ARRAY: { + + p_store_string_func(p_store_string_ud, "PackedFloat32Array( "); + Vector<float> data = p_variant; + int len = data.size(); + const float *ptr = data.ptr(); + + for (int i = 0; i < len; i++) { + + if (i > 0) + p_store_string_func(p_store_string_ud, ", "); + p_store_string_func(p_store_string_ud, rtosfix(ptr[i])); + } + + p_store_string_func(p_store_string_ud, " )"); + + } break; + case Variant::PACKED_FLOAT64_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedRealArray( "); - Vector<real_t> data = p_variant; + p_store_string_func(p_store_string_ud, "PackedFloat64Array( "); + Vector<double> data = p_variant; int len = data.size(); - const real_t *ptr = data.ptr(); + const double *ptr = data.ptr(); for (int i = 0; i < len; i++) { |