From 507fcf2a8265d39ab292e22cdf820ffa3c82bded Mon Sep 17 00:00:00 2001 From: kleonc <9283098+kleonc@users.noreply.github.com> Date: Sat, 22 May 2021 11:44:34 +0200 Subject: [PATCH 01/30] Astar::get_available_point_id Start from 0 (cherry picked from commit 17324db4caf61a8bf665d7122ca67da2a2d91043) --- core/math/a_star.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index abcf63ac1d0..7949e1cc07b 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -35,18 +35,12 @@ #include "scene/scene_string_names.h" int AStar::get_available_point_id() const { - if (points.empty()) { - return 1; - } - - // calculate our new next available point id if bigger than before or next id already contained in set of points. if (points.has(last_free_id)) { - int cur_new_id = last_free_id; + int cur_new_id = last_free_id + 1; while (points.has(cur_new_id)) { cur_new_id++; } - int &non_const = const_cast(last_free_id); - non_const = cur_new_id; + const_cast(last_free_id) = cur_new_id; } return last_free_id; From bcd3c9a285e523efd47a6681b66d3467d18c27c4 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 18 Jul 2021 10:51:03 +0200 Subject: [PATCH 02/30] Improve the 2D editor ruler display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use the ° symbol instead of "deg" to reduce clutter. - Round the displayed lengths to only one decimal instead of two to further reduce clutter. - Don't make the `px` suffix localizable, as it isn't localizable anywhere else in the editor. (cherry picked from commit 026aea681dc032c9846836d9f3d1113e6227f76b) --- editor/plugins/canvas_item_editor_plugin.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 5af6e5c64cc..cf6734ab9db 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3102,7 +3102,7 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 text_pos = (begin + end) / 2 - Vector2(text_width / 2, text_height / 2); text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5); text_pos.y = CLAMP(text_pos.y, text_height * 1.5, viewport->get_rect().size.y - text_height * 1.5); - viewport->draw_string(font, text_pos, vformat("%.2f px", length_vector.length()), font_color); + viewport->draw_string(font, text_pos, vformat("%.1f px", length_vector.length()), font_color); if (draw_secondary_lines) { const float horizontal_angle_rad = atan2(length_vector.y, length_vector.x); @@ -3112,16 +3112,16 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 text_pos2 = text_pos; text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2); - viewport->draw_string(font, text_pos2, vformat("%.2f px", length_vector.y), font_secondary_color); + viewport->draw_string(font, text_pos2, vformat("%.1f px", length_vector.y), font_secondary_color); Point2 v_angle_text_pos = Point2(); v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5); - viewport->draw_string(font, v_angle_text_pos, vformat("%d deg", vertical_angle), font_secondary_color); + viewport->draw_string(font, v_angle_text_pos, vformat(String::utf8("%d°"), vertical_angle), font_secondary_color); text_pos2 = text_pos; text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2); - viewport->draw_string(font, text_pos2, vformat("%.2f px", length_vector.x), font_secondary_color); + viewport->draw_string(font, text_pos2, vformat("%.1f px", length_vector.x), font_secondary_color); Point2 h_angle_text_pos = Point2(); h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); @@ -3138,7 +3138,7 @@ void CanvasItemEditor::_draw_ruler_tool() { h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height)); } } - viewport->draw_string(font, h_angle_text_pos, vformat("%d deg", horizontal_angle), font_secondary_color); + viewport->draw_string(font, h_angle_text_pos, vformat(String::utf8("%d°"), horizontal_angle), font_secondary_color); // Angle arcs int arc_point_count = 8; From bea67d77635b3e1226ef3c50f7a084562464af20 Mon Sep 17 00:00:00 2001 From: vitika9 Date: Tue, 27 Jul 2021 16:29:30 +0530 Subject: [PATCH 03/30] Fixed Camera2D's reset_smoothing() does not work as described (cherry picked from commit 22eaec689513827a1a9cf22d1c016324762f6af5) --- scene/2d/camera_2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index a0f4b7c2ea5..c87ebbcc736 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -472,8 +472,8 @@ void Camera2D::force_update_scroll() { } void Camera2D::reset_smoothing() { - smoothed_camera_pos = camera_pos; _update_scroll(); + smoothed_camera_pos = camera_pos; } void Camera2D::align() { From 1da4e9e608728bca771964e23d0a72253dcb981c Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Thu, 29 Jul 2021 11:05:11 +0800 Subject: [PATCH 04/30] Hide open doc button when not inspecting anything (cherry picked from commit 80e4c8626d1ff648cf8ed1263cb24954f9fc1ccf) --- editor/inspector_dock.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 903da35f6a7..496e1febf5f 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -414,6 +414,7 @@ void InspectorDock::update(Object *p_object) { current = p_object; if (!p_object) { + open_docs_button->set_disabled(true); object_menu->set_disabled(true); warning->hide(); search->set_editable(false); @@ -429,7 +430,7 @@ void InspectorDock::update(Object *p_object) { editor_path->enable_path(); resource_save_button->set_disabled(!is_resource); - open_docs_button->set_visible(is_resource || is_node); + open_docs_button->set_disabled(!is_resource && !is_node); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_COPY), !is_resource); @@ -570,7 +571,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { open_docs_button = memnew(Button); open_docs_button->set_flat(true); - open_docs_button->set_visible(false); + open_docs_button->set_disabled(true); open_docs_button->set_tooltip(TTR("Open documentation for this object.")); open_docs_button->set_icon(get_icon("HelpSearch", "EditorIcons")); open_docs_button->set_shortcut(ED_SHORTCUT("property_editor/open_help", TTR("Open Documentation"))); From ecb973ab0266b3a4e1c902f30b011d9d6380edd7 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Tue, 27 Jul 2021 23:16:10 +0200 Subject: [PATCH 05/30] Use `allowEmpty` parameter in Split (cherry picked from commit b7a66a820b88002e734a8e7e7c31992cb7d37fdd) --- .../mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index bb4cc1a4ef9..34da29bdf50 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -1132,7 +1132,7 @@ namespace Godot /// public static string[] Split(this string instance, string divisor, bool allowEmpty = true) { - return instance.Split(new[] { divisor }, StringSplitOptions.RemoveEmptyEntries); + return instance.Split(new[] { divisor }, allowEmpty ? StringSplitOptions.None : StringSplitOptions.RemoveEmptyEntries); } /// From a0d47033f71630e080dbd835694abdac1be5a6b4 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Thu, 29 Jul 2021 21:51:07 +0800 Subject: [PATCH 06/30] Remove colon from column titles (cherry picked from commit f9aad98d36c9c26edd518bc87bb382ee09904e19) --- editor/editor_plugin_settings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index cf40b2cfcc7..371f25fdc6c 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -210,11 +210,11 @@ EditorPluginSettings::EditorPluginSettings() { plugin_list->set_v_size_flags(SIZE_EXPAND_FILL); plugin_list->set_columns(5); plugin_list->set_column_titles_visible(true); - plugin_list->set_column_title(0, TTR("Name:")); - plugin_list->set_column_title(1, TTR("Version:")); - plugin_list->set_column_title(2, TTR("Author:")); - plugin_list->set_column_title(3, TTR("Status:")); - plugin_list->set_column_title(4, TTR("Edit:")); + plugin_list->set_column_title(0, TTR("Name")); + plugin_list->set_column_title(1, TTR("Version")); + plugin_list->set_column_title(2, TTR("Author")); + plugin_list->set_column_title(3, TTR("Status")); + plugin_list->set_column_title(4, TTR("Edit")); plugin_list->set_column_expand(0, true); plugin_list->set_column_expand(1, false); plugin_list->set_column_expand(2, false); From e71640af2f72889cbb34acec2c30c7f02208b9d6 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Thu, 29 Jul 2021 11:34:34 -0300 Subject: [PATCH 07/30] Make some small tweaks to the MIME info (cherry picked from commit 0218616747387b5c63bece8a64c87323d1bd704f) --- misc/dist/linux/org.godotengine.Godot.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/misc/dist/linux/org.godotengine.Godot.xml b/misc/dist/linux/org.godotengine.Godot.xml index e51179cd617..989db6afaa1 100644 --- a/misc/dist/linux/org.godotengine.Godot.xml +++ b/misc/dist/linux/org.godotengine.Godot.xml @@ -2,20 +2,20 @@ Godot Engine project - - + + Godot Engine resource - + Godot Engine scene - + @@ -23,13 +23,15 @@ Godot Engine shader - + + GDScript script - + + From e74ee7294e01677e1ada828340ee43333a32cfb5 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Thu, 29 Jul 2021 19:18:24 -0300 Subject: [PATCH 08/30] Properly tag project files as a subclass of plain text in the MIME info (cherry picked from commit a47e48987d86ba545506fb29ed34445275da8533) --- misc/dist/linux/org.godotengine.Godot.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/dist/linux/org.godotengine.Godot.xml b/misc/dist/linux/org.godotengine.Godot.xml index 989db6afaa1..d4452018c42 100644 --- a/misc/dist/linux/org.godotengine.Godot.xml +++ b/misc/dist/linux/org.godotengine.Godot.xml @@ -2,6 +2,7 @@ Godot Engine project + From 42ad0917389c42c6ceddeaead05e77e4a3a052f4 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Fri, 21 May 2021 10:47:24 -0700 Subject: [PATCH 09/30] Make curve interpolate crash less. (cherry picked from commit d67c5afa95e3610e5c3db1c6a9850809eead3eb0) --- modules/gltf/gltf_document.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 6594bba65e8..a64bfd676c1 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5644,6 +5644,8 @@ struct EditorSceneImporterGLTFInterpolate { template T GLTFDocument::_interpolate_track(const Vector &p_times, const Vector &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { + ERR_FAIL_COND_V(!p_values.size(), T()); + ERR_FAIL_COND_V(p_times.size() != p_values.size(), p_values[0]); //could use binary search, worth it? int idx = -1; for (int i = 0; i < p_times.size(); i++) { From 6ba37005d120a4e484c75be0c6006262477c3f97 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Thu, 29 Jul 2021 22:56:19 -0700 Subject: [PATCH 10/30] In glTF2 animations, log spam less when running. (cherry picked from commit 882f7d9bdf0e26cc6e09a7d7b0c699a318baa1c1) --- modules/gltf/gltf_document.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index a64bfd676c1..7b5d9308432 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5645,7 +5645,10 @@ struct EditorSceneImporterGLTFInterpolate { template T GLTFDocument::_interpolate_track(const Vector &p_times, const Vector &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { ERR_FAIL_COND_V(!p_values.size(), T()); - ERR_FAIL_COND_V(p_times.size() != p_values.size(), p_values[0]); + if (p_times.size() != p_values.size()) { + ERR_PRINT_ONCE("The interpolated values are not corresponding to its times."); + return p_values[0]; + } //could use binary search, worth it? int idx = -1; for (int i = 0; i < p_times.size(); i++) { From 8f592d50c3d87692bac26ed90fd18f0695d406f0 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Thu, 29 Jul 2021 23:09:17 -0700 Subject: [PATCH 11/30] glTF2 fallback load PNG and JPG (cherry picked from commit ddff1c10c3184efbb7ed4bd3669edcaad82fccef) --- modules/gltf/gltf_document.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7b5d9308432..60b5c77244c 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -3086,24 +3086,31 @@ Error GLTFDocument::_parse_images(Ref state, const String &p_base_pat Ref img; + // First we honor the mime types if they were defined. if (mimetype == "image/png") { // Load buffer as PNG. ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); img = Image::_png_mem_loader_func(data_ptr, data_size); } else if (mimetype == "image/jpeg") { // Loader buffer as JPEG. ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); img = Image::_jpg_mem_loader_func(data_ptr, data_size); - } else { - // We can land here if we got an URI with base64-encoded data with application/* MIME type, - // and the optional mimeType property was not defined to tell us how to handle this data (or was invalid). - // So let's try PNG first, then JPEG. - ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); - img = Image::_png_mem_loader_func(data_ptr, data_size); - if (img.is_null()) { - ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); - img = Image::_jpg_mem_loader_func(data_ptr, data_size); - } } + // If we didn't pass the above tests, we attempt loading as PNG and then + // JPEG directly. + // This covers URIs with base64-encoded data with application/* type but + // no optional mimeType property, or bufferViews with a bogus mimeType + // (e.g. `image/jpeg` but the data is actually PNG). + // That's not *exactly* what the spec mandates but this lets us be + // lenient with bogus glb files which do exist in production. + if (img.is_null()) { // Try PNG first. + ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); + img = Image::_png_mem_loader_func(data_ptr, data_size); + } + if (img.is_null()) { // And then JPEG. + ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); + img = Image::_jpg_mem_loader_func(data_ptr, data_size); + } + // Now we've done our best, fix your scenes. if (img.is_null()) { ERR_PRINT(vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype)); state->images.push_back(Ref()); From ccbd810934a6c8667ca71ef788d084a4ac37a6e0 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 30 Jul 2021 15:43:01 +0200 Subject: [PATCH 12/30] [Net] Fix Marshalls infinite recursion crash. Variants like dictionaries and arrays can have cyclic references, which caused `encode_variant` to run an infinite recursion. Instead of keeping a stack and looking for cyclic references which would make serialization slower, this commit adds a `MAX_RECURSION_DEPTH` constant to Variant, and have `encode_variant` keep track of the current recursion depth, bailing when it's too high since this likely means a cyclic reference has been encountered. (cherry picked from commit 324636473aa65165caeee29e9b70e2d8c21fcb96) --- core/io/marshalls.cpp | 18 ++++++++++-------- core/io/marshalls.h | 2 +- core/variant.h | 5 +++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 59fea4fba65..7c6bd718694 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -763,7 +763,8 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) { } } -Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects) { +Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects, int p_depth) { + ERR_FAIL_COND_V_MSG(p_depth > Variant::MAX_RECURSION_DEPTH, ERR_OUT_OF_MEMORY, "Potential inifite recursion detected. Bailing."); uint8_t *buf = r_buffer; r_len = 0; @@ -1076,10 +1077,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo _encode_string(E->get().name, buf, r_len); int len; - Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects); - if (err) { - return err; - } + Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { @@ -1130,13 +1129,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo */ Variant *v = d.getptr(E->get()); int len; - encode_variant(v ? E->get() : Variant("[Deleted Object]"), buf, len, p_full_objects); + Error err = encode_variant(v ? E->get() : Variant("[Deleted Object]"), buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { buf += len; } - encode_variant(v ? *v : Variant(), buf, len, p_full_objects); + err = encode_variant(v ? *v : Variant(), buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { @@ -1157,7 +1158,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo for (int i = 0; i < v.size(); i++) { int len; - encode_variant(v.get(i), buf, len, p_full_objects); + Error err = encode_variant(v.get(i), buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { diff --git a/core/io/marshalls.h b/core/io/marshalls.h index f7935729bf7..c52616affdb 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -181,6 +181,6 @@ public: }; Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false); -Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false); +Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false, int p_depth = 0); #endif diff --git a/core/variant.h b/core/variant.h index 8db69886b07..b53288733db 100644 --- a/core/variant.h +++ b/core/variant.h @@ -136,6 +136,11 @@ public: }; + enum { + // Maximum recursion depth allowed when serializing variants. + MAX_RECURSION_DEPTH = 1024, + }; + private: friend struct _VariantCall; // Variant takes 20 bytes when real_t is float, and 36 if double From f4208ad1e8bdf4eee09780cc5ea84977d615fdd1 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sat, 31 Jul 2021 02:25:05 +0800 Subject: [PATCH 13/30] Do nothing when dragging CSGBox handle perpendicular to the camera (cherry picked from commit 0f1e107ede5085aff017e8069697463598c5b512) --- modules/csg/csg_gizmos.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 4b17b17f60d..f70abb2265d 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -139,6 +139,12 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx]; + + if (Math::is_nan(d)) { + // The handle is perpendicular to the camera. + return; + } + if (SpatialEditor::get_singleton()->is_snap_enabled()) { d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); } From 61d153a1fab21a1116a4cfd7b04fcdd48af23272 Mon Sep 17 00:00:00 2001 From: Nicholas Huelin <62965063+SirQuartz@users.noreply.github.com> Date: Fri, 30 Jul 2021 15:10:05 -0400 Subject: [PATCH 14/30] Make "Find in Files" searches ignore directories with `.gdignore` files in them This pull request fixes an issue where searches using the "Find in Files" function would include folders with `.gdignore` files in them. The editor is supposed to ignore directories with these files in them altogether. (cherry picked from commit 658b152bd8f546dfb0fe54d4dce49d9e5f87ce8c) --- editor/find_in_files.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 606f210ce3b..22d4cf04504 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -233,6 +233,11 @@ void FindInFiles::_scan_dir(String path, PoolStringArray &out_folders) { break; } + // If there is a .gdignore file in the directory, don't bother searching it + if (file == ".gdignore") { + break; + } + // Ignore special dirs (such as .git and .import) if (file == "." || file == ".." || file.begins_with(".")) { continue; From 69c194736dd8726a107984aaaea4c1c42485a06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 30 Jul 2021 23:22:00 +0200 Subject: [PATCH 15/30] VariantParser: Fix uninitialized ResourceParser funcs They could cause a segfault when parsing values with ID "Resource" as apparently we never set a valid `func` for it. Fixes crash part of #42115. (cherry picked from commit f3aaa713d9296bae68a6db91157a2063f01fddc5) --- core/variant_parser.h | 8 ++++---- scene/resources/resource_format_text.cpp | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/variant_parser.h b/core/variant_parser.h index 19478c9be67..856e6289b16 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -73,10 +73,10 @@ public: typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref &r_res, int &line, String &r_err_str); struct ResourceParser { - void *userdata; - ParseResourceFunc func; - ParseResourceFunc ext_func; - ParseResourceFunc sub_func; + void *userdata = nullptr; + ParseResourceFunc func = nullptr; + ParseResourceFunc ext_func = nullptr; + ParseResourceFunc sub_func = nullptr; }; enum TokenType { diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index fc5938f21c6..27a349d75c4 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -853,7 +853,6 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) rp.ext_func = _parse_ext_resources; rp.sub_func = _parse_sub_resources; - rp.func = nullptr; rp.userdata = this; } From e0f8efcb016390b736dbdadac171b866472b8c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Sat, 31 Jul 2021 09:36:34 +0200 Subject: [PATCH 16/30] Fix thread start with no user data when target has no default argument (cherry picked from commit 7ca805164532f6fc0e488c6cef1e328fa95fb95b) --- core/bind/core_bind.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 53b704edba6..0f36cdb61d5 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2589,7 +2589,36 @@ void _Thread::_start_func(void *ud) { memdelete(tud); Variant::CallError ce; const Variant *arg[1] = { &t->userdata }; - int argc = (int)(arg[0]->get_type() != Variant::NIL); + int argc = 0; + if (arg[0]->get_type() != Variant::NIL) { + // Just pass to the target function whatever came as user data + argc = 1; + } else { + // There are two cases of null user data: + // a) The target function has zero parameters and the caller is just honoring that. + // b) The target function has at least one parameter with no default and the caller is + // leveraging the fact that user data defaults to null in Thread.start(). + // We care about the case of more than one parameter because, even if a thread + // function can have one at most, out mindset here is to do our best with the + // only/first one and let the call handle any other error conditions, like too + // much arguments. + // We must check if we are in case b). + int target_param_count = 0; + int target_default_arg_count = 0; + Ref