diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/engine.cpp | 36 | ||||
-rw-r--r-- | core/config/engine.h | 2 | ||||
-rw-r--r-- | core/config/project_settings.cpp | 19 | ||||
-rw-r--r-- | core/config/project_settings.h | 5 | ||||
-rw-r--r-- | core/core_bind.cpp | 6 | ||||
-rw-r--r-- | core/core_bind.h | 2 | ||||
-rw-r--r-- | core/extension/gdnative_interface.h | 10 | ||||
-rw-r--r-- | core/extension/native_extension.cpp | 9 | ||||
-rw-r--r-- | core/io/packed_data_container.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 8 | ||||
-rw-r--r-- | core/math/vector4.cpp | 4 | ||||
-rw-r--r-- | core/math/vector4.h | 1 | ||||
-rw-r--r-- | core/object/method_bind.cpp | 2 | ||||
-rw-r--r-- | core/object/object.cpp | 63 | ||||
-rw-r--r-- | core/object/object.h | 36 | ||||
-rw-r--r-- | core/object/ref_counted.cpp | 3 | ||||
-rw-r--r-- | core/object/script_language.h | 6 | ||||
-rw-r--r-- | core/object/script_language_extension.h | 13 | ||||
-rw-r--r-- | core/string/translation.cpp | 2 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 10 |
20 files changed, 213 insertions, 26 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 1a6093869f..e1da9eb44e 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -181,6 +181,42 @@ String Engine::get_license_text() const { return String(GODOT_LICENSE_TEXT); } +String Engine::get_architecture_name() const { +#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) + return "x86_64"; + +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + return "x86_32"; + +#elif defined(__aarch64__) || defined(_M_ARM64) + return "arm64"; + +#elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7S__) + return "armv7"; + +#elif defined(__riscv) +#if __riscv_xlen == 8 + return "rv64"; +#else + return "riscv"; +#endif + +#elif defined(__powerpc__) +#if defined(__powerpc64__) + return "ppc64"; +#else + return "ppc"; +#endif + +#elif defined(__wasm__) +#if defined(__wasm64__) + return "wasm64"; +#elif defined(__wasm32__) + return "wasm32"; +#endif +#endif +} + bool Engine::is_abort_on_gpu_errors_enabled() const { return abort_on_gpu_errors; } diff --git a/core/config/engine.h b/core/config/engine.h index 68562643e7..649be23717 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -142,6 +142,8 @@ public: void set_write_movie_path(const String &p_path); String get_write_movie_path() const; + String get_architecture_name() const; + void set_shader_cache_path(const String &p_path); String get_shader_cache_path() const; diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 5c4bcc687a..26b683db82 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1070,7 +1070,7 @@ bool ProjectSettings::is_using_datapack() const { return using_datapack; } -bool ProjectSettings::property_can_revert(const String &p_name) { +bool ProjectSettings::_property_can_revert(const StringName &p_name) const { if (!props.has(p_name)) { return false; } @@ -1078,12 +1078,13 @@ bool ProjectSettings::property_can_revert(const String &p_name) { return props[p_name].initial != props[p_name].variant; } -Variant ProjectSettings::property_get_revert(const String &p_name) { +bool ProjectSettings::_property_get_revert(const StringName &p_name, Variant &r_property) const { if (!props.has(p_name)) { - return Variant(); + return false; } - return props[p_name].initial; + r_property = props[p_name].initial; + return true; } void ProjectSettings::set_setting(const String &p_setting, const Variant &p_value) { @@ -1134,8 +1135,6 @@ void ProjectSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path); ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save); ClassDB::bind_method(D_METHOD("load_resource_pack", "pack", "replace_files", "offset"), &ProjectSettings::_load_resource_pack, DEFVAL(true), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert); - ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ProjectSettings::property_get_revert); ClassDB::bind_method(D_METHOD("save_custom", "file"), &ProjectSettings::_save_custom_bnd); } @@ -1183,10 +1182,14 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("application/config/custom_user_dir_name", ""); GLOBAL_DEF("application/config/project_settings_override", ""); - GLOBAL_DEF_BASIC("display/window/size/viewport_width", 1024); + // The default window size is tuned to: + // - Have a 16:9 aspect ratio, + // - Have both dimensions divisible by 8 to better play along with video recording, + // - Be displayable correctly in windowed mode on a 1366×768 display (tested on Windows 10 with default settings). + GLOBAL_DEF_BASIC("display/window/size/viewport_width", 1152); custom_prop_info["display/window/size/viewport_width"] = PropertyInfo(Variant::INT, "display/window/size/viewport_width", PROPERTY_HINT_RANGE, "0,7680,1,or_greater"); // 8K resolution - GLOBAL_DEF_BASIC("display/window/size/viewport_height", 600); + GLOBAL_DEF_BASIC("display/window/size/viewport_height", 648); custom_prop_info["display/window/size/viewport_height"] = PropertyInfo(Variant::INT, "display/window/size/viewport_height", PROPERTY_HINT_RANGE, "0,4320,1,or_greater"); // 8K resolution GLOBAL_DEF_BASIC("display/window/size/resizable", true); diff --git a/core/config/project_settings.h b/core/config/project_settings.h index c3992a4db2..c845120a26 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -102,6 +102,8 @@ protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; + bool _property_can_revert(const StringName &p_name) const; + bool _property_get_revert(const StringName &p_name, Variant &r_property) const; static ProjectSettings *singleton; @@ -147,9 +149,6 @@ public: void set_ignore_value_in_docs(const String &p_name, bool p_ignore); bool get_ignore_value_in_docs(const String &p_name) const; - bool property_can_revert(const String &p_name); - Variant property_get_revert(const String &p_name); - String get_project_data_dir_name() const; String get_project_data_path() const; String get_resource_path() const; diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 56130134a0..630bd68e65 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2270,6 +2270,10 @@ String Engine::get_license_text() const { return ::Engine::get_singleton()->get_license_text(); } +String Engine::get_architecture_name() const { + return ::Engine::get_singleton()->get_architecture_name(); +} + bool Engine::is_in_physics_frame() const { return ::Engine::get_singleton()->is_in_physics_frame(); } @@ -2367,6 +2371,8 @@ void Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("get_license_info"), &Engine::get_license_info); ClassDB::bind_method(D_METHOD("get_license_text"), &Engine::get_license_text); + ClassDB::bind_method(D_METHOD("get_architecture_name"), &Engine::get_architecture_name); + ClassDB::bind_method(D_METHOD("is_in_physics_frame"), &Engine::is_in_physics_frame); ClassDB::bind_method(D_METHOD("has_singleton", "name"), &Engine::has_singleton); diff --git a/core/core_bind.h b/core/core_bind.h index 98bf34e07d..79230bd685 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -666,6 +666,8 @@ public: Dictionary get_license_info() const; String get_license_text() const; + String get_architecture_name() const; + bool is_in_physics_frame() const; bool has_singleton(const StringName &p_name) const; diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index 041a6e5112..cb2adcb562 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -222,6 +222,8 @@ typedef struct { typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count); typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list); +typedef GDNativeBool (*GDNativeExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name); +typedef GDNativeBool (*GDNativeExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); typedef void (*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDNativeStringPtr p_out); typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance); @@ -237,6 +239,8 @@ typedef struct { GDNativeExtensionClassGet get_func; GDNativeExtensionClassGetPropertyList get_property_list_func; GDNativeExtensionClassFreePropertyList free_property_list_func; + GDNativeExtensionClassPropertyCanRevert property_can_revert_func; + GDNativeExtensionClassPropertyGetRevert property_get_revert_func; GDNativeExtensionClassNotification notification_func; GDNativeExtensionClassToString to_string_func; GDNativeExtensionClassReference reference_func; @@ -309,6 +313,9 @@ typedef const GDNativePropertyInfo *(*GDNativeExtensionScriptInstanceGetProperty typedef void (*GDNativeExtensionScriptInstanceFreePropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativePropertyInfo *p_list); typedef GDNativeVariantType (*GDNativeExtensionScriptInstanceGetPropertyType)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeBool *r_is_valid); +typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyCanRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); +typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyGetRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); + typedef GDNativeObjectPtr (*GDNativeExtensionScriptInstanceGetOwner)(GDNativeExtensionScriptInstanceDataPtr p_instance); typedef void (*GDNativeExtensionScriptInstancePropertyStateAdd)(const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value, void *p_userdata); typedef void (*GDNativeExtensionScriptInstanceGetPropertyState)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata); @@ -343,6 +350,9 @@ typedef struct { GDNativeExtensionScriptInstanceFreePropertyList free_property_list_func; GDNativeExtensionScriptInstanceGetPropertyType get_property_type_func; + GDNativeExtensionScriptInstancePropertyCanRevert property_can_revert_func; + GDNativeExtensionScriptInstancePropertyGetRevert property_get_revert_func; + GDNativeExtensionScriptInstanceGetOwner get_owner_func; GDNativeExtensionScriptInstanceGetPropertyState get_property_state_func; diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index b69859b441..fdb4e50d90 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -156,6 +156,8 @@ void NativeExtension::_register_extension_class(const GDNativeExtensionClassLibr extension->native_extension.get = p_extension_funcs->get_func; extension->native_extension.get_property_list = p_extension_funcs->get_property_list_func; extension->native_extension.free_property_list = p_extension_funcs->free_property_list_func; + extension->native_extension.property_can_revert = p_extension_funcs->property_can_revert_func; + extension->native_extension.property_get_revert = p_extension_funcs->property_get_revert_func; extension->native_extension.notification = p_extension_funcs->notification_func; extension->native_extension.to_string = p_extension_funcs->to_string_func; extension->native_extension.reference = p_extension_funcs->reference_func; @@ -372,7 +374,7 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St } if (err != OK) { - ERR_PRINT("Error loading GDExtension config file: " + p_path); + ERR_PRINT("Error loading GDExtension configuration file: " + p_path); return Ref<Resource>(); } @@ -380,7 +382,7 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St if (r_error) { *r_error = ERR_INVALID_DATA; } - ERR_PRINT("GDExtension config file must contain 'configuration.entry_symbol' key: " + p_path); + ERR_PRINT("GDExtension configuration file must contain a \"configuration/entry_symbol\" key: " + p_path); return Ref<Resource>(); } @@ -413,7 +415,8 @@ Ref<Resource> NativeExtensionResourceLoader::load(const String &p_path, const St if (r_error) { *r_error = ERR_FILE_NOT_FOUND; } - ERR_PRINT("No GDExtension library found for current architecture; in config file " + p_path); + const String os_arch = OS::get_singleton()->get_name().to_lower() + "." + Engine::get_singleton()->get_architecture_name(); + ERR_PRINT(vformat("No GDExtension library found for current OS and architecture (%s) in configuration file: %s", os_arch, p_path)); return Ref<Resource>(); } diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index a456318148..2dcb86cbc6 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -353,7 +353,7 @@ Variant PackedDataContainer::_iter_get(const Variant &p_iter) { } void PackedDataContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_data"), &PackedDataContainer::_set_data); + ClassDB::bind_method(D_METHOD("_set_data", "data"), &PackedDataContainer::_set_data); ClassDB::bind_method(D_METHOD("_get_data"), &PackedDataContainer::_get_data); ClassDB::bind_method(D_METHOD("_iter_init"), &PackedDataContainer::_iter_init); ClassDB::bind_method(D_METHOD("_iter_get"), &PackedDataContainer::_iter_get); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3e595557f9..eccb397e2e 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -794,6 +794,8 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem // To find the path of the remapped resource, we extract the locale name after // the last ':' to match the project locale. + // An extra remap may still be necessary afterwards due to the text -> binary converter on export. + String locale = TranslationServer::get_singleton()->get_locale(); ERR_FAIL_COND_V_MSG(locale.length() < 2, p_path, "Could not remap path '" + p_path + "' for translation as configured locale '" + locale + "' is invalid."); @@ -829,12 +831,10 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem if (path_remaps.has(new_path)) { new_path = path_remaps[new_path]; - } - - if (new_path == p_path) { // Did not remap. + } else { // Try file remap. Error err; - Ref<FileAccess> f = FileAccess::open(p_path + ".remap", FileAccess::READ, &err); + Ref<FileAccess> f = FileAccess::open(new_path + ".remap", FileAccess::READ, &err); if (f.is_valid()) { VariantParser::StreamFile stream; stream.f = f; diff --git a/core/math/vector4.cpp b/core/math/vector4.cpp index 4697c311b4..1dd5adad2b 100644 --- a/core/math/vector4.cpp +++ b/core/math/vector4.cpp @@ -91,6 +91,10 @@ real_t Vector4::distance_to(const Vector4 &p_to) const { return (p_to - *this).length(); } +real_t Vector4::distance_squared_to(const Vector4 &p_to) const { + return (p_to - *this).length_squared(); +} + Vector4 Vector4::direction_to(const Vector4 &p_to) const { Vector4 ret(p_to.x - x, p_to.y - y, p_to.z - z, p_to.w - w); ret.normalize(); diff --git a/core/math/vector4.h b/core/math/vector4.h index 373a6a1218..d26fe15941 100644 --- a/core/math/vector4.h +++ b/core/math/vector4.h @@ -79,6 +79,7 @@ struct _NO_DISCARD_ Vector4 { bool is_normalized() const; real_t distance_to(const Vector4 &p_to) const; + real_t distance_squared_to(const Vector4 &p_to) const; Vector4 direction_to(const Vector4 &p_to) const; Vector4 abs() const; diff --git a/core/object/method_bind.cpp b/core/object/method_bind.cpp index a4474ea53b..0edc7a90c2 100644 --- a/core/object/method_bind.cpp +++ b/core/object/method_bind.cpp @@ -63,7 +63,7 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const { PropertyInfo info = _gen_argument_type_info(p_argument); #ifdef DEBUG_METHODS_ENABLED - info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("arg" + itos(p_argument)); + info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("_unnamed_arg" + itos(p_argument)); #endif return info; } diff --git a/core/object/object.cpp b/core/object/object.cpp index 0fcd1c0e40..a95ba7992b 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -518,6 +518,59 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons void Object::_validate_property(PropertyInfo &property) const { } +bool Object::property_can_revert(const String &p_name) const { + if (script_instance) { + if (script_instance->property_can_revert(p_name)) { + return true; + } + } + +// C style pointer casts should never trigger a compiler warning because the risk is assumed by the user, so GCC should keep quiet about it. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#endif + if (_extension && _extension->property_can_revert) { + if (_extension->property_can_revert(_extension_instance, (const GDNativeStringNamePtr)&p_name)) { + return true; + } + } +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + + return _property_can_revertv(p_name); +} + +Variant Object::property_get_revert(const String &p_name) const { + Variant ret; + + if (script_instance) { + if (script_instance->property_get_revert(p_name, ret)) { + return ret; + } + } + +// C style pointer casts should never trigger a compiler warning because the risk is assumed by the user, so GCC should keep quiet about it. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#endif + if (_extension && _extension->property_get_revert) { + if (_extension->property_get_revert(_extension_instance, (const GDNativeStringNamePtr)&p_name, (GDNativeVariantPtr)&ret)) { + return ret; + } + } +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + + if (_property_get_revertv(p_name, ret)) { + return ret; + } + return Variant(); +} + void Object::get_method_list(List<MethodInfo> *p_list) const { ClassDB::get_method_list(get_class_name(), p_list); if (script_instance) { @@ -1499,10 +1552,12 @@ void Object::_bind_methods() { miget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; BIND_OBJ_CORE_METHOD(miget); - MethodInfo plget("_get_property_list"); - - plget.return_val.type = Variant::ARRAY; - BIND_OBJ_CORE_METHOD(plget); + BIND_OBJ_CORE_METHOD(MethodInfo(Variant::ARRAY, "_get_property_list")); + BIND_OBJ_CORE_METHOD(MethodInfo(Variant::BOOL, "_property_can_revert", PropertyInfo(Variant::STRING_NAME, "property"))); + MethodInfo mipgr("_property_get_revert", PropertyInfo(Variant::STRING_NAME, "property")); + mipgr.return_val.name = "Variant"; + mipgr.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; + BIND_OBJ_CORE_METHOD(mipgr); #endif BIND_OBJ_CORE_METHOD(MethodInfo("_init")); diff --git a/core/object/object.h b/core/object/object.h index 35d0aaaa7d..154ef176d3 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -294,6 +294,8 @@ struct ObjectNativeExtension { GDNativeExtensionClassGet get; GDNativeExtensionClassGetPropertyList get_property_list; GDNativeExtensionClassFreePropertyList free_property_list; + GDNativeExtensionClassPropertyCanRevert property_can_revert; + GDNativeExtensionClassPropertyGetRevert property_get_revert; GDNativeExtensionClassNotification notification; GDNativeExtensionClassToString to_string; GDNativeExtensionClassReference reference; @@ -469,6 +471,28 @@ protected: m_inherits::_get_property_listv(p_list, p_reversed); \ } \ } \ + _FORCE_INLINE_ bool (Object::*_get_property_can_revert() const)(const StringName &p_name) const { \ + return (bool(Object::*)(const StringName &) const) & m_class::_property_can_revert; \ + } \ + virtual bool _property_can_revertv(const StringName &p_name) const override { \ + if (m_class::_get_property_can_revert() != m_inherits::_get_property_can_revert()) { \ + if (_property_can_revert(p_name)) { \ + return true; \ + } \ + } \ + return m_inherits::_property_can_revertv(p_name); \ + } \ + _FORCE_INLINE_ bool (Object::*_get_property_get_revert() const)(const StringName &p_name, Variant &) const { \ + return (bool(Object::*)(const StringName &, Variant &) const) & m_class::_property_get_revert; \ + } \ + virtual bool _property_get_revertv(const StringName &p_name, Variant &r_ret) const override { \ + if (m_class::_get_property_get_revert() != m_inherits::_get_property_get_revert()) { \ + if (_property_get_revert(p_name, r_ret)) { \ + return true; \ + } \ + } \ + return m_inherits::_property_get_revertv(p_name, r_ret); \ + } \ _FORCE_INLINE_ void (Object::*_get_notification() const)(int) { \ return (void(Object::*)(int)) & m_class::_notification; \ } \ @@ -613,12 +637,16 @@ protected: virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; }; virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; }; virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {}; + virtual bool _property_can_revertv(const StringName &p_name) const { return false; }; + virtual bool _property_get_revertv(const StringName &p_name, Variant &r_property) const { return false; }; virtual void _notificationv(int p_notification, bool p_reversed) {} static void _bind_methods(); bool _set(const StringName &p_name, const Variant &p_property) { return false; }; bool _get(const StringName &p_name, Variant &r_property) const { return false; }; void _get_property_list(List<PropertyInfo> *p_list) const {}; + bool _property_can_revert(const StringName &p_name) const { return false; }; + bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; }; void _notification(int p_notification) {} _FORCE_INLINE_ static void (*_get_bind_methods())() { @@ -633,6 +661,12 @@ protected: _FORCE_INLINE_ void (Object::*_get_get_property_list() const)(List<PropertyInfo> *p_list) const { return &Object::_get_property_list; } + _FORCE_INLINE_ bool (Object::*_get_property_can_revert() const)(const StringName &p_name) const { + return &Object::_property_can_revert; + } + _FORCE_INLINE_ bool (Object::*_get_property_get_revert() const)(const StringName &p_name, Variant &) const { + return &Object::_property_get_revert; + } _FORCE_INLINE_ void (Object::*_get_notification() const)(int) { return &Object::_notification; } @@ -757,6 +791,8 @@ public: Variant get_indexed(const Vector<StringName> &p_names, bool *r_valid = nullptr) const; void get_property_list(List<PropertyInfo> *p_list, bool p_reversed = false) const; + bool property_can_revert(const String &p_name) const; + Variant property_get_revert(const String &p_name) const; bool has_method(const StringName &p_method) const; void get_method_list(List<MethodInfo> *p_list) const; diff --git a/core/object/ref_counted.cpp b/core/object/ref_counted.cpp index 726e2c012c..cac2400744 100644 --- a/core/object/ref_counted.cpp +++ b/core/object/ref_counted.cpp @@ -85,7 +85,8 @@ bool RefCounted::unreference() { _get_extension()->unreference(_get_extension_instance()); } - die = die && _instance_binding_reference(false); + bool binding_ret = _instance_binding_reference(false); + die = die && binding_ret; } return die; diff --git a/core/object/script_language.h b/core/object/script_language.h index f5f052b600..bfdedbe4a5 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -171,6 +171,9 @@ public: virtual void get_property_list(List<PropertyInfo> *p_properties) const = 0; virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const = 0; + virtual bool property_can_revert(const StringName &p_name) const = 0; + virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const = 0; + virtual Object *get_owner() { return nullptr; } virtual void get_property_state(List<Pair<StringName, Variant>> &state); @@ -447,6 +450,9 @@ public: virtual void get_property_list(List<PropertyInfo> *p_properties) const override; virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const override; + virtual bool property_can_revert(const StringName &p_name) const override { return false; }; + virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { return false; }; + virtual void get_method_list(List<MethodInfo> *p_list) const override; virtual bool has_method(const StringName &p_method) const override; diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index 2869f4ad98..7e74f6a2be 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -692,6 +692,19 @@ public: return Variant::NIL; } + virtual bool property_can_revert(const StringName &p_name) const override { + if (native_info->property_can_revert_func) { + return native_info->property_can_revert_func(instance, (const GDNativeStringNamePtr)&p_name); + } + return false; + } + virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { + if (native_info->property_get_revert_func) { + return native_info->property_get_revert_func(instance, (const GDNativeStringNamePtr)&p_name, (GDNativeVariantPtr)&r_ret); + } + return false; + } + virtual Object *get_owner() override { if (native_info->get_owner_func) { return (Object *)native_info->get_owner_func(instance); diff --git a/core/string/translation.cpp b/core/string/translation.cpp index cba2f09022..b83b7c786f 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -141,7 +141,7 @@ void Translation::_bind_methods() { ClassDB::bind_method(D_METHOD("erase_message", "src_message", "context"), &Translation::erase_message, DEFVAL("")); ClassDB::bind_method(D_METHOD("get_message_list"), &Translation::_get_message_list); ClassDB::bind_method(D_METHOD("get_message_count"), &Translation::get_message_count); - ClassDB::bind_method(D_METHOD("_set_messages"), &Translation::_set_messages); + ClassDB::bind_method(D_METHOD("_set_messages", "messages"), &Translation::_set_messages); ClassDB::bind_method(D_METHOD("_get_messages"), &Translation::_get_messages); GDVIRTUAL_BIND(_get_plural_message, "src_message", "src_plural_message", "n", "context"); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 5c298f9b3b..eba12b68bb 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1746,6 +1746,7 @@ static void _register_variant_builtin_methods() { bind_method(Vector4, is_normalized, sarray(), varray()); bind_method(Vector4, direction_to, sarray("to"), varray()); bind_method(Vector4, distance_to, sarray("to"), varray()); + bind_method(Vector4, distance_squared_to, sarray("to"), varray()); bind_method(Vector4, dot, sarray("with"), varray()); bind_method(Vector4, inverse, sarray(), varray()); bind_method(Vector4, is_equal_approx, sarray("with"), varray()); @@ -2067,6 +2068,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedByteArray, fill, sarray("value"), varray()); bind_methodv(PackedByteArray, resize, &PackedByteArray::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedByteArray, clear, sarray(), varray()); bind_method(PackedByteArray, has, sarray("value"), varray()); bind_method(PackedByteArray, reverse, sarray(), varray()); bind_method(PackedByteArray, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2131,6 +2133,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt32Array, fill, sarray("value"), varray()); bind_methodv(PackedInt32Array, resize, &PackedInt32Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedInt32Array, clear, sarray(), varray()); bind_method(PackedInt32Array, has, sarray("value"), varray()); bind_method(PackedInt32Array, reverse, sarray(), varray()); bind_method(PackedInt32Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2154,6 +2157,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt64Array, fill, sarray("value"), varray()); bind_methodv(PackedInt64Array, resize, &PackedInt64Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedInt64Array, clear, sarray(), varray()); bind_method(PackedInt64Array, has, sarray("value"), varray()); bind_method(PackedInt64Array, reverse, sarray(), varray()); bind_method(PackedInt64Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2177,6 +2181,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat32Array, fill, sarray("value"), varray()); bind_methodv(PackedFloat32Array, resize, &PackedFloat32Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedFloat32Array, clear, sarray(), varray()); bind_method(PackedFloat32Array, has, sarray("value"), varray()); bind_method(PackedFloat32Array, reverse, sarray(), varray()); bind_method(PackedFloat32Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2200,6 +2205,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat64Array, fill, sarray("value"), varray()); bind_methodv(PackedFloat64Array, resize, &PackedFloat64Array::resize_zeroed, sarray("new_size"), varray()); + bind_method(PackedFloat64Array, clear, sarray(), varray()); bind_method(PackedFloat64Array, has, sarray("value"), varray()); bind_method(PackedFloat64Array, reverse, sarray(), varray()); bind_method(PackedFloat64Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2223,6 +2229,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedStringArray, fill, sarray("value"), varray()); bind_method(PackedStringArray, resize, sarray("new_size"), varray()); + bind_method(PackedStringArray, clear, sarray(), varray()); bind_method(PackedStringArray, has, sarray("value"), varray()); bind_method(PackedStringArray, reverse, sarray(), varray()); bind_method(PackedStringArray, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2246,6 +2253,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector2Array, fill, sarray("value"), varray()); bind_method(PackedVector2Array, resize, sarray("new_size"), varray()); + bind_method(PackedVector2Array, clear, sarray(), varray()); bind_method(PackedVector2Array, has, sarray("value"), varray()); bind_method(PackedVector2Array, reverse, sarray(), varray()); bind_method(PackedVector2Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2269,6 +2277,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector3Array, fill, sarray("value"), varray()); bind_method(PackedVector3Array, resize, sarray("new_size"), varray()); + bind_method(PackedVector3Array, clear, sarray(), varray()); bind_method(PackedVector3Array, has, sarray("value"), varray()); bind_method(PackedVector3Array, reverse, sarray(), varray()); bind_method(PackedVector3Array, slice, sarray("begin", "end"), varray(INT_MAX)); @@ -2292,6 +2301,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedColorArray, fill, sarray("value"), varray()); bind_method(PackedColorArray, resize, sarray("new_size"), varray()); + bind_method(PackedColorArray, clear, sarray(), varray()); bind_method(PackedColorArray, has, sarray("value"), varray()); bind_method(PackedColorArray, reverse, sarray(), varray()); bind_method(PackedColorArray, slice, sarray("begin", "end"), varray(INT_MAX)); |