diff options
66 files changed, 458 insertions, 863 deletions
diff --git a/core/io/json.cpp b/core/io/json.cpp index ca29534c35..448e39b2c3 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -30,6 +30,7 @@ #include "json.h" +#include "core/config/engine.h" #include "core/string/print_string.h" const char *JSON::tk_name[TK_MAX] = { @@ -506,6 +507,7 @@ Error JSON::_parse_object(Dictionary &object, const char32_t *p_str, int &index, void JSON::set_data(const Variant &p_data) { data = p_data; + text.clear(); } Error JSON::_parse_string(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line) { @@ -539,14 +541,21 @@ Error JSON::_parse_string(const String &p_json, Variant &r_ret, String &r_err_st return err; } -Error JSON::parse(const String &p_json_string) { +Error JSON::parse(const String &p_json_string, bool p_keep_text) { Error err = _parse_string(p_json_string, data, err_str, err_line); if (err == Error::OK) { err_line = 0; } + if (p_keep_text) { + text = p_json_string; + } return err; } +String JSON::get_parsed_text() const { + return text; +} + String JSON::stringify(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) { Ref<JSON> jason; jason.instantiate(); @@ -565,10 +574,11 @@ Variant JSON::parse_string(const String &p_json_string) { void JSON::_bind_methods() { ClassDB::bind_static_method("JSON", D_METHOD("stringify", "data", "indent", "sort_keys", "full_precision"), &JSON::stringify, DEFVAL(""), DEFVAL(true), DEFVAL(false)); ClassDB::bind_static_method("JSON", D_METHOD("parse_string", "json_string"), &JSON::parse_string); - ClassDB::bind_method(D_METHOD("parse", "json_string"), &JSON::parse); + ClassDB::bind_method(D_METHOD("parse", "json_text", "keep_text"), &JSON::parse, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_data"), &JSON::get_data); ClassDB::bind_method(D_METHOD("set_data", "data"), &JSON::set_data); + ClassDB::bind_method(D_METHOD("get_parsed_text"), &JSON::get_parsed_text); ClassDB::bind_method(D_METHOD("get_error_line"), &JSON::get_error_line); ClassDB::bind_method(D_METHOD("get_error_message"), &JSON::get_error_message); @@ -592,13 +602,20 @@ Ref<Resource> ResourceFormatLoaderJSON::load(const String &p_path, const String Ref<JSON> json; json.instantiate(); - Error err = json->parse(FileAccess::get_file_as_string(p_path)); + Error err = json->parse(FileAccess::get_file_as_string(p_path), Engine::get_singleton()->is_editor_hint()); if (err != OK) { - if (r_error) { - *r_error = err; + String err_text = "Error parsing JSON file at '" + p_path + "', on line " + itos(json->get_error_line()) + ": " + json->get_error_message(); + + if (Engine::get_singleton()->is_editor_hint()) { + // If running on editor, still allow opening the JSON so the code editor can edit it. + WARN_PRINT(err_text); + } else { + if (r_error) { + *r_error = err; + } + ERR_PRINT(err_text); + return Ref<Resource>(); } - ERR_PRINT("Error parsing JSON file at '" + p_path + "', on line " + itos(json->get_error_line()) + ": " + json->get_error_message()); - return Ref<Resource>(); } if (r_error) { @@ -628,7 +645,7 @@ Error ResourceFormatSaverJSON::save(const Ref<Resource> &p_resource, const Strin Ref<JSON> json = p_resource; ERR_FAIL_COND_V(json.is_null(), ERR_INVALID_PARAMETER); - String source = JSON::stringify(json->get_data(), "\t", false, true); + String source = json->get_parsed_text().is_empty() ? JSON::stringify(json->get_data(), "\t", false, true) : json->get_parsed_text(); Error err; Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err); diff --git a/core/io/json.h b/core/io/json.h index d66a4e24a3..a21cc542fd 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -36,8 +36,8 @@ #include "core/io/resource_saver.h" #include "core/variant/variant.h" -class JSON : public RefCounted { - GDCLASS(JSON, RefCounted); +class JSON : public Resource { + GDCLASS(JSON, Resource); enum TokenType { TK_CURLY_BRACKET_OPEN, @@ -65,6 +65,7 @@ class JSON : public RefCounted { Variant value; }; + String text; Variant data; String err_str; int err_line = 0; @@ -83,7 +84,9 @@ protected: static void _bind_methods(); public: - Error parse(const String &p_json_string); + Error parse(const String &p_json_string, bool p_keep_text = false); + String get_parsed_text() const; + static String stringify(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true, bool p_full_precision = false); static Variant parse_string(const String &p_json_string); diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 66ef418e42..df5486512d 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -245,9 +245,12 @@ void ScriptServer::thread_exit() { } HashMap<StringName, ScriptServer::GlobalScriptClass> ScriptServer::global_classes; +HashMap<StringName, Vector<StringName>> ScriptServer::inheriters_cache; +bool ScriptServer::inheriters_cache_dirty = true; void ScriptServer::global_classes_clear() { global_classes.clear(); + inheriters_cache.clear(); } void ScriptServer::add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path) { @@ -257,16 +260,44 @@ void ScriptServer::add_global_class(const StringName &p_class, const StringName g.path = p_path; g.base = p_base; global_classes[p_class] = g; + inheriters_cache_dirty = true; } void ScriptServer::remove_global_class(const StringName &p_class) { global_classes.erase(p_class); + inheriters_cache_dirty = true; +} + +void ScriptServer::get_inheriters_list(const StringName &p_base_type, List<StringName> *r_classes) { + if (inheriters_cache_dirty) { + inheriters_cache.clear(); + for (const KeyValue<StringName, GlobalScriptClass> &K : global_classes) { + if (!inheriters_cache.has(K.value.base)) { + inheriters_cache[K.value.base] = Vector<StringName>(); + } + inheriters_cache[K.value.base].push_back(K.key); + } + for (KeyValue<StringName, Vector<StringName>> &K : inheriters_cache) { + K.value.sort_custom<StringName::AlphCompare>(); + } + inheriters_cache_dirty = false; + } + + if (!inheriters_cache.has(p_base_type)) { + return; + } + + const Vector<StringName> &v = inheriters_cache[p_base_type]; + for (int i = 0; i < v.size(); i++) { + r_classes->push_back(v[i]); + } } void ScriptServer::remove_global_class_by_path(const String &p_path) { for (const KeyValue<StringName, GlobalScriptClass> &kv : global_classes) { if (kv.value.path == p_path) { global_classes.erase(kv.key); + inheriters_cache_dirty = true; return; } } diff --git a/core/object/script_language.h b/core/object/script_language.h index 02d1880dc2..0c64b079c1 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -56,10 +56,12 @@ class ScriptServer { struct GlobalScriptClass { StringName language; String path; - String base; + StringName base; }; static HashMap<StringName, GlobalScriptClass> global_classes; + static HashMap<StringName, Vector<StringName>> inheriters_cache; + static bool inheriters_cache_dirty; public: static ScriptEditRequestFunction edit_request_func; @@ -87,6 +89,7 @@ public: static StringName get_global_class_base(const String &p_class); static StringName get_global_class_native_base(const String &p_class); static void get_global_class_list(List<StringName> *r_global_classes); + static void get_inheriters_list(const StringName &p_base_type, List<StringName> *r_classes); static void save_global_classes(); static void init_languages(); diff --git a/core/os/os.cpp b/core/os/os.cpp index c6fa8d307b..86469852e3 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -203,16 +203,26 @@ uint64_t OS::get_embedded_pck_offset() const { } // Helper function to ensure that a dir name/path will be valid on the OS -String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator) const { +String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const { + String safe_dir_name = p_dir_name; Vector<String> invalid_chars = String(": * ? \" < > |").split(" "); - if (p_allow_dir_separator) { + if (p_allow_paths) { // Dir separators are allowed, but disallow ".." to avoid going up the filesystem invalid_chars.push_back(".."); + safe_dir_name = safe_dir_name.replace("\\", "/").strip_edges(); } else { invalid_chars.push_back("/"); + invalid_chars.push_back("\\"); + safe_dir_name = safe_dir_name.strip_edges(); + + // These directory names are invalid. + if (safe_dir_name == ".") { + safe_dir_name = "dot"; + } else if (safe_dir_name == "..") { + safe_dir_name = "twodots"; + } } - String safe_dir_name = p_dir_name.replace("\\", "/").strip_edges(); for (int i = 0; i < invalid_chars.size(); i++) { safe_dir_name = safe_dir_name.replace(invalid_chars[i], "-"); } diff --git a/core/os/os.h b/core/os/os.h index 4818e9281a..436a83eae3 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -238,7 +238,7 @@ public: virtual uint64_t get_embedded_pck_offset() const; - String get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator = false) const; + String get_safe_dir_name(const String &p_dir_name, bool p_allow_paths = false) const; virtual String get_godot_dir_name() const; virtual String get_data_path() const; diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index 93731cf553..6fe53dfaac 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="JSON" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> +<class name="JSON" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <brief_description> Helper class for creating and parsing JSON data. </brief_description> @@ -49,13 +49,21 @@ Returns an empty string if the last call to [method parse] was successful, or the error message if it failed. </description> </method> + <method name="get_parsed_text" qualifiers="const"> + <return type="String" /> + <description> + Return the text parsed by [method parse] as long as the function is instructed to keep it. + </description> + </method> <method name="parse"> <return type="int" enum="Error" /> - <param index="0" name="json_string" type="String" /> + <param index="0" name="json_text" type="String" /> + <param index="1" name="keep_text" type="bool" default="false" /> <description> - Attempts to parse the [param json_string] provided. + Attempts to parse the [param json_text] provided. Returns an [enum Error]. If the parse was successful, it returns [constant OK] and the result can be retrieved using [member data]. If unsuccessful, use [method get_error_line] and [method get_error_message] for identifying the source of the failure. Non-static variant of [method parse_string], if you want custom error handling. + The optional [param keep_text] argument instructs the parser to keep a copy of the original text. This text can be obtained later by using the [method get_parsed_text] function and is used when saving the resource (instead of generating new text from [member data]). </description> </method> <method name="parse_string" qualifiers="static"> diff --git a/doc/classes/VisualInstance3D.xml b/doc/classes/VisualInstance3D.xml index e069642e50..3781045c02 100644 --- a/doc/classes/VisualInstance3D.xml +++ b/doc/classes/VisualInstance3D.xml @@ -64,7 +64,7 @@ <member name="sorting_offset" type="float" setter="set_sorting_offset" getter="get_sorting_offset" default="0.0"> The sorting offset used by this [VisualInstance3D]. Adjusting it to a higher value will make the [VisualInstance3D] reliably draw on top of other [VisualInstance3D]s that are otherwise positioned at the same spot. </member> - <member name="sorting_use_aabb_center" type="bool" setter="set_sorting_use_aabb_center" getter="is_sorting_use_aabb_center" default="true"> + <member name="sorting_use_aabb_center" type="bool" setter="set_sorting_use_aabb_center" getter="is_sorting_use_aabb_center"> If [code]true[/code], the object is sorted based on the [AABB] center. The object will be sorted based on the global position otherwise. The [AABB] center based sorting is generally more accurate for 3D models. The position based sorting instead allows to better control the drawing order when working with [GPUParticles3D] and [CPUParticles3D]. </member> diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index fb338b9849..89b1c1889e 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -803,7 +803,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend light_count++; - if (light_count == data.max_lights_per_item) { + if (light_count == data.max_lights_per_item - 1) { break; } } diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index e4bcc424b3..9547435607 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1535,8 +1535,6 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b } } - li->gl_id = r_omni_light_count; - scene_state.omni_light_sort[r_omni_light_count].instance = li; scene_state.omni_light_sort[r_omni_light_count].depth = distance; r_omni_light_count++; @@ -1560,8 +1558,6 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b } } - li->gl_id = r_spot_light_count; - scene_state.spot_light_sort[r_spot_light_count].instance = li; scene_state.spot_light_sort[r_spot_light_count].depth = distance; r_spot_light_count++; @@ -1584,8 +1580,11 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b LightData &light_data = (i < r_omni_light_count) ? scene_state.omni_lights[index] : scene_state.spot_lights[index]; RS::LightType type = (i < r_omni_light_count) ? RS::LIGHT_OMNI : RS::LIGHT_SPOT; GLES3::LightInstance *li = (i < r_omni_light_count) ? scene_state.omni_light_sort[index].instance : scene_state.spot_light_sort[index].instance; + real_t distance = (i < r_omni_light_count) ? scene_state.omni_light_sort[index].depth : scene_state.spot_light_sort[index].depth; RID base = li->light; + li->gl_id = index; + Transform3D light_transform = li->transform; Vector3 pos = inverse_transform.xform(light_transform.origin); @@ -1612,13 +1611,11 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b // Reuse fade begin, fade length and distance for shadow LOD determination later. float fade_begin = 0.0; float fade_length = 0.0; - real_t distance = 0.0; float fade = 1.0; if (light_storage->light_is_distance_fade_enabled(li->light)) { fade_begin = light_storage->light_get_distance_fade_begin(li->light); fade_length = light_storage->light_get_distance_fade_length(li->light); - distance = p_render_data->cam_transform.origin.distance_to(li->transform.origin); if (distance > fade_begin) { // Use `smoothstep()` to make opacity changes more gradual and less noticeable to the player. diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 8818ab2118..12def52d50 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1534,18 +1534,6 @@ AABB TextureStorage::decal_get_aabb(RID p_decal) const { return AABB(); } -/* DECAL INSTANCE API */ - -RID TextureStorage::decal_instance_create(RID p_decal) { - return RID(); -} - -void TextureStorage::decal_instance_free(RID p_decal_instance) { -} - -void TextureStorage::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) { -} - /* RENDER TARGET API */ GLuint TextureStorage::system_fbo = 0; diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index 9ffe16fd16..9d3f407226 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -561,9 +561,10 @@ public: /* DECAL INSTANCE */ - virtual RID decal_instance_create(RID p_decal) override; - virtual void decal_instance_free(RID p_decal_instance) override; - virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override; + virtual RID decal_instance_create(RID p_decal) override { return RID(); } + virtual void decal_instance_free(RID p_decal_instance) override {} + virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override {} + virtual void decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) override {} /* RENDER TARGET API */ diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 37a94ce4cc..ea40622afc 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -34,7 +34,6 @@ #include "core/os/os.h" #include "core/string/print_string.h" - #include <share.h> // _SH_DENYNO #include <shlwapi.h> #define WIN32_LEAN_AND_MEAN @@ -58,7 +57,27 @@ void FileAccessWindows::check_errors() const { } } +bool FileAccessWindows::is_path_invalid(const String &p_path) { + // Check for invalid operating system file. + String fname = p_path; + int dot = fname.find("."); + if (dot != -1) { + fname = fname.substr(0, dot); + } + fname = fname.to_lower(); + return invalid_files.has(fname); +} + Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) { + if (is_path_invalid(p_path)) { +#ifdef DEBUG_ENABLED + if (p_mode_flags != READ) { + WARN_PRINT("The path :" + p_path + " is a reserved Windows system pipe, so it can't be used for creating files."); + } +#endif + return ERR_INVALID_PARAMETER; + } + _close(); path_src = p_path; @@ -313,6 +332,10 @@ void FileAccessWindows::store_buffer(const uint8_t *p_src, uint64_t p_length) { } bool FileAccessWindows::file_exists(const String &p_name) { + if (is_path_invalid(p_name)) { + return false; + } + String filename = fix_path(p_name); FILE *g = _wfsopen((LPCWSTR)(filename.utf16().get_data()), L"rb", _SH_DENYNO); if (g == nullptr) { @@ -324,6 +347,10 @@ bool FileAccessWindows::file_exists(const String &p_name) { } uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { + if (is_path_invalid(p_file)) { + return 0; + } + String file = fix_path(p_file); if (file.ends_with("/") && file != "/") { file = file.substr(0, file.length() - 1); @@ -352,4 +379,20 @@ FileAccessWindows::~FileAccessWindows() { _close(); } +HashSet<String> FileAccessWindows::invalid_files; + +void FileAccessWindows::initialize() { + static const char *reserved_files[]{ + "con", "prn", "aux", "nul", "com0", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt0", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", nullptr + }; + int reserved_file_index = 0; + while (reserved_files[reserved_file_index] != nullptr) { + invalid_files.insert(reserved_files[reserved_file_index]); + reserved_file_index++; + } +} +void FileAccessWindows::finalize() { + invalid_files.clear(); +} + #endif // WINDOWS_ENABLED diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index 832cef3363..2b9960d494 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -50,6 +50,9 @@ class FileAccessWindows : public FileAccess { void _close(); + static bool is_path_invalid(const String &p_path); + static HashSet<String> invalid_files; + public: virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file virtual bool is_open() const override; ///< true when file is open @@ -79,6 +82,9 @@ public: virtual uint32_t _get_unix_permissions(const String &p_file) override; virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override; + static void initialize(); + static void finalize(); + FileAccessWindows() {} virtual ~FileAccessWindows(); }; diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp deleted file mode 100644 index dd27b61df9..0000000000 --- a/editor/array_property_edit.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************/ -/* array_property_edit.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#include "array_property_edit.h" - -#include "core/io/marshalls.h" -#include "editor/editor_undo_redo_manager.h" - -#define ITEMS_PER_PAGE 100 - -Variant ArrayPropertyEdit::get_array() const { - Object *o = ObjectDB::get_instance(obj); - if (!o) { - return Array(); - } - Variant arr = o->get(property); - if (!arr.is_array()) { - Callable::CallError ce; - Variant::construct(default_type, arr, nullptr, 0, ce); - } - return arr; -} - -void ArrayPropertyEdit::_notif_change() { - notify_property_list_changed(); -} - -void ArrayPropertyEdit::_set_size(int p_size) { - Variant arr = get_array(); - arr.call("resize", p_size); - Object *o = ObjectDB::get_instance(obj); - if (!o) { - return; - } - - o->set(property, arr); -} - -void ArrayPropertyEdit::_set_value(int p_idx, const Variant &p_value) { - Variant arr = get_array(); - arr.set(p_idx, p_value); - Object *o = ObjectDB::get_instance(obj); - if (!o) { - return; - } - - o->set(property, arr); -} - -bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { - String pn = p_name; - - if (pn.begins_with("array/")) { - if (pn == "array/size") { - Variant arr = get_array(); - int size = arr.call("size"); - - int newsize = p_value; - if (newsize == size) { - return true; - } - - EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - ur->create_action(TTR("Resize Array")); - ur->add_do_method(this, "_set_size", newsize); - ur->add_undo_method(this, "_set_size", size); - if (newsize < size) { - for (int i = newsize; i < size; i++) { - ur->add_undo_method(this, "_set_value", i, arr.get(i)); - } - } else if (newsize > size) { - Variant init; - Callable::CallError ce; - Variant::Type new_type = subtype; - if (new_type == Variant::NIL && size) { - new_type = arr.get(size - 1).get_type(); - } - if (new_type != Variant::NIL) { - Variant::construct(new_type, init, nullptr, 0, ce); - for (int i = size; i < newsize; i++) { - ur->add_do_method(this, "_set_value", i, init); - } - } - } - ur->add_do_method(this, "_notif_change"); - ur->add_undo_method(this, "_notif_change"); - ur->commit_action(); - return true; - } - if (pn == "array/page") { - page = p_value; - notify_property_list_changed(); - return true; - } - - } else if (pn.begins_with("indices")) { - if (pn.contains("_")) { - //type - int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int(); - - int type = p_value; - - Variant arr = get_array(); - - Variant value = arr.get(idx); - if (value.get_type() != type && type >= 0 && type < Variant::VARIANT_MAX) { - Callable::CallError ce; - Variant new_value; - Variant::construct(Variant::Type(type), new_value, nullptr, 0, ce); - EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - - ur->create_action(TTR("Change Array Value Type")); - ur->add_do_method(this, "_set_value", idx, new_value); - ur->add_undo_method(this, "_set_value", idx, value); - ur->add_do_method(this, "_notif_change"); - ur->add_undo_method(this, "_notif_change"); - ur->commit_action(); - } - return true; - - } else { - int idx = pn.get_slicec('/', 1).to_int(); - Variant arr = get_array(); - - Variant value = arr.get(idx); - EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - - ur->create_action(TTR("Change Array Value")); - ur->add_do_method(this, "_set_value", idx, p_value); - ur->add_undo_method(this, "_set_value", idx, value); - ur->commit_action(); - return true; - } - } - - return false; -} - -bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { - Variant arr = get_array(); - //int size = arr.call("size"); - - String pn = p_name; - if (pn.begins_with("array/")) { - if (pn == "array/size") { - r_ret = arr.call("size"); - return true; - } - if (pn == "array/page") { - r_ret = page; - return true; - } - } else if (pn.begins_with("indices")) { - if (pn.contains("_")) { - //type - int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int(); - bool valid; - r_ret = arr.get(idx, &valid); - if (valid) { - r_ret = r_ret.get_type(); - } - return valid; - - } else { - int idx = pn.get_slicec('/', 1).to_int(); - bool valid; - r_ret = arr.get(idx, &valid); - - if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) { - r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id(); - } - - return valid; - } - } - - return false; -} - -void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { - Variant arr = get_array(); - int size = arr.call("size"); - - p_list->push_back(PropertyInfo(Variant::INT, "array/size", PROPERTY_HINT_RANGE, "0,100000,1")); - int pages = size / ITEMS_PER_PAGE; - if (pages > 0) { - p_list->push_back(PropertyInfo(Variant::INT, "array/page", PROPERTY_HINT_RANGE, "0," + itos(pages) + ",1")); - } - - int offset = page * ITEMS_PER_PAGE; - - int items = MIN(size - offset, ITEMS_PER_PAGE); - - for (int i = 0; i < items; i++) { - Variant v = arr.get(i + offset); - bool is_typed = arr.get_type() != Variant::ARRAY || subtype != Variant::NIL; - - if (!is_typed) { - p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset) + "_type", PROPERTY_HINT_ENUM, vtypes)); - } - - if (v.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(v)) { - p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset), PROPERTY_HINT_OBJECT_ID, "Object")); - continue; - } - - if (is_typed || v.get_type() != Variant::NIL) { - PropertyInfo pi(v.get_type(), "indices/" + itos(i + offset)); - if (subtype != Variant::NIL) { - pi.type = Variant::Type(subtype); - pi.hint = PropertyHint(subtype_hint); - pi.hint_string = subtype_hint_string; - } else if (v.get_type() == Variant::OBJECT) { - pi.hint = PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string = "Resource"; - } - - p_list->push_back(pi); - } - } -} - -void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const String &p_hint_string, Variant::Type p_deftype) { - page = 0; - property = p_prop; - obj = p_obj->get_instance_id(); - default_type = p_deftype; - - if (!p_hint_string.is_empty()) { - int hint_subtype_separator = p_hint_string.find(":"); - if (hint_subtype_separator >= 0) { - String subtype_string = p_hint_string.substr(0, hint_subtype_separator); - - int slash_pos = subtype_string.find("/"); - if (slash_pos >= 0) { - subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int()); - subtype_string = subtype_string.substr(0, slash_pos); - } - - subtype_hint_string = p_hint_string.substr(hint_subtype_separator + 1, p_hint_string.size() - hint_subtype_separator - 1); - subtype = Variant::Type(subtype_string.to_int()); - } - } -} - -Node *ArrayPropertyEdit::get_node() { - return Object::cast_to<Node>(ObjectDB::get_instance(obj)); -} - -bool ArrayPropertyEdit::_dont_undo_redo() { - return true; -} - -void ArrayPropertyEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_size"), &ArrayPropertyEdit::_set_size); - ClassDB::bind_method(D_METHOD("_set_value"), &ArrayPropertyEdit::_set_value); - ClassDB::bind_method(D_METHOD("_notif_change"), &ArrayPropertyEdit::_notif_change); - ClassDB::bind_method(D_METHOD("_dont_undo_redo"), &ArrayPropertyEdit::_dont_undo_redo); -} - -ArrayPropertyEdit::ArrayPropertyEdit() { - page = 0; - for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (i > 0) { - vtypes += ","; - } - vtypes += Variant::get_type_name(Variant::Type(i)); - } - default_type = Variant::NIL; - subtype = Variant::NIL; - subtype_hint = PROPERTY_HINT_NONE; - subtype_hint_string = ""; -} diff --git a/editor/array_property_edit.h b/editor/array_property_edit.h deleted file mode 100644 index 6e34a06943..0000000000 --- a/editor/array_property_edit.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************/ -/* array_property_edit.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#ifndef ARRAY_PROPERTY_EDIT_H -#define ARRAY_PROPERTY_EDIT_H - -#include "scene/main/node.h" - -class ArrayPropertyEdit : public RefCounted { - GDCLASS(ArrayPropertyEdit, RefCounted); - - int page; - ObjectID obj; - StringName property; - String vtypes; - String subtype_hint_string; - PropertyHint subtype_hint; - Variant::Type subtype; - Variant get_array() const; - Variant::Type default_type; - - void _notif_change(); - void _set_size(int p_size); - void _set_value(int p_idx, const Variant &p_value); - - bool _dont_undo_redo(); - -protected: - static void _bind_methods(); - 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; - -public: - void edit(Object *p_obj, const StringName &p_prop, const String &p_hint_string, Variant::Type p_deftype); - - Node *get_node(); - - ArrayPropertyEdit(); -}; - -#endif // ARRAY_PROPERTY_EDIT_H diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp deleted file mode 100644 index ad59a1c169..0000000000 --- a/editor/dictionary_property_edit.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************/ -/* dictionary_property_edit.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#include "dictionary_property_edit.h" -#include "editor/editor_undo_redo_manager.h" - -void DictionaryPropertyEdit::_notif_change() { - notify_property_list_changed(); -} - -void DictionaryPropertyEdit::_set_key(const Variant &p_old_key, const Variant &p_new_key) { - // TODO: Set key of a dictionary is not allowed yet -} - -void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_value) { - Dictionary dict = get_dictionary(); - dict[p_key] = p_value; - Object *o = ObjectDB::get_instance(obj); - if (!o) { - return; - } - - o->set(property, dict); -} - -Variant DictionaryPropertyEdit::get_dictionary() const { - Object *o = ObjectDB::get_instance(obj); - if (!o) { - return Dictionary(); - } - Variant dict = o->get(property); - if (dict.get_type() != Variant::DICTIONARY) { - return Dictionary(); - } - return dict; -} - -void DictionaryPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { - Dictionary dict = get_dictionary(); - - Array keys = dict.keys(); - keys.sort(); - - for (int i = 0; i < keys.size(); i++) { - String index = itos(i); - - const Variant &key = keys[i]; - PropertyInfo pi(key.get_type(), index + ": key"); - p_list->push_back(pi); - - const Variant &value = dict[key]; - pi = PropertyInfo(value.get_type(), index + ": value"); - p_list->push_back(pi); - } -} - -void DictionaryPropertyEdit::edit(Object *p_obj, const StringName &p_prop) { - property = p_prop; - obj = p_obj->get_instance_id(); -} - -Node *DictionaryPropertyEdit::get_node() { - Object *o = ObjectDB::get_instance(obj); - if (!o) { - return nullptr; - } - - return cast_to<Node>(o); -} - -bool DictionaryPropertyEdit::_dont_undo_redo() { - return true; -} - -void DictionaryPropertyEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_key"), &DictionaryPropertyEdit::_set_key); - ClassDB::bind_method(D_METHOD("_set_value"), &DictionaryPropertyEdit::_set_value); - ClassDB::bind_method(D_METHOD("_notif_change"), &DictionaryPropertyEdit::_notif_change); - ClassDB::bind_method(D_METHOD("_dont_undo_redo"), &DictionaryPropertyEdit::_dont_undo_redo); -} - -bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { - Dictionary dict = get_dictionary(); - Array keys = dict.keys(); - keys.sort(); - - String pn = p_name; - int slash = pn.find(": "); - if (slash != -1 && pn.length() > slash) { - String type = pn.substr(slash + 2, pn.length()); - int index = pn.substr(0, slash).to_int(); - if (type == "key" && index < keys.size()) { - const Variant &key = keys[index]; - EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - - ur->create_action(TTR("Change Dictionary Key")); - ur->add_do_method(this, "_set_key", key, p_value); - ur->add_undo_method(this, "_set_key", p_value, key); - ur->commit_action(); - - return true; - } else if (type == "value" && index < keys.size()) { - const Variant &key = keys[index]; - if (dict.has(key)) { - Variant value = dict[key]; - EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - - ur->create_action(TTR("Change Dictionary Value")); - ur->add_do_method(this, "_set_value", key, p_value); - ur->add_undo_method(this, "_set_value", key, value); - ur->commit_action(); - - return true; - } - } - } - - return false; -} - -bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { - Dictionary dict = get_dictionary(); - Array keys = dict.keys(); - keys.sort(); - - String pn = p_name; - int slash = pn.find(": "); - - if (slash != -1 && pn.length() > slash) { - String type = pn.substr(slash + 2, pn.length()); - int index = pn.substr(0, slash).to_int(); - - if (type == "key" && index < keys.size()) { - r_ret = keys[index]; - return true; - } else if (type == "value" && index < keys.size()) { - const Variant &key = keys[index]; - if (dict.has(key)) { - r_ret = dict[key]; - return true; - } - } - } - - return false; -} - -DictionaryPropertyEdit::DictionaryPropertyEdit() { -} diff --git a/editor/dictionary_property_edit.h b/editor/dictionary_property_edit.h deleted file mode 100644 index 197bb394d4..0000000000 --- a/editor/dictionary_property_edit.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************/ -/* dictionary_property_edit.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#ifndef DICTIONARY_PROPERTY_EDIT_H -#define DICTIONARY_PROPERTY_EDIT_H - -#include "scene/main/node.h" - -class DictionaryPropertyEdit : public RefCounted { - GDCLASS(DictionaryPropertyEdit, RefCounted); - - ObjectID obj; - StringName property; - - void _notif_change(); - void _set_key(const Variant &p_old_key, const Variant &p_new_key); - void _set_value(const Variant &p_key, const Variant &p_value); - - Variant get_dictionary() const; - - bool _dont_undo_redo(); - -protected: - static void _bind_methods(); - 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; - -public: - void edit(Object *p_obj, const StringName &p_prop); - - Node *get_node(); - - DictionaryPropertyEdit(); -}; - -#endif // DICTIONARY_PROPERTY_EDIT_H diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index a1c913aadd..cb71a2457b 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -42,12 +42,6 @@ #include "editor/plugins/script_editor_plugin.h" #include "editor/scene_tree_dock.h" -HashMap<StringName, List<StringName>> EditorResourcePicker::allowed_types_cache; - -void EditorResourcePicker::clear_caches() { - allowed_types_cache.clear(); -} - void EditorResourcePicker::_update_resource() { String resource_path; if (edited_resource.is_valid() && edited_resource->get_path().is_resource_file()) { @@ -464,7 +458,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { if (!base_type.is_empty()) { int idx = 0; - HashSet<String> allowed_types; + HashSet<StringName> allowed_types; _get_allowed_types(false, &allowed_types); Vector<EditorData::CustomType> custom_resources; @@ -472,7 +466,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"]; } - for (const String &E : allowed_types) { + for (const StringName &E : allowed_types) { const String &t = E; bool is_custom_resource = false; @@ -561,53 +555,44 @@ String EditorResourcePicker::_get_resource_type(const Ref<Resource> &p_resource) return res_type; } -void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const { - Vector<String> allowed_types = base_type.split(","); - int size = allowed_types.size(); +static void _add_allowed_type(const StringName &p_type, HashSet<StringName> *p_vector) { + if (p_vector->has(p_type)) { + // Already added + return; + } - List<StringName> global_classes; - ScriptServer::get_global_class_list(&global_classes); + if (ClassDB::class_exists(p_type)) { + // Engine class, - for (int i = 0; i < size; i++) { - String base = allowed_types[i].strip_edges(); - if (!ClassDB::is_virtual(base)) { - p_vector->insert(base); + if (!ClassDB::is_virtual(p_type)) { + p_vector->insert(p_type); } - // If we hit a familiar base type, take all the data from cache. - if (allowed_types_cache.has(base)) { - List<StringName> allowed_subtypes = allowed_types_cache[base]; - for (const StringName &subtype_name : allowed_subtypes) { - if (!ClassDB::is_virtual(subtype_name)) { - p_vector->insert(subtype_name); - } - } - } else { - List<StringName> allowed_subtypes; + List<StringName> inheriters; + ClassDB::get_inheriters_from_class(p_type, &inheriters); + for (const StringName &S : inheriters) { + _add_allowed_type(S, p_vector); + } + } else { + // Script class. + p_vector->insert(p_type); + } - List<StringName> inheriters; - if (!ScriptServer::is_global_class(base)) { - ClassDB::get_inheriters_from_class(base, &inheriters); - } - for (const StringName &subtype_name : inheriters) { - if (!ClassDB::is_virtual(subtype_name)) { - p_vector->insert(subtype_name); - } - allowed_subtypes.push_back(subtype_name); - } + List<StringName> inheriters; + ScriptServer::get_inheriters_list(p_type, &inheriters); + for (const StringName &S : inheriters) { + _add_allowed_type(S, p_vector); + } +} - for (const StringName &subtype_name : global_classes) { - if (EditorNode::get_editor_data().script_class_is_parent(subtype_name, base)) { - if (!ClassDB::is_virtual(subtype_name)) { - p_vector->insert(subtype_name); - } - allowed_subtypes.push_back(subtype_name); - } - } +void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<StringName> *p_vector) const { + Vector<String> allowed_types = base_type.split(","); + int size = allowed_types.size(); - // Store the subtypes of the base type in the cache for future use. - allowed_types_cache[base] = allowed_subtypes; - } + for (int i = 0; i < size; i++) { + String base = allowed_types[i].strip_edges(); + + _add_allowed_type(base, p_vector); if (p_with_convert) { if (base == "BaseMaterial3D") { @@ -619,14 +604,6 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSet<Strin } } } - - if (EditorNode::get_editor_data().get_custom_types().has("Resource")) { - Vector<EditorData::CustomType> custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"]; - - for (int i = 0; i < custom_resources.size(); i++) { - p_vector->insert(custom_resources[i].name); - } - } } bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { @@ -654,7 +631,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { } } - HashSet<String> allowed_types; + HashSet<StringName> allowed_types; _get_allowed_types(true, &allowed_types); if (res.is_valid()) { @@ -673,9 +650,9 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { return false; } -bool EditorResourcePicker::_is_type_valid(const String p_type_name, HashSet<String> p_allowed_types) const { - for (const String &E : p_allowed_types) { - String at = E.strip_edges(); +bool EditorResourcePicker::_is_type_valid(const String p_type_name, HashSet<StringName> p_allowed_types) const { + for (const StringName &E : p_allowed_types) { + String at = E; if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) { return true; } @@ -721,15 +698,15 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ } if (dropped_resource.is_valid()) { - HashSet<String> allowed_types; + HashSet<StringName> allowed_types; _get_allowed_types(false, &allowed_types); String res_type = _get_resource_type(dropped_resource); // If the accepted dropped resource is from the extended list, it requires conversion. if (!_is_type_valid(res_type, allowed_types)) { - for (const String &E : allowed_types) { - String at = E.strip_edges(); + for (const StringName &E : allowed_types) { + String at = E; if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) { // Use existing resource if possible and only replace its data. @@ -832,7 +809,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { // There is a possibility that the new base type is conflicting with the existing value. // Keep the value, but warn the user that there is a potential mistake. if (!base_type.is_empty() && edited_resource.is_valid()) { - HashSet<String> allowed_types; + HashSet<StringName> allowed_types; _get_allowed_types(true, &allowed_types); StringName custom_class; @@ -846,10 +823,6 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) { String class_str = (custom_class == StringName() ? edited_resource->get_class() : vformat("%s (%s)", custom_class, edited_resource->get_class())); WARN_PRINT(vformat("Value mismatch between the new base type of this EditorResourcePicker, '%s', and the type of the value it already has, '%s'.", base_type, class_str)); } - } else { - // Call the method to build the cache immediately. - HashSet<String> allowed_types; - _get_allowed_types(false, &allowed_types); } } @@ -858,7 +831,7 @@ String EditorResourcePicker::get_base_type() const { } Vector<String> EditorResourcePicker::get_allowed_types() const { - HashSet<String> allowed_types; + HashSet<StringName> allowed_types; _get_allowed_types(false, &allowed_types); Vector<String> types; @@ -866,7 +839,7 @@ Vector<String> EditorResourcePicker::get_allowed_types() const { int i = 0; String *w = types.ptrw(); - for (const String &E : allowed_types) { + for (const StringName &E : allowed_types) { w[i] = E; i++; } @@ -882,7 +855,7 @@ void EditorResourcePicker::set_edited_resource(Ref<Resource> p_resource) { } if (!base_type.is_empty()) { - HashSet<String> allowed_types; + HashSet<StringName> allowed_types; _get_allowed_types(true, &allowed_types); StringName custom_class; diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index 8641cb6e84..a302e24957 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -42,8 +42,6 @@ class EditorQuickOpen; class EditorResourcePicker : public HBoxContainer { GDCLASS(EditorResourcePicker, HBoxContainer); - static HashMap<StringName, List<StringName>> allowed_types_cache; - String base_type; Ref<Resource> edited_resource; @@ -92,9 +90,9 @@ class EditorResourcePicker : public HBoxContainer { void _button_input(const Ref<InputEvent> &p_event); String _get_resource_type(const Ref<Resource> &p_resource) const; - void _get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const; + void _get_allowed_types(bool p_with_convert, HashSet<StringName> *p_vector) const; bool _is_drop_valid(const Dictionary &p_drag_data) const; - bool _is_type_valid(const String p_type_name, HashSet<String> p_allowed_types) const; + bool _is_type_valid(const String p_type_name, HashSet<StringName> p_allowed_types) const; Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; @@ -118,8 +116,6 @@ protected: GDVIRTUAL1R(bool, _handle_menu_selected, int) public: - static void clear_caches(); - void set_base_type(const String &p_base_type); String get_base_type() const; Vector<String> get_allowed_types() const; diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp index cc96107f97..1d147cc5b9 100644 --- a/editor/export/editor_export.cpp +++ b/editor/export/editor_export.cpp @@ -77,7 +77,6 @@ void EditorExport::_save() { config->set_value(section, "encryption_exclude_filters", preset->get_enc_ex_filter()); config->set_value(section, "encrypt_pck", preset->get_enc_pck()); config->set_value(section, "encrypt_directory", preset->get_enc_directory()); - config->set_value(section, "script_export_mode", preset->get_script_export_mode()); config->set_value(section, "script_encryption_key", preset->get_script_encryption_key()); String option_section = "preset." + itos(i) + ".options"; @@ -264,9 +263,6 @@ void EditorExport::load_config() { if (config->has_section_key(section, "encryption_exclude_filters")) { preset->set_enc_ex_filter(config->get_value(section, "encryption_exclude_filters")); } - if (config->has_section_key(section, "script_export_mode")) { - preset->set_script_export_mode(config->get_value(section, "script_export_mode")); - } if (config->has_section_key(section, "script_encryption_key")) { preset->set_script_encryption_key(config->get_value(section, "script_encryption_key")); } diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index 6cd8e85e6a..c6365806b3 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -203,15 +203,6 @@ bool EditorExportPreset::get_enc_directory() const { return enc_directory; } -void EditorExportPreset::set_script_export_mode(int p_mode) { - script_mode = p_mode; - EditorExport::singleton->save_presets(); -} - -int EditorExportPreset::get_script_export_mode() const { - return script_mode; -} - void EditorExportPreset::set_script_encryption_key(const String &p_key) { script_key = p_key; EditorExport::singleton->save_presets(); diff --git a/editor/export/editor_export_preset.h b/editor/export/editor_export_preset.h index 2055416d4b..de208f410e 100644 --- a/editor/export/editor_export_preset.h +++ b/editor/export/editor_export_preset.h @@ -46,11 +46,6 @@ public: EXCLUDE_SELECTED_RESOURCES, }; - enum ScriptExportMode { - MODE_SCRIPT_TEXT, - MODE_SCRIPT_COMPILED, - }; - private: Ref<EditorExportPlatform> platform; ExportFilter export_filter = EXPORT_ALL_RESOURCES; @@ -78,7 +73,6 @@ private: bool enc_pck = false; bool enc_directory = false; - int script_mode = MODE_SCRIPT_COMPILED; String script_key; protected: @@ -132,9 +126,6 @@ public: void set_enc_directory(bool p_enabled); bool get_enc_directory() const; - void set_script_export_mode(int p_mode); - int get_script_export_mode() const; - void set_script_encryption_key(const String &p_key); String get_script_encryption_key() const; diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index e099acca00..2caebc6f04 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -317,9 +317,6 @@ void ProjectExportDialog::_edit_preset(int p_index) { bool enc_directory_mode = current->get_enc_directory(); enc_directory->set_pressed(enc_directory_mode); - int script_export_mode = current->get_script_export_mode(); - script_mode->select(script_export_mode); - String key = current->get_script_encryption_key(); if (!updating_script_key) { script_key->set_text(key); @@ -513,19 +510,6 @@ void ProjectExportDialog::_enc_directory_changed(bool p_pressed) { _update_current_preset(); } -void ProjectExportDialog::_script_export_mode_changed(int p_mode) { - if (updating) { - return; - } - - Ref<EditorExportPreset> current = get_current_preset(); - ERR_FAIL_COND(current.is_null()); - - current->set_script_export_mode(p_mode); - - _update_current_preset(); -} - void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) { if (updating) { return; @@ -1111,12 +1095,6 @@ ProjectExportDialog::ProjectExportDialog() { exclude_filters); exclude_filters->connect("text_changed", callable_mp(this, &ProjectExportDialog::_filter_changed)); - script_mode = memnew(OptionButton); - resources_vb->add_margin_child(TTR("GDScript Export Mode:"), script_mode); - script_mode->add_item(TTR("Text"), (int)EditorExportPreset::MODE_SCRIPT_TEXT); - script_mode->add_item(TTR("Compiled Bytecode (Faster Loading)"), (int)EditorExportPreset::MODE_SCRIPT_COMPILED); - script_mode->connect("item_selected", callable_mp(this, &ProjectExportDialog::_script_export_mode_changed)); - // Feature tags. VBoxContainer *feature_vb = memnew(VBoxContainer); diff --git a/editor/export/project_export.h b/editor/export/project_export.h index 1138d598cb..d392dba2a4 100644 --- a/editor/export/project_export.h +++ b/editor/export/project_export.h @@ -86,7 +86,6 @@ private: LineEdit *custom_features = nullptr; RichTextLabel *custom_feature_display = nullptr; - OptionButton *script_mode = nullptr; LineEdit *script_key = nullptr; Label *script_key_error = nullptr; @@ -152,7 +151,6 @@ private: void _enc_pck_changed(bool p_pressed); void _enc_directory_changed(bool p_pressed); void _enc_filters_changed(const String &p_text); - void _script_export_mode_changed(int p_mode); void _script_encryption_key_changed(const String &p_key); bool _validate_script_encryption_key(const String &p_key); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 7ba60bfaad..f1ea8e8e65 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2590,11 +2590,18 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str if (p_paths.size() == 1) { p_popup->add_separator(); if (p_display_path_dependent_options) { - p_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); - p_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); - p_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); - p_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); - p_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); + PopupMenu *new_menu = memnew(PopupMenu); + new_menu->set_name("New"); + new_menu->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option)); + + p_popup->add_child(new_menu); + p_popup->add_submenu_item(TTR("New"), "New"); + + new_menu->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("Folder..."), FILE_NEW_FOLDER); + new_menu->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("Scene..."), FILE_NEW_SCENE); + new_menu->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("Script..."), FILE_NEW_SCRIPT); + new_menu->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("Resource..."), FILE_NEW_RESOURCE); + new_menu->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("TextFile..."), FILE_NEW_TEXTFILE); p_popup->add_separator(); } diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 2a55ac949f..4f0db70681 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -48,6 +48,8 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, if (name == "scripts") { // Script set is intercepted at object level (check Variant Object::get()), so use a different name. name = "script"; + } else if (name.begins_with("Metadata/")) { + name = name.replace_first("Metadata/", "metadata/"); } Node *node_path_target = nullptr; @@ -98,6 +100,8 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const { String name = p_name; if (name == "scripts") { // Script set is intercepted at object level (check Variant Object::get()), so use a different name. name = "script"; + } else if (name.begins_with("Metadata/")) { + name = name.replace_first("Metadata/", "metadata/"); } for (const NodePath &E : nodes) { @@ -137,14 +141,18 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> plist; n->get_property_list(&plist, true); - for (const PropertyInfo &F : plist) { + for (PropertyInfo F : plist) { if (F.name == "script") { continue; // Added later manually, since this is intercepted before being set (check Variant Object::get()). + } else if (F.name.begins_with("metadata/")) { + F.name = F.name.replace_first("metadata/", "Metadata/"); // Trick to not get actual metadata edited from MultiNodeEdit. } + if (!usage.has(F.name)) { PLData pld; pld.uses = 0; pld.info = F; + pld.info.name = F.name; usage[F.name] = pld; data_list.push_back(usage.getptr(F.name)); } diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index c9a23d06ac..b5dca26c63 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -210,6 +210,7 @@ static const char *gdscript_function_renames[][2] = { // { "set_v_offset", "set_drag_vertical_offset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D // {"get_points","get_points_id"},// Astar, broke Line2D, Convexpolygonshape // {"get_v_scroll","get_v_scroll_bar"},//ItemList, broke TextView + // { "get_stylebox", "get_theme_stylebox" }, // Control - Will rename the method in Theme as well, skipping { "_about_to_show", "_about_to_popup" }, // ColorPickerButton { "_get_configuration_warning", "_get_configuration_warnings" }, // Node { "_set_current", "set_current" }, // Camera2D @@ -665,6 +666,7 @@ static const char *csharp_function_renames[][2] = { // { "SetVOffset", "SetDragVerticalOffset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D // {"GetPoints","GetPointsId"},// Astar, broke Line2D, Convexpolygonshape // {"GetVScroll","GetVScrollBar"},//ItemList, broke TextView + // { "GetStylebox", "GetThemeStylebox" }, // Control - Will rename the method in Theme as well, skipping { "AddSpatialGizmoPlugin", "AddNode3dGizmoPlugin" }, // EditorPlugin { "RenderingServer", "GetTabAlignment" }, // Tab { "_AboutToShow", "_AboutToPopup" }, // ColorPickerButton @@ -1078,6 +1080,7 @@ static const char *gdscript_properties_renames[][2] = { // { "zfar", "far" }, // Camera3D // { "znear", "near" }, // Camera3D // { "filename", "scene_file_path" }, // Node + // { "pressed", "button_pressed" }, // BaseButton - Will also rename the signal, skipping for now { "as_normalmap", "as_normal_map" }, // NoiseTexture { "bbcode_text", "text" }, // RichTextLabel { "bg", "panel" }, // Theme @@ -1113,6 +1116,7 @@ static const char *gdscript_properties_renames[][2] = { { "gravity_vec", "gravity_direction" }, // Area2D { "hint_tooltip", "tooltip_text" }, // Control { "hseparation", "h_separation" }, // Theme + { "icon_align", "icon_alignment" }, // Button { "iterations_per_second", "physics_ticks_per_second" }, // Engine { "invert_enable", "invert_enabled" }, // Polygon2D { "margin_bottom", "offset_bottom" }, // Control broke NinePatchRect, StyleBox @@ -1137,7 +1141,7 @@ static const char *gdscript_properties_renames[][2] = { { "rect_position", "position" }, // Control { "rect_global_position", "global_position" }, // Control { "rect_size", "size" }, // Control - { "rect_min_size", "minimum_size" }, // Control + { "rect_min_size", "custom_minimum_size" }, // Control { "rect_rotation", "rotation" }, // Control { "rect_scale", "scale" }, // Control { "rect_pivot_offset", "pivot_offset" }, // Control @@ -1192,6 +1196,7 @@ static const char *csharp_properties_renames[][2] = { // { "WrapEnabled", "WrapMode" }, // TextEdit // { "Zfar", "Far" }, // Camera3D // { "Znear", "Near" }, // Camera3D + // { "Pressed", "ButtonPressed" }, // BaseButton - Will also rename the signal, skipping for now { "AsNormalmap", "AsNormalMap" }, // NoiseTexture { "BbcodeText", "Text" }, // RichTextLabel { "CaretBlinkSpeed", "CaretBlinkInterval" }, // TextEdit, LineEdit @@ -1221,6 +1226,7 @@ static const char *csharp_properties_renames[][2] = { { "GravityVec", "GravityDirection" }, // Area2D { "HintTooltip", "TooltipText" }, // Control { "Hseparation", "HSeparation" }, // Theme + { "IconAlign", "IconAlignment" }, // Button { "IterationsPerSecond", "PhysicsTicksPerSecond" }, // Engine { "InvertEnable", "InvertEnabled" }, // Polygon2D { "MarginBottom", "OffsetBottom" }, // Control broke NinePatchRect, StyleBox @@ -1363,6 +1369,18 @@ static const char *project_settings_renames[][2] = { { nullptr, nullptr }, }; +static const char *input_map_renames[][2] = { + { ",\"alt\":", ",\"alt_pressed\":" }, + { ",\"shift\":", ",\"shift_pressed\":" }, + { ",\"control\":", ",\"ctrl_pressed\":" }, + { ",\"meta\":", ",\"meta_pressed\":" }, + { ",\"scancode\":", ",\"keycode\":" }, + { ",\"physical_scancode\":", ",\"physical_keycode\":" }, + { ",\"doubleclick\":", ",\"double_click\":" }, + + { nullptr, nullptr }, +}; + static const char *builtin_types_renames[][2] = { { "PoolByteArray", "PackedByteArray" }, { "PoolColorArray", "PackedColorArray" }, @@ -1878,6 +1896,7 @@ public: LocalVector<RegEx *> enum_regexes; LocalVector<RegEx *> gdscript_function_regexes; LocalVector<RegEx *> project_settings_regexes; + LocalVector<RegEx *> input_map_regexes; LocalVector<RegEx *> gdscript_properties_regexes; LocalVector<RegEx *> gdscript_signals_regexes; LocalVector<RegEx *> shaders_regexes; @@ -1901,6 +1920,10 @@ public: for (unsigned int current_index = 0; project_settings_renames[current_index][0]; current_index++) { project_settings_regexes.push_back(memnew(RegEx(String("\\b") + project_settings_renames[current_index][0] + "\\b"))); } + // Input Map. + for (unsigned int current_index = 0; input_map_renames[current_index][0]; current_index++) { + input_map_regexes.push_back(memnew(RegEx(String("\\b") + input_map_renames[current_index][0] + "\\b"))); + } // GDScript properties. for (unsigned int current_index = 0; gdscript_properties_renames[current_index][0]; current_index++) { gdscript_properties_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_properties_renames[current_index][0] + "\\b"))); @@ -1972,6 +1995,9 @@ public: for (unsigned int i = 0; i < project_settings_regexes.size(); i++) { memdelete(project_settings_regexes[i]); } + for (unsigned int i = 0; i < input_map_regexes.size(); i++) { + memdelete(input_map_regexes[i]); + } for (unsigned int i = 0; i < gdscript_properties_regexes.size(); i++) { memdelete(gdscript_properties_regexes[i]); } @@ -2123,6 +2149,7 @@ int ProjectConverter3To4::convert() { } else if (file_name.ends_with("project.godot")) { rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); + rename_common(input_map_renames, reg_container.input_map_regexes, lines); } else if (file_name.ends_with(".csproj")) { // TODO } else { @@ -2288,6 +2315,7 @@ int ProjectConverter3To4::validate_conversion() { } else if (file_name.ends_with("project.godot")) { changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); + changed_elements.append_array(check_for_rename_common(input_map_renames, reg_container.input_map_regexes, lines)); } else if (file_name.ends_with(".csproj")) { // TODO } else { @@ -2424,6 +2452,8 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { valid = valid && test_conversion_basic("audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db", project_settings_renames, reg_container.project_settings_regexes, "project setting"); + valid = valid && test_conversion_basic("\"device\":-1,\"alt\":false,\"shift\":false,\"control\":false,\"meta\":false,\"doubleclick\":false,\"scancode\":0,\"physical_scancode\":16777254,\"script\":null", "\"device\":-1,\"alt_pressed\":false,\"shift_pressed\":false,\"ctrl_pressed\":false,\"meta_pressed\":false,\"double_click\":false,\"keycode\":0,\"physical_keycode\":16777254,\"script\":null", input_map_renames, reg_container.input_map_regexes, "input map"); + valid = valid && test_conversion_basic("Transform", "Transform3D", builtin_types_renames, reg_container.builtin_types_regexes, "builtin type"); // Custom Renames. @@ -2812,6 +2842,7 @@ bool ProjectConverter3To4::test_array_names() { valid = valid && test_single_array(shaders_renames, true); valid = valid && test_single_array(gdscript_signals_renames); valid = valid && test_single_array(project_settings_renames); + valid = valid && test_single_array(input_map_renames); valid = valid && test_single_array(builtin_types_renames); valid = valid && test_single_array(color_renames); @@ -3880,11 +3911,33 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai if (line.contains("OS.set_window_title")) { line = line.replace("OS.set_window_title", "get_window().set_title"); } + + // get_tree().set_input_as_handled() -> get_viewport().set_input_as_handled() + if (line.contains("get_tree().set_input_as_handled()")) { + line = line.replace("get_tree().set_input_as_handled()", "get_viewport().set_input_as_handled()"); + } + + // Fix the simple case of using _unhandled_key_input + // func _unhandled_key_input(event: InputEventKey) -> _unhandled_key_input(event: InputEvent) + if (line.contains("_unhandled_key_input(event: InputEventKey)")) { + line = line.replace("_unhandled_key_input(event: InputEventKey)", "_unhandled_key_input(event: InputEvent)"); + } } void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer ®_container) { line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()"); + // GetTree().SetInputAsHandled() -> GetViewport().SetInputAsHandled() + if (line.contains("GetTree().SetInputAsHandled()")) { + line = line.replace("GetTree().SetInputAsHandled()", "GetViewport().SetInputAsHandled()"); + } + + // Fix the simple case of using _UnhandledKeyInput + // func _UnhandledKeyInput(InputEventKey @event) -> _UnhandledKeyInput(InputEvent @event) + if (line.contains("_UnhandledKeyInput(InputEventKey @event)")) { + line = line.replace("_UnhandledKeyInput(InputEventKey @event)", "_UnhandledKeyInput(InputEvent @event)"); + } + // -- Connect(,,,things) -> Connect(,Callable(,),things) Object if (line.contains("Connect(")) { int start = line.find("Connect("); diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index 5f6b5aa42f..061baaff7e 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -219,6 +219,4 @@ void unregister_editor_types() { if (EditorPaths::get_singleton()) { EditorPaths::free(); } - - EditorResourcePicker::clear_caches(); } diff --git a/main/main.cpp b/main/main.cpp index e5d2ea3922..b9cb755cbf 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2431,6 +2431,14 @@ bool Main::start() { ERR_FAIL_COND_V_MSG(da.is_null(), false, "Argument supplied to --doctool must be a valid directory path."); } +#ifndef MODULE_MONO_ENABLED + // Hack to define .NET-specific project settings even on non-.NET builds, + // so that we don't lose their descriptions and default values in DocTools. + // Default values should be synced with mono_gd/gd_mono.cpp. + GLOBAL_DEF("dotnet/project/assembly_name", ""); + GLOBAL_DEF("dotnet/project/solution_directory", ""); +#endif + Error err; DocTools doc; doc.generate(doc_base); diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml index 8246c96c15..1a102bd16f 100644 --- a/modules/gdscript/doc_classes/GDScript.xml +++ b/modules/gdscript/doc_classes/GDScript.xml @@ -11,12 +11,6 @@ <link title="GDScript documentation index">$DOCS_URL/tutorials/scripting/gdscript/index.html</link> </tutorials> <methods> - <method name="get_as_byte_code" qualifiers="const"> - <return type="PackedByteArray" /> - <description> - Returns byte code for the script source code. - </description> - </method> <method name="new" qualifiers="vararg"> <return type="Variant" /> <description> diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 28f478e9cd..ffe01eaa18 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1007,17 +1007,6 @@ void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const { void GDScript::_bind_methods() { ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &GDScript::_new, MethodInfo("new")); - - ClassDB::bind_method(D_METHOD("get_as_byte_code"), &GDScript::get_as_byte_code); -} - -Vector<uint8_t> GDScript::get_as_byte_code() const { - return Vector<uint8_t>(); -}; - -// TODO: Fully remove this. There's not this kind of "bytecode" anymore. -Error GDScript::load_byte_code(const String &p_path) { - return ERR_COMPILATION_FAILED; } void GDScript::set_path(const String &p_path, bool p_take_over) { @@ -2647,8 +2636,6 @@ Ref<Resource> ResourceFormatLoaderGDScript::load(const String &p_path, const Str Error err; Ref<GDScript> scr = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE); - // TODO: Reintroduce binary and encrypted scripts. - if (scr.is_null()) { // Don't fail loading because of parsing error. scr.instantiate(); @@ -2663,9 +2650,6 @@ Ref<Resource> ResourceFormatLoaderGDScript::load(const String &p_path, const Str void ResourceFormatLoaderGDScript::get_recognized_extensions(List<String> *p_extensions) const { p_extensions->push_back("gd"); - // TODO: Reintroduce binary and encrypted scripts. - // p_extensions->push_back("gdc"); - // p_extensions->push_back("gde"); } bool ResourceFormatLoaderGDScript::handles_type(const String &p_type) const { @@ -2674,8 +2658,7 @@ bool ResourceFormatLoaderGDScript::handles_type(const String &p_type) const { String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - // TODO: Reintroduce binary and encrypted scripts. - if (el == "gd" /*|| el == "gdc" || el == "gde"*/) { + if (el == "gd") { return "GDScript"; } return ""; diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index a53785a98d..71184ac2da 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -250,9 +250,6 @@ public: virtual void set_path(const String &p_path, bool p_take_over = false) override; String get_script_path() const; Error load_source_code(const String &p_path); - Error load_byte_code(const String &p_path); - - Vector<uint8_t> get_as_byte_code() const; bool get_property_default_value(const StringName &p_property, Variant &r_value) const override; diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index edb2e8117a..b9e6921034 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -107,6 +107,7 @@ void GDScriptTextDocument::didSave(const Variant &p_param) { } else { scr->reload(true); } + scr->update_exports(); ScriptEditor::get_singleton()->update_docs_from_script(scr); } } diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 33b5ae6942..b6feaadccf 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -71,21 +71,18 @@ class EditorExportGDScript : public EditorExportPlugin { public: virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override { - int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED; String script_key; const Ref<EditorExportPreset> &preset = get_export_preset(); if (preset.is_valid()) { - script_mode = preset->get_script_export_mode(); script_key = preset->get_script_encryption_key().to_lower(); } - if (!p_path.ends_with(".gd") || script_mode == EditorExportPreset::MODE_SCRIPT_TEXT) { + if (!p_path.ends_with(".gd")) { return; } - // TODO: Re-add compiled GDScript on export. return; } diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index bb1ad3d83b..587caf81bf 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -437,6 +437,14 @@ String EditorExportPlatformAndroid::get_project_name(const String &p_name) const String EditorExportPlatformAndroid::get_package_name(const String &p_package) const { String pname = p_package; + String name = get_valid_basename(); + pname = pname.replace("$genname", name); + return pname; +} + +// Returns the project name without invalid characters +// or the "noname" string if all characters are invalid. +String EditorExportPlatformAndroid::get_valid_basename() const { String basename = GLOBAL_GET("application/config/name"); basename = basename.to_lower(); @@ -452,13 +460,12 @@ String EditorExportPlatformAndroid::get_package_name(const String &p_package) co first = false; } } + if (name.is_empty()) { name = "noname"; } - pname = pname.replace("$genname", name); - - return pname; + return name; } String EditorExportPlatformAndroid::get_assets_directory(const Ref<EditorExportPreset> &p_preset, int p_export_format) const { @@ -466,7 +473,7 @@ String EditorExportPlatformAndroid::get_assets_directory(const Ref<EditorExportP } bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, String *r_error) const { - String pname = p_package; + String pname = get_package_name(p_package); if (pname.length() == 0) { if (r_error) { @@ -525,6 +532,24 @@ bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, return false; } + if (p_package.find("$genname") >= 0 && !is_project_name_valid()) { + if (r_error) { + *r_error = TTR("The project name does not meet the requirement for the package name format. Please explicitly specify the package name."); + } + return false; + } + + return true; +} + +bool EditorExportPlatformAndroid::is_project_name_valid() const { + // Get the original project name and convert to lowercase. + String basename = GLOBAL_GET("application/config/name"); + basename = basename.to_lower(); + // Check if there are invalid characters. + if (basename != get_valid_basename()) { + return false; + } return true; } @@ -2286,7 +2311,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit String pn = p_preset->get("package/unique_name"); String pn_err; - if (!is_package_name_valid(get_package_name(pn), &pn_err)) { + if (!is_package_name_valid(pn, &pn_err)) { valid = false; err += TTR("Invalid package name:") + " " + pn_err + "\n"; } diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index a6dfc9fcb3..bff769fcba 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -91,9 +91,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { String get_package_name(const String &p_package) const; + String get_valid_basename() const; + String get_assets_directory(const Ref<EditorExportPreset> &p_preset, int p_export_format) const; bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const; + bool is_project_name_valid() const; static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data); diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index f4d36f1a87..1830a7b39b 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -405,9 +405,9 @@ def configure(env: "Environment"): # Link those statically for portability if env["use_static_cpp"]: env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) - if env["use_llvm"]: + if env["use_llvm"] and platform.system() != "FreeBSD": env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a" else: - if env["use_llvm"]: + if env["use_llvm"] and platform.system() != "FreeBSD": env.Append(LIBS=["atomic"]) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 130c5f7b97..08299d9b98 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -210,6 +210,8 @@ void OS_Windows::initialize() { } else if (!dwrite2_init) { print_verbose("Unable to load IDWriteFactory2, automatic system font fallback is disabled."); } + + FileAccessWindows::initialize(); } void OS_Windows::delete_main_loop() { @@ -252,6 +254,8 @@ void OS_Windows::finalize() { } void OS_Windows::finalize_core() { + FileAccessWindows::finalize(); + timeEndPeriod(1); memdelete(process_map); diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 5eb76bdbb5..f80da6e9ab 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -175,6 +175,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i return; //does not exist because it was likely removed from the tree } + lock_callback(); locked = true; if (body_in) { @@ -224,6 +225,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } locked = false; + unlock_callback(); } void Area2D::_area_enter_tree(ObjectID p_id) { @@ -268,6 +270,8 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i if (!area_in && !E) { return; //likely removed from the tree } + + lock_callback(); locked = true; if (area_in) { @@ -317,6 +321,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } locked = false; + unlock_callback(); } void Area2D::_clear_monitoring() { diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index b2fee6ad82..caea753d99 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -94,10 +94,14 @@ void CollisionObject2D::_notification(int p_what) { bool disabled = !is_enabled(); if (!disabled || (disable_mode != DISABLE_MODE_REMOVE)) { - if (area) { - PhysicsServer2D::get_singleton()->area_set_space(rid, RID()); + if (callback_lock > 0) { + ERR_PRINT("Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead."); } else { - PhysicsServer2D::get_singleton()->body_set_space(rid, RID()); + if (area) { + PhysicsServer2D::get_singleton()->area_set_space(rid, RID()); + } else { + PhysicsServer2D::get_singleton()->body_set_space(rid, RID()); + } } } @@ -225,10 +229,14 @@ void CollisionObject2D::_apply_disabled() { switch (disable_mode) { case DISABLE_MODE_REMOVE: { if (is_inside_tree()) { - if (area) { - PhysicsServer2D::get_singleton()->area_set_space(rid, RID()); + if (callback_lock > 0) { + ERR_PRINT("Disabling a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Disable with call_deferred() instead."); } else { - PhysicsServer2D::get_singleton()->body_set_space(rid, RID()); + if (area) { + PhysicsServer2D::get_singleton()->area_set_space(rid, RID()); + } else { + PhysicsServer2D::get_singleton()->body_set_space(rid, RID()); + } } } } break; diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index d44e402e96..88429b145d 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -53,6 +53,7 @@ private: bool area = false; RID rid; + uint32_t callback_lock = 0; bool pickable = false; DisableMode disable_mode = DISABLE_MODE_REMOVE; @@ -83,6 +84,12 @@ private: void _apply_enabled(); protected: + _FORCE_INLINE_ void lock_callback() { callback_lock++; } + _FORCE_INLINE_ void unlock_callback() { + ERR_FAIL_COND(callback_lock == 0); + callback_lock--; + } + CollisionObject2D(RID p_rid, bool p_area); void _notification(int p_what); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 9fee99c6a7..1721bcde3b 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -434,6 +434,8 @@ struct _RigidBody2DInOut { }; void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) { + lock_callback(); + set_block_transform_notify(true); // don't want notify (would feedback loop) if (!freeze || freeze_mode != FREEZE_MODE_KINEMATIC) { set_global_transform(p_state->get_transform()); @@ -527,6 +529,8 @@ void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) { contact_monitor->locked = false; } + + unlock_callback(); } void RigidBody2D::_apply_body_mode() { diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index fa61ce5546..72f186c676 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -230,6 +230,7 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i return; //likely removed from the tree } + lock_callback(); locked = true; if (body_in) { @@ -279,6 +280,7 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i } locked = false; + unlock_callback(); } void Area3D::_clear_monitoring() { @@ -417,6 +419,7 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i return; //likely removed from the tree } + lock_callback(); locked = true; if (area_in) { @@ -466,6 +469,7 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i } locked = false; + unlock_callback(); } bool Area3D::is_monitoring() const { diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index c408b0714a..26ada1da5a 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -100,10 +100,14 @@ void CollisionObject3D::_notification(int p_what) { bool disabled = !is_enabled(); if (!disabled || (disable_mode != DISABLE_MODE_REMOVE)) { - if (area) { - PhysicsServer3D::get_singleton()->area_set_space(rid, RID()); + if (callback_lock > 0) { + ERR_PRINT("Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead."); } else { - PhysicsServer3D::get_singleton()->body_set_space(rid, RID()); + if (area) { + PhysicsServer3D::get_singleton()->area_set_space(rid, RID()); + } else { + PhysicsServer3D::get_singleton()->body_set_space(rid, RID()); + } } } @@ -223,10 +227,14 @@ void CollisionObject3D::_apply_disabled() { switch (disable_mode) { case DISABLE_MODE_REMOVE: { if (is_inside_tree()) { - if (area) { - PhysicsServer3D::get_singleton()->area_set_space(rid, RID()); + if (callback_lock > 0) { + ERR_PRINT("Disabling a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Disable with call_deferred() instead."); } else { - PhysicsServer3D::get_singleton()->body_set_space(rid, RID()); + if (area) { + PhysicsServer3D::get_singleton()->area_set_space(rid, RID()); + } else { + PhysicsServer3D::get_singleton()->body_set_space(rid, RID()); + } } } } break; diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h index 656b8c9bf1..ebcbb39e0d 100644 --- a/scene/3d/collision_object_3d.h +++ b/scene/3d/collision_object_3d.h @@ -52,6 +52,7 @@ private: bool area = false; RID rid; + uint32_t callback_lock = 0; DisableMode disable_mode = DISABLE_MODE_REMOVE; @@ -97,6 +98,12 @@ private: protected: CollisionObject3D(RID p_rid, bool p_area); + _FORCE_INLINE_ void lock_callback() { callback_lock++; } + _FORCE_INLINE_ void unlock_callback() { + ERR_FAIL_COND(callback_lock == 0); + callback_lock--; + } + void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index e9cc4e9479..fbcb1c8f2c 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -156,6 +156,10 @@ void Decal::_validate_property(PropertyInfo &p_property) const { if (!distance_fade_enabled && (p_property.name == "distance_fade_begin" || p_property.name == "distance_fade_length")) { p_property.usage = PROPERTY_USAGE_NO_EDITOR; } + + if (p_property.name == "sorting_offset") { + p_property.usage = PROPERTY_USAGE_DEFAULT; + } } PackedStringArray Decal::get_configuration_warnings() const { diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 46956b0a2e..106efbc596 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -484,6 +484,8 @@ struct _RigidBodyInOut { }; void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { + lock_callback(); + set_ignore_transform_notification(true); set_global_transform(p_state->get_transform()); @@ -578,6 +580,8 @@ void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { contact_monitor->locked = false; } + + unlock_callback(); } void RigidBody3D::_notification(int p_what) { diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 64fb0a7657..8026b12c2b 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -120,6 +120,12 @@ bool VisualInstance3D::is_sorting_use_aabb_center() const { return sorting_use_aabb_center; } +void VisualInstance3D::_validate_property(PropertyInfo &p_property) const { + if (p_property.name == "sorting_offset" || p_property.name == "sorting_use_aabb_center") { + p_property.usage = PROPERTY_USAGE_NONE; + } +} + void VisualInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance3D::set_base); ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance3D::get_base); @@ -437,6 +443,12 @@ PackedStringArray GeometryInstance3D::get_configuration_warnings() const { return warnings; } +void GeometryInstance3D::_validate_property(PropertyInfo &p_property) const { + if (p_property.name == "sorting_offset" || p_property.name == "sorting_use_aabb_center") { + p_property.usage = PROPERTY_USAGE_DEFAULT; + } +} + void GeometryInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override); ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override); diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index 190ed17753..ef0f7966e2 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -47,6 +47,7 @@ protected: void _notification(int p_what); static void _bind_methods(); + void _validate_property(PropertyInfo &p_property) const; GDVIRTUAL0RC(AABB, _get_aabb) public: @@ -140,6 +141,7 @@ 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; + void _validate_property(PropertyInfo &p_property) const; static void _bind_methods(); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index e074927b9b..a00b1d8ee1 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -901,7 +901,7 @@ void AnimationNodeTransition::_bind_methods() { ClassDB::bind_method(D_METHOD("set_reset", "reset"), &AnimationNodeTransition::set_reset); ClassDB::bind_method(D_METHOD("is_reset"), &AnimationNodeTransition::is_reset); - ADD_PROPERTY(PropertyInfo(Variant::INT, "enabled_inputs", PROPERTY_HINT_RANGE, "0,64,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_enabled_inputs", "get_enabled_inputs"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "enabled_inputs", PROPERTY_HINT_RANGE, "0,31,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_enabled_inputs", "get_enabled_inputs"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "xfade_time", PROPERTY_HINT_RANGE, "0,120,0.01,suffix:s"), "set_xfade_time", "get_xfade_time"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "xfade_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_xfade_curve", "get_xfade_curve"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset"), "set_reset", "is_reset"); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index d0326290ac..472299b135 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -385,6 +385,7 @@ void BaseButton::shortcut_input(const Ref<InputEvent> &p_event) { if (shortcut_feedback) { if (shortcut_feedback_timer == nullptr) { shortcut_feedback_timer = memnew(Timer); + shortcut_feedback_timer->set_one_shot(true); add_child(shortcut_feedback_timer); shortcut_feedback_timer->set_wait_time(GLOBAL_GET("gui/timers/button_shortcut_feedback_highlight_time")); shortcut_feedback_timer->connect("timeout", callable_mp(this, &BaseButton::_shortcut_feedback_timeout)); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index eb57ccfef1..def91c424c 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -279,7 +279,10 @@ void Node::_propagate_exit_tree() { //block while removing children #ifdef DEBUG_ENABLED - SceneDebugger::remove_from_cache(data.scene_file_path, this); + if (!data.scene_file_path.is_empty()) { + // Only remove if file path is set (optimization). + SceneDebugger::remove_from_cache(data.scene_file_path, this); + } #endif data.blocked++; @@ -305,7 +308,6 @@ void Node::_propagate_exit_tree() { } // exit groups - for (KeyValue<StringName, GroupData> &E : data.grouped) { data.tree->remove_from_group(E.key, this); E.value.group = nullptr; @@ -1166,7 +1168,7 @@ void Node::add_sibling(Node *p_sibling, bool p_force_readable_name) { void Node::remove_child(Node *p_child) { ERR_FAIL_NULL(p_child); - ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, `remove_child()` failed. Consider using `remove_child.call_deferred(child)` instead."); + ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy adding/removing children, `remove_child()` can't be called at this time. Consider using `remove_child.call_deferred(child)` instead."); int child_count = data.children.size(); Node **children = data.children.ptrw(); @@ -1197,11 +1199,13 @@ void Node::remove_child(Node *p_child) { data.internal_children_back--; } + data.blocked++; p_child->_set_tree(nullptr); //} remove_child_notify(p_child); p_child->notification(NOTIFICATION_UNPARENTED); + data.blocked--; data.children.remove_at(idx); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 624f2e8896..e78d9b924d 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -1034,7 +1034,7 @@ void VisualShaderNodeTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeTexture::set_texture_type); ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeTexture::get_texture_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth,SamplerPort,ScreenNormal,Roughness"), "set_source", "get_source"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth,SamplerPort,Normal3D,Roughness"), "set_source", "get_source"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normal Map"), "set_texture_type", "get_texture_type"); @@ -7694,12 +7694,15 @@ bool VisualShaderNodeProximityFade::has_output_port_preview(int p_port) const { return false; } +String VisualShaderNodeProximityFade::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { + return "uniform sampler2D " + make_unique_id(p_type, p_id, "depth_tex") + " : hint_depth_texture;\n"; +} + String VisualShaderNodeProximityFade::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; code += " {\n"; - String proximity_fade_distance = vformat("%s", p_input_vars[0]); - code += " float __depth_tex = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).r;\n"; + code += " float __depth_tex = texture(" + make_unique_id(p_type, p_id, "depth_tex") + ", SCREEN_UV).r;\n"; if (!RenderingServer::get_singleton()->is_low_end()) { code += " vec4 __depth_world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, __depth_tex, 1.0);\n"; } else { diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 8d0f88d83a..e3b101cf84 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -2849,6 +2849,7 @@ public: virtual String get_output_port_name(int p_port) const override; virtual bool has_output_port_preview(int p_port) const override; + virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override; virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; VisualShaderNodeProximityFade(); diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h index 62e1eb326d..fd36e7ac10 100644 --- a/servers/rendering/dummy/storage/texture_storage.h +++ b/servers/rendering/dummy/storage/texture_storage.h @@ -154,6 +154,7 @@ public: virtual RID decal_instance_create(RID p_decal) override { return RID(); } virtual void decal_instance_free(RID p_decal_instance) override {} virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override {} + virtual void decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) override {} /* RENDER TARGET */ diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 93c741fd34..3fd8d55a71 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -1480,7 +1480,7 @@ void RenderForwardClustered::_pre_opaque_render(RenderDataRD *p_render_data, boo uint32_t directional_light_count = 0; uint32_t positional_light_count = 0; light_storage->update_light_buffers(p_render_data, *p_render_data->lights, p_render_data->scene_data->cam_transform, p_render_data->shadow_atlas, using_shadows, directional_light_count, positional_light_count, p_render_data->directional_light_soft_shadows); - texture_storage->update_decal_buffer(*p_render_data->decals, p_render_data->scene_data->cam_transform.affine_inverse()); + texture_storage->update_decal_buffer(*p_render_data->decals, p_render_data->scene_data->cam_transform); p_render_data->directional_light_count = directional_light_count; diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index 816248567b..5d4e3c1ac1 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -632,7 +632,7 @@ void RenderForwardMobile::_pre_opaque_render(RenderDataRD *p_render_data) { uint32_t directional_light_count = 0; uint32_t positional_light_count = 0; light_storage->update_light_buffers(p_render_data, *p_render_data->lights, p_render_data->scene_data->cam_transform, p_render_data->shadow_atlas, using_shadows, directional_light_count, positional_light_count, p_render_data->directional_light_soft_shadows); - texture_storage->update_decal_buffer(*p_render_data->decals, p_render_data->scene_data->cam_transform.affine_inverse()); + texture_storage->update_decal_buffer(*p_render_data->decals, p_render_data->scene_data->cam_transform); p_render_data->directional_light_count = directional_light_count; } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 462b925134..638fe44266 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -455,7 +455,7 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend light_count++; - if (light_count == MAX_LIGHTS_PER_ITEM) { + if (light_count == MAX_LIGHTS_PER_ITEM - 1) { break; } } diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp index 673fc25595..33e35a7a64 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp @@ -568,8 +568,6 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged r_directional_light_count = 0; r_positional_light_count = 0; - Plane camera_plane(-p_camera_transform.basis.get_column(Vector3::AXIS_Z).normalized(), p_camera_transform.origin); - omni_light_count = 0; spot_light_count = 0; @@ -720,7 +718,7 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged } Transform3D light_transform = light_instance->transform; - const real_t distance = camera_plane.distance_to(light_transform.origin); + const real_t distance = p_camera_transform.origin.distance_to(light_transform.origin); if (light->distance_fade) { const float fade_begin = light->distance_fade_begin; @@ -745,7 +743,7 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged } Transform3D light_transform = light_instance->transform; - const real_t distance = camera_plane.distance_to(light_transform.origin); + const real_t distance = p_camera_transform.origin.distance_to(light_transform.origin); if (light->distance_fade) { const float fade_begin = light->distance_fade_begin; @@ -787,6 +785,7 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged RS::LightType type = (i < omni_light_count) ? RS::LIGHT_OMNI : RS::LIGHT_SPOT; LightInstance *light_instance = (i < omni_light_count) ? omni_light_sort[index].light_instance : spot_light_sort[index].light_instance; Light *light = (i < omni_light_count) ? omni_light_sort[index].light : spot_light_sort[index].light; + real_t distance = (i < omni_light_count) ? omni_light_sort[index].depth : spot_light_sort[index].depth; if (using_forward_ids) { forward_id_storage->map_forward_id(type == RS::LIGHT_OMNI ? RendererRD::FORWARD_ID_TYPE_OMNI_LIGHT : RendererRD::FORWARD_ID_TYPE_SPOT_LIGHT, light_instance->forward_id, index); @@ -803,7 +802,6 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged float fade_begin = 0.0; float fade_shadow = 0.0; float fade_length = 0.0; - real_t distance = 0.0; float fade = 1.0; float shadow_opacity_fade = 1.0; @@ -811,7 +809,6 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged fade_begin = light->distance_fade_begin; fade_shadow = light->distance_fade_shadow; fade_length = light->distance_fade_length; - distance = camera_plane.distance_to(light_transform.origin); // Use `smoothstep()` to make opacity changes more gradual and less noticeable to the player. if (distance > fade_begin) { diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 06fda8fa9e..e8d9f486bb 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -2206,6 +2206,12 @@ void TextureStorage::decal_instance_set_transform(RID p_decal_instance, const Tr di->transform = p_transform; } +void TextureStorage::decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) { + DecalInstance *di = decal_instance_owner.get_or_null(p_decal_instance); + ERR_FAIL_COND(!di); + di->sorting_offset = p_sorting_offset; +} + /* DECAL DATA API */ void TextureStorage::free_decal_data() { @@ -2233,7 +2239,7 @@ void TextureStorage::set_max_decals(const uint32_t p_max_decals) { decal_buffer = RD::get_singleton()->storage_buffer_create(decal_buffer_size); } -void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const Transform3D &p_camera_inverse_xform) { +void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const Transform3D &p_camera_xform) { ForwardIDStorage *forward_id_storage = ForwardIDStorage::get_singleton(); Transform3D uv_xform; @@ -2257,7 +2263,7 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const Transform3D xform = decal_instance->transform; - real_t distance = -p_camera_inverse_xform.xform(xform.origin).z; + real_t distance = p_camera_xform.origin.distance_to(xform.origin); if (decal->distance_fade) { float fade_begin = decal->distance_fade_begin; @@ -2272,7 +2278,7 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const decal_sort[decal_count].decal_instance = decal_instance; decal_sort[decal_count].decal = decal; - decal_sort[decal_count].depth = distance; + decal_sort[decal_count].depth = distance - decal_instance->sorting_offset; decal_count++; } @@ -2292,11 +2298,10 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const decal_instance->cull_mask = decal->cull_mask; - Transform3D xform = decal_instance->transform; float fade = 1.0; if (decal->distance_fade) { - const real_t distance = -p_camera_inverse_xform.xform(xform.origin).z; + const real_t distance = decal_sort[i].depth + decal_instance->sorting_offset; const float fade_begin = decal->distance_fade_begin; const float fade_length = decal->distance_fade_length; @@ -2312,11 +2317,16 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const Transform3D scale_xform; scale_xform.basis.scale(decal_extents); - Transform3D to_decal_xform = (p_camera_inverse_xform * xform * scale_xform * uv_xform).affine_inverse(); + + Transform3D xform = decal_instance->transform; + + Transform3D camera_inverse_xform = p_camera_xform.affine_inverse(); + + Transform3D to_decal_xform = (camera_inverse_xform * xform * scale_xform * uv_xform).affine_inverse(); MaterialStorage::store_transform(to_decal_xform, dd.xform); Vector3 normal = xform.basis.get_column(Vector3::AXIS_Y).normalized(); - normal = p_camera_inverse_xform.basis.xform(normal); //camera is normalized, so fine + normal = camera_inverse_xform.basis.xform(normal); //camera is normalized, so fine dd.normal[0] = normal.x; dd.normal[1] = normal.y; @@ -2350,7 +2360,7 @@ void TextureStorage::update_decal_buffer(const PagedArray<RID> &p_decals, const dd.normal_rect[2] = rect.size.x; dd.normal_rect[3] = rect.size.y; - Basis normal_xform = p_camera_inverse_xform.basis * xform.basis.orthonormalized(); + Basis normal_xform = camera_inverse_xform.basis * xform.basis.orthonormalized(); MaterialStorage::store_basis_3x4(normal_xform, dd.normal_xform); } else { dd.normal_rect[0] = 0; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index 1558342c3b..ea0df0b459 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -258,6 +258,7 @@ private: struct DecalInstance { RID decal; Transform3D transform; + float sorting_offset = 0.0; uint32_t cull_mask = 0; RendererRD::ForwardID forward_id = -1; }; @@ -646,6 +647,7 @@ public: virtual RID decal_instance_create(RID p_decal) override; virtual void decal_instance_free(RID p_decal_instance) override; virtual void decal_instance_set_transform(RID p_decal_instance, const Transform3D &p_transform) override; + virtual void decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) override; _FORCE_INLINE_ RID decal_instance_get_base(RID p_decal_instance) const { DecalInstance *di = decal_instance_owner.get_or_null(p_decal_instance); @@ -677,7 +679,7 @@ public: void free_decal_data(); void set_max_decals(const uint32_t p_max_decals); RID get_decal_buffer() { return decal_buffer; } - void update_decal_buffer(const PagedArray<RID> &p_decals, const Transform3D &p_camera_inverse_xform); + void update_decal_buffer(const PagedArray<RID> &p_decals, const Transform3D &p_camera_xform); /* RENDER TARGET API */ diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 218bb7b736..de417082f5 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -694,6 +694,7 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) { instance->base_data = decal; decal->instance = RSG::texture_storage->decal_instance_create(p_base); + RSG::texture_storage->decal_instance_set_sorting_offset(decal->instance, instance->sorting_offset); } break; case RS::INSTANCE_LIGHTMAP: { InstanceLightmapData *lightmap_data = memnew(InstanceLightmapData); @@ -871,6 +872,9 @@ void RendererSceneCull::instance_set_pivot_data(RID p_instance, float p_sorting_ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(instance->base_data); ERR_FAIL_NULL(geom->geometry_instance); geom->geometry_instance->set_pivot_data(p_sorting_offset, p_use_aabb_center); + } else if (instance->base_type == RS::INSTANCE_DECAL && instance->base_data) { + InstanceDecalData *decal = static_cast<InstanceDecalData *>(instance->base_data); + RSG::texture_storage->decal_instance_set_sorting_offset(decal->instance, instance->sorting_offset); } } @@ -2824,7 +2828,9 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); ERR_FAIL_NULL(geom->geometry_instance); + cull_data.cull->lock.lock(); geom->geometry_instance->set_softshadow_projector_pairing(geom->softshadow_count > 0, geom->projector_count > 0); + cull_data.cull->lock.unlock(); idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY); } @@ -2891,7 +2897,9 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul sh[j] = sh[j].lerp(target_sh[j], MIN(1.0, lightmap_probe_update_speed)); } ERR_FAIL_NULL(geom->geometry_instance); + cull_data.cull->lock.lock(); geom->geometry_instance->set_lightmap_capture(sh); + cull_data.cull->lock.unlock(); idata.instance->last_frame_pass = frame_number; } diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 5ecc38a63b..ba7ffda00a 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -5402,7 +5402,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (identifier == "SCREEN_TEXTURE" || identifier == "DEPTH_TEXTURE" || identifier == "NORMAL_ROUGHNESS_TEXTURE") { String name = String(identifier); String name_lower = name.to_lower(); - _set_error(vformat(RTR("%s has been removed in favor of using hint_%s with a uniform.\nTo continue with minimal code changes add 'uniform sampler2D %s : hint_%s, filter_linear_mipmaps;' near the top of your shader."), name, name_lower, name, name_lower)); + _set_error(vformat(RTR("%s has been removed in favor of using hint_%s with a uniform.\nTo continue with minimal code changes add 'uniform sampler2D %s : hint_%s, filter_linear_mipmap;' near the top of your shader."), name, name_lower, name, name_lower)); return nullptr; } _set_error(vformat(RTR("Unknown identifier in expression: '%s'."), String(identifier))); @@ -8697,14 +8697,17 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f case TK_HINT_SCREEN_TEXTURE: { new_hint = ShaderNode::Uniform::HINT_SCREEN_TEXTURE; --texture_uniforms; + --texture_binding; } break; case TK_HINT_NORMAL_ROUGHNESS_TEXTURE: { new_hint = ShaderNode::Uniform::HINT_NORMAL_ROUGHNESS_TEXTURE; --texture_uniforms; + --texture_binding; } break; case TK_HINT_DEPTH_TEXTURE: { new_hint = ShaderNode::Uniform::HINT_DEPTH_TEXTURE; --texture_uniforms; + --texture_binding; } break; case TK_FILTER_NEAREST: { new_filter = FILTER_NEAREST; diff --git a/servers/rendering/storage/texture_storage.h b/servers/rendering/storage/texture_storage.h index 92149b0064..4c4a84d04e 100644 --- a/servers/rendering/storage/texture_storage.h +++ b/servers/rendering/storage/texture_storage.h @@ -127,6 +127,7 @@ public: virtual RID decal_instance_create(RID p_decal) = 0; virtual void decal_instance_free(RID p_decal_instance) = 0; virtual void decal_instance_set_transform(RID p_decal_instance, const Transform3D &p_transform) = 0; + virtual void decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) = 0; /* RENDER TARGET */ diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 3d39b4f2cc..675db63b9a 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2963,9 +2963,9 @@ void RenderingServer::init() { GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_depth", PROPERTY_HINT_RANGE, "16,512,1"), 64); GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/use_filter", PROPERTY_HINT_ENUM, "No (Faster),Yes (Higher Quality)"), 1); - GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/update_iterations_per_frame", PROPERTY_HINT_RANGE, "0,1024,1"), 10); - GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/threaded_cull_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 1000); - GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/limits/forward_renderer/threaded_render_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 500); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/update_iterations_per_frame", PROPERTY_HINT_RANGE, "0,1024,1"), 10); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/threaded_cull_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 1000); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/forward_renderer/threaded_render_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 500); GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1"), 512); |