From cf3497ce78d1d12d8c3f046290e2ddca1d127541 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Sat, 19 Feb 2022 19:58:38 -0500 Subject: [PATCH 01/10] Fix deleting of directories on Linux Trailing slash of directories was mishandled, and incorrect derived paths were formed. Stripping the slash fixes this. (cherry picked from commit 2c00b906130a8a86027e3b79384d2a9a4ea430da) --- platform/x11/os_x11.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 87217274193..91dd605c97d 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -3758,9 +3758,11 @@ static String get_mountpoint(const String &p_path) { } Error OS_X11::move_to_trash(const String &p_path) { + String path = p_path.rstrip("/"); // Strip trailing slash when path points to a directory + int err_code; List args; - args.push_back(p_path); + args.push_back(path); args.push_front("trash"); // The command is `gio trash ` so we need to add it to args. Error result = execute("gio", args, true, nullptr, nullptr, &err_code); // For GNOME based machines. if (result == OK && !err_code) { @@ -3790,14 +3792,14 @@ Error OS_X11::move_to_trash(const String &p_path) { // If the commands `kioclient5`, `gio` or `gvfs-trash` don't exist on the system we do it manually. String trash_path = ""; - String mnt = get_mountpoint(p_path); + String mnt = get_mountpoint(path); // If there is a directory "[Mountpoint]/.Trash-[UID], use it as the trash can. if (mnt != "") { - String path(mnt + "/.Trash-" + itos(getuid())); + String mountpoint_trash_path(mnt + "/.Trash-" + itos(getuid())); struct stat s; - if (!stat(path.utf8().get_data(), &s)) { - trash_path = path; + if (!stat(mountpoint_trash_path.utf8().get_data(), &s)) { + trash_path = mountpoint_trash_path; } } @@ -3828,18 +3830,15 @@ Error OS_X11::move_to_trash(const String &p_path) { // Issue an error if trash can is not created proprely. ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\""); err = dir_access->make_dir_recursive(trash_path + "/files"); - ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"/files"); + ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "/files\""); err = dir_access->make_dir_recursive(trash_path + "/info"); - ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"/info"); + ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "/info\""); } // The trash can is successfully created, now we check that we don't exceed our file name length limit. // If the file name is too long trim it so we can add the identifying number and ".trashinfo". // Assumes that the file name length limit is 255 characters. - String file_name = p_path.get_file(); - if (file_name.length() == 0) { - file_name = p_path.get_base_dir().get_file(); - } + String file_name = path.get_file(); if (file_name.length() > 240) { file_name = file_name.substr(0, file_name.length() - 15); } @@ -3862,29 +3861,31 @@ Error OS_X11::move_to_trash(const String &p_path) { } file_name = fn; + String renamed_path = path.get_base_dir() + "/" + file_name; + // Generates the .trashinfo file OS::Date date = OS::get_singleton()->get_date(false); OS::Time time = OS::get_singleton()->get_time(false); String timestamp = vformat("%04d-%02d-%02dT%02d:%02d:", date.year, (int)date.month, date.day, time.hour, time.min); timestamp = vformat("%s%02d", timestamp, time.sec); // vformat only supports up to 6 arguments. - String trash_info = "[Trash Info]\nPath=" + p_path.http_escape() + "\nDeletionDate=" + timestamp + "\n"; + String trash_info = "[Trash Info]\nPath=" + path.http_escape() + "\nDeletionDate=" + timestamp + "\n"; { Error err; FileAccessRef file = FileAccess::open(trash_path + "/info/" + file_name + ".trashinfo", FileAccess::WRITE, &err); - ERR_FAIL_COND_V_MSG(err != OK, err, "Can't create trashinfo file:" + trash_path + "/info/" + file_name + ".trashinfo"); + ERR_FAIL_COND_V_MSG(err != OK, err, "Can't create trashinfo file: \"" + trash_path + "/info/" + file_name + ".trashinfo\""); file->store_string(trash_info); file->close(); // Rename our resource before moving it to the trash can. DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - err = dir_access->rename(p_path, p_path.get_base_dir() + "/" + file_name); - ERR_FAIL_COND_V_MSG(err != OK, err, "Can't rename file \"" + p_path + "\""); + err = dir_access->rename(path, renamed_path); + ERR_FAIL_COND_V_MSG(err != OK, err, "Can't rename file \"" + path + "\" to \"" + renamed_path + "\""); } // Move the given resource to the trash can. // Do not use DirAccess:rename() because it can't move files across multiple mountpoints. List mv_args; - mv_args.push_back(p_path.get_base_dir() + "/" + file_name); + mv_args.push_back(renamed_path); mv_args.push_back(trash_path + "/files"); { int retval; @@ -3892,11 +3893,11 @@ Error OS_X11::move_to_trash(const String &p_path) { // Issue an error if "mv" failed to move the given resource to the trash can. if (err != OK || retval != 0) { - ERR_PRINT("move_to_trash: Could not move the resource \"" + p_path + "\" to the trash can \"" + trash_path + "/files\""); + ERR_PRINT("move_to_trash: Could not move the resource \"" + path + "\" to the trash can \"" + trash_path + "/files\""); DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - err = dir_access->rename(p_path.get_base_dir() + "/" + file_name, p_path); + err = dir_access->rename(renamed_path, path); memdelete(dir_access); - ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename " + p_path.get_base_dir() + "/" + file_name + " back to its original name:" + p_path); + ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename \"" + renamed_path + "\" back to its original name: \"" + path + "\""); return FAILED; } } From 4594c96daee8ac90b1e44f759327973b1d01adae Mon Sep 17 00:00:00 2001 From: hoontee Date: Wed, 9 Mar 2022 17:25:45 -0600 Subject: [PATCH 02/10] Revert #52647 (cherry picked from commit 9c312c486c14d234062f6407708a4298bebe91af) --- modules/csg/csg_shape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index bc312f1d321..09d9fcceefe 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -273,7 +273,7 @@ void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const f } void CSGShape::_update_shape() { - if (parent || !is_inside_tree()) { + if (parent) { return; } From 36aa94502c1c3cb906d4dad7dc4665e57150a645 Mon Sep 17 00:00:00 2001 From: Ansraer Date: Thu, 10 Mar 2022 01:04:40 +0100 Subject: [PATCH 03/10] Fix alpha scissor support (cherry picked from commit 2fb998bfbc6daddc2d5b311d489fb01c782c4c3b) --- drivers/gles2/rasterizer_storage_gles2.cpp | 2 +- drivers/gles3/rasterizer_storage_gles3.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 5c891bd53f6..d2d85daebe3 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -1952,7 +1952,7 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) { if (p_material->shader && p_material->shader->mode == VS::SHADER_SPATIAL) { if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX && - (!p_material->shader->spatial.uses_alpha || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) { + (!(p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) { can_cast_shadow = true; } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 2a3631fdb87..b8050fd3ca9 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3153,7 +3153,7 @@ void RasterizerStorageGLES3::_update_material(Material *material) { if (material->shader && material->shader->mode == VS::SHADER_SPATIAL) { if (material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX && - (!material->shader->spatial.uses_alpha || material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) { + (!(material->shader->spatial.uses_alpha && !material->shader->spatial.uses_alpha_scissor) || material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) { can_cast_shadow = true; } From bd47f7aebbbfbda129741ab05518ad39b72d2ce1 Mon Sep 17 00:00:00 2001 From: MythTitans Date: Fri, 11 Mar 2022 00:16:30 +0100 Subject: [PATCH 04/10] Fix normals computation at the 'seam' of smoothed torus shape (cherry picked from commit 8bcbaff41119b254c34938a632f787a8049e88c6) --- modules/csg/csg_shape.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 09d9fcceefe..fbf0e082170 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1577,6 +1577,9 @@ CSGBrush *CSGTorus::_build_brush() { for (int i = 0; i < sides; i++) { float inci = float(i) / sides; float inci_n = float((i + 1)) / sides; + if (i == sides - 1) { + inci_n = 0; + } float angi = inci * Math_PI * 2.0; float angi_n = inci_n * Math_PI * 2.0; @@ -1587,6 +1590,9 @@ CSGBrush *CSGTorus::_build_brush() { for (int j = 0; j < ring_sides; j++) { float incj = float(j) / ring_sides; float incj_n = float((j + 1)) / ring_sides; + if (j == ring_sides - 1) { + incj_n = 0; + } float angj = incj * Math_PI * 2.0; float angj_n = incj_n * Math_PI * 2.0; From e7d9a40a8bbceb77a3bcb86c6331f6019e8d68e2 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Fri, 11 Mar 2022 01:03:07 +0100 Subject: [PATCH 05/10] Fix documentation about depth and width of Height map (cherry picked from commit 2cafaf3adb59ccd72a0b28360665c9a94cb19b5b) --- doc/classes/HeightMapShape.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/classes/HeightMapShape.xml b/doc/classes/HeightMapShape.xml index 46dc1cd9328..ea14356f306 100644 --- a/doc/classes/HeightMapShape.xml +++ b/doc/classes/HeightMapShape.xml @@ -15,10 +15,10 @@ Height map data, pool array must be of [member map_width] * [member map_depth] size. - Depth of the height map data. Changing this will resize the [member map_data]. + Number of vertices in the depth of the height map. Changing this will resize the [member map_data]. - Width of the height map data. Changing this will resize the [member map_data]. + Number of vertices in the width of the height map. Changing this will resize the [member map_data]. From 69c3abedf0427fe90895f8aa46ac56b69386a9a0 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Fri, 11 Mar 2022 15:44:40 +0000 Subject: [PATCH 06/10] Correct docs for Environment background keep mode The docs incorrectly stated that KEEP was the fastest mode. This is not the case with modern hardware. (cherry picked from commit bc924d4b4135e3314fbf934aca5274c7985a4408) --- doc/classes/Environment.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index ecef1ef4a69..b5971741d5b 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -302,7 +302,8 @@ - Keeps on screen every pixel drawn in the background. This is the fastest background mode, but it can only be safely used in fully-interior scenes (no visible sky or sky reflections). If enabled in a scene where the background is visible, "ghost trail" artifacts will be visible when moving the camera. + Keeps on screen every pixel drawn in the background. Only select this mode if you really need to keep the old data. On modern GPUs it will generally not be faster than clearing the background, and can be significantly slower, particularly on mobile. + It can only be safely used in fully-interior scenes (no visible sky or sky reflections). If enabled in a scene where the background is visible, "ghost trail" artifacts will be visible when moving the camera. Clears the background using the clear color defined in [member ProjectSettings.rendering/environment/default_clear_color]. From d57b7cb0e5b31280bd42b8aaecd9ada802493f2f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 11 Mar 2022 18:22:20 +0100 Subject: [PATCH 07/10] Clarify the position of points in `Curve{2D,3D}.add_point()` (cherry picked from commit 35c8d332b539b034cb325394e2a5c70623403916) --- doc/classes/Curve2D.xml | 2 +- doc/classes/Curve3D.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index f6679439b19..d2d94e6a88d 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -17,7 +17,7 @@ - Adds a point to a curve at [code]position[/code], with control points [code]in[/code] and [code]out[/code]. + Adds a point to a curve at [code]position[/code] relative to the [Curve2D]'s position, with control points [code]in[/code] and [code]out[/code]. If [code]at_position[/code] is given, the point is inserted before the point number [code]at_position[/code], moving that point (and every point after) after the inserted point. If [code]at_position[/code] is not given, or is an illegal value ([code]at_position <0[/code] or [code]at_position >= [method get_point_count][/code]), the point will be appended at the end of the point list. diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index 76e4ece6fe2..7fbd309f338 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -17,7 +17,7 @@ - Adds a point to a curve at [code]position[/code], with control points [code]in[/code] and [code]out[/code]. + Adds a point to a curve at [code]position[/code] relative to the [Curve3D]'s position, with control points [code]in[/code] and [code]out[/code]. If [code]at_position[/code] is given, the point is inserted before the point number [code]at_position[/code], moving that point (and every point after) after the inserted point. If [code]at_position[/code] is not given, or is an illegal value ([code]at_position <0[/code] or [code]at_position >= [method get_point_count][/code]), the point will be appended at the end of the point list. From 5c64f0d7bf21cd28a67e2a5e329e6a6285ae0cd8 Mon Sep 17 00:00:00 2001 From: MythTitans Date: Fri, 11 Mar 2022 18:55:44 +0100 Subject: [PATCH 08/10] Prevent non-smoothed face normals to participate to smoothed face normals (cherry picked from commit ec2984f7c7b9543b1353d3a605c7fcdfe5642703) --- modules/csg/csg_shape.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index fbf0e082170..64164f55f57 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -296,17 +296,19 @@ void CSGShape::_update_shape() { ERR_CONTINUE(mat < -1 || mat >= face_count.size()); int idx = mat == -1 ? face_count.size() - 1 : mat; - Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]); + if (n->faces[i].smooth) { + Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]); - for (int j = 0; j < 3; j++) { - Vector3 v = n->faces[i].vertices[j]; - Vector3 add; - if (vec_map.lookup(v, add)) { - add += p.normal; - } else { - add = p.normal; + for (int j = 0; j < 3; j++) { + Vector3 v = n->faces[i].vertices[j]; + Vector3 add; + if (vec_map.lookup(v, add)) { + add += p.normal; + } else { + add = p.normal; + } + vec_map.set(v, add); } - vec_map.set(v, add); } face_count.write[idx]++; From 496d2843c45712a6b0e81d731c3c493f955987c6 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sat, 12 Mar 2022 14:37:20 +0800 Subject: [PATCH 09/10] Hide smart snapping line when guideline dragging ends (cherry picked from commit b255efba7cbcc3757d5489b63ae4bbe79db954f4) --- editor/plugins/canvas_item_editor_plugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index abd30fa39ee..3f1615f0a12 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1241,6 +1241,8 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref &p_eve } } } + snap_target[0] = SNAP_TARGET_NONE; + snap_target[1] = SNAP_TARGET_NONE; drag_type = DRAG_NONE; viewport->update(); return true; From 7adead25eafb551e7b7537a05ce91efdbc731987 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sat, 12 Mar 2022 11:02:27 +0800 Subject: [PATCH 10/10] Fix RichTextLabel shadow color when text has transparency (cherry picked from commit 7d219b67934ed554cb8dd1160fbb60a937f1c896) --- scene/gui/rich_text_label.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index f5a0ee38521..b7a6adad4af 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -591,21 +591,24 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & draw_rect(Rect2(p_ofs.x + pofs, p_ofs.y + y, cw, lh), selection_bg); } - if (p_font_color_shadow.a > 0) { + const Color char_color = selected && override_selected_font_color ? selection_fg : fx_color; + const Color shadow_color = p_font_color_shadow * Color(1, 1, 1, char_color.a); + + if (shadow_color.a > 0) { const Point2 shadow_base_pos = p_ofs + Point2(align_ofs + pofs, y + lh - line_descent); - font->draw_char(ci, shadow_base_pos + shadow_ofs + fx_offset, fx_char, c[i + 1], p_font_color_shadow); + font->draw_char(ci, shadow_base_pos + shadow_ofs + fx_offset, fx_char, c[i + 1], shadow_color); if (p_shadow_as_outline) { - font->draw_char(ci, shadow_base_pos + Vector2(-shadow_ofs.x, shadow_ofs.y) + fx_offset, fx_char, c[i + 1], p_font_color_shadow); - font->draw_char(ci, shadow_base_pos + Vector2(shadow_ofs.x, -shadow_ofs.y) + fx_offset, fx_char, c[i + 1], p_font_color_shadow); - font->draw_char(ci, shadow_base_pos + Vector2(-shadow_ofs.x, -shadow_ofs.y) + fx_offset, fx_char, c[i + 1], p_font_color_shadow); + font->draw_char(ci, shadow_base_pos + Vector2(-shadow_ofs.x, shadow_ofs.y) + fx_offset, fx_char, c[i + 1], shadow_color); + font->draw_char(ci, shadow_base_pos + Vector2(shadow_ofs.x, -shadow_ofs.y) + fx_offset, fx_char, c[i + 1], shadow_color); + font->draw_char(ci, shadow_base_pos + Vector2(-shadow_ofs.x, -shadow_ofs.y) + fx_offset, fx_char, c[i + 1], shadow_color); } } if (selected) { - drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent), fx_char, c[i + 1], override_selected_font_color ? selection_fg : fx_color); + drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent), fx_char, c[i + 1], char_color); } else { - cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color); + cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], char_color); } } else if (previously_visible && c[i] != '\t') { backtrack += font->get_char_size(fx_char, c[i + 1]).x;