From 2bae35353d49fbbd7a1b2530785b6ba75103fad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 2 Mar 2020 16:35:16 +0100 Subject: [PATCH 01/43] Revert "Fix control node transform animation jitter with pivot offset" This reverts commit 15315f118ccd0a462eafa01801570c0dd887ca4d. It caused a regression: #36087. --- scene/gui/control.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4c70bd1d394..ae48a1356e6 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -462,6 +462,11 @@ void Control::_update_canvas_item_transform() { Transform2D xform = _get_internal_transform(); xform[2] += get_position(); + // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot() + if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { + xform[2] = xform[2].round(); + } + VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform); } From 45248fb0ec5fcf36f00a05eb82fe528a40329188 Mon Sep 17 00:00:00 2001 From: Fabio Iotti Date: Mon, 2 Mar 2020 21:36:01 +0000 Subject: [PATCH 02/43] Fix OGG audio loops (cherry picked from commit 4f8d1c47b8d8c0429c4499ead764850324a77ed3) --- modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index f2d0f5c9a64..606de8921bb 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -57,7 +57,8 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra if (todo) { //end of file! - if (vorbis_stream->loop && mixed > 0) { + bool is_not_empty = mixed > 0 || stb_vorbis_stream_length_in_samples(ogg_stream) > 0; + if (vorbis_stream->loop && is_not_empty) { //loop seek(vorbis_stream->loop_offset); loops++; From e70e0d24d93998f07afcf79fbbcca484143fae0b Mon Sep 17 00:00:00 2001 From: Eevee Date: Sat, 29 Feb 2020 16:50:33 -0700 Subject: [PATCH 03/43] Fix inverted use of Camera2D.offset_v MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code above for horizontal movement uses the right margin (_positive_ x direction) when the offset is negative, but vertical movement uses the top margin (_negative_ y direction) when the offset is negative. The resulting problem is easily seen in the editor — set the drag margins to be asymmetrical, turn on drawing the drag margins, and slide the offsets from -1 to 1 and back. The horizontal offset moves the camera's center between the left and right margins, but the vertical offset gets them backwards and will move the camera outside the margins entirely. (cherry picked from commit 40816574ac789af9cfcc061eea5bd91aa1079f6b) --- scene/2d/camera_2d.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index e9f8c5dff2c..907d0bedfa8 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -128,9 +128,9 @@ Transform2D Camera2D::get_camera_transform() { } else { if (v_ofs < 0) { - camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs; - } else { camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs; + } else { + camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs; } v_offset_changed = false; From c75459ac9567c2599414af64aebc024b4036723a Mon Sep 17 00:00:00 2001 From: Phischermen Date: Wed, 20 Nov 2019 23:58:48 -0800 Subject: [PATCH 04/43] Enabled concave collision detection with Areas in Bullet. (cherry picked from commit 2c01cf54f8463fb22b4120c40087b4f0398b1704) --- modules/bullet/space_bullet.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 0f50d316116..fb317f6eb37 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -726,9 +726,6 @@ void SpaceBullet::check_ghost_overlaps() { other_body_shape = static_cast(otherObject->get_bt_shape(z)); - if (other_body_shape->isConcave()) - continue; - btTransform other_shape_transform(otherObject->get_bt_shape_transform(z)); other_shape_transform.getOrigin() *= other_body_scale; From 04b3e208fa656f01e0948880b87c6f93c85a3755 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Mon, 10 Feb 2020 16:04:15 +0300 Subject: [PATCH 05/43] Add a button to quickly repeat last search in files (cherry picked from commit 8c80b602ac51c5bceec4f767692e694d9ce73450) --- editor/find_in_files.cpp | 14 ++++++++++++++ editor/find_in_files.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index b24a5c38f21..c448ef58939 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -533,6 +533,12 @@ FindInFilesPanel::FindInFilesPanel() { _status_label = memnew(Label); hbc->add_child(_status_label); + _refresh_button = memnew(Button); + _refresh_button->set_text(TTR("Refresh")); + _refresh_button->connect("pressed", this, "_on_refresh_button_clicked"); + _refresh_button->hide(); + hbc->add_child(_refresh_button); + _cancel_button = memnew(Button); _cancel_button->set_text(TTR("Cancel")); _cancel_button->connect("pressed", this, "_on_cancel_button_clicked"); @@ -616,6 +622,7 @@ void FindInFilesPanel::start_search() { _finder->start(); update_replace_buttons(); + _refresh_button->hide(); _cancel_button->show(); } @@ -626,6 +633,7 @@ void FindInFilesPanel::stop_search() { _status_label->set_text(""); update_replace_buttons(); set_progress_visible(false); + _refresh_button->show(); _cancel_button->hide(); } @@ -728,9 +736,14 @@ void FindInFilesPanel::_on_finished() { _status_label->set_text(TTR("Search complete")); update_replace_buttons(); set_progress_visible(false); + _refresh_button->show(); _cancel_button->hide(); } +void FindInFilesPanel::_on_refresh_button_clicked() { + start_search(); +} + void FindInFilesPanel::_on_cancel_button_clicked() { stop_search(); } @@ -905,6 +918,7 @@ void FindInFilesPanel::_bind_methods() { ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found); ClassDB::bind_method("_on_item_edited", &FindInFilesPanel::_on_item_edited); ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished); + ClassDB::bind_method("_on_refresh_button_clicked", &FindInFilesPanel::_on_refresh_button_clicked); ClassDB::bind_method("_on_cancel_button_clicked", &FindInFilesPanel::_on_cancel_button_clicked); ClassDB::bind_method("_on_result_selected", &FindInFilesPanel::_on_result_selected); ClassDB::bind_method("_on_replace_text_changed", &FindInFilesPanel::_on_replace_text_changed); diff --git a/editor/find_in_files.h b/editor/find_in_files.h index 327c3f1b5ad..e8a524aaf42 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -163,6 +163,7 @@ protected: private: void _on_result_found(String fpath, int line_number, int begin, int end, String text); void _on_finished(); + void _on_refresh_button_clicked(); void _on_cancel_button_clicked(); void _on_result_selected(); void _on_item_edited(); @@ -190,6 +191,7 @@ private: Label *_search_text_label; Tree *_results_display; Label *_status_label; + Button *_refresh_button; Button *_cancel_button; ProgressBar *_progress_bar; Map _file_items; From f328ac36d65b7eaaaa363076afae13393c2a0fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=27dreamsComeTrue=27=20Jasi=C5=84ski?= Date: Mon, 10 Feb 2020 23:09:07 +0100 Subject: [PATCH 06/43] Fix: auto brace complete for quoted strings Fixes #36002 (cherry picked from commit 6a404a88e4ed865eae9ce7c603c64423b92d9621) --- scene/gui/text_edit.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6de2f0b5709..f9e1c68bc91 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1844,6 +1844,42 @@ void TextEdit::_consume_pair_symbol(CharType ch) { } } + String line = text[cursor.line]; + + bool in_single_quote = false; + bool in_double_quote = false; + + int c = 0; + while (c < line.length()) { + if (line[c] == '\\') { + c++; // Skip quoted anything. + + if (cursor.column == c) { + break; + } + } else { + if (line[c] == '\'' && !in_double_quote) { + in_single_quote = !in_single_quote; + } else if (line[c] == '"' && !in_single_quote) { + in_double_quote = !in_double_quote; + } + } + + c++; + + if (cursor.column == c) { + break; + } + } + + // Disallow inserting duplicated quotes while already in string + if ((in_single_quote || in_double_quote) && (ch == '"' || ch == '\'')) { + insert_text_at_cursor(ch_single); + cursor_set_column(cursor_position_to_move); + + return; + } + insert_text_at_cursor(ch_pair); cursor_set_column(cursor_position_to_move); } From b80190721b56e5b398282f7bd0c8b08e26119bb9 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 17 Feb 2020 00:01:52 +0100 Subject: [PATCH 07/43] Allow using `MeshLibrary.get_item_preview()` in non-editor builds again This closes #36268. (cherry picked from commit 64fac9dd5d8ad360c783020a62a04c8434f5e143) --- doc/classes/MeshLibrary.xml | 3 +-- scene/resources/mesh_library.cpp | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/doc/classes/MeshLibrary.xml b/doc/classes/MeshLibrary.xml index 75d2dd22f38..fed82520792 100644 --- a/doc/classes/MeshLibrary.xml +++ b/doc/classes/MeshLibrary.xml @@ -84,8 +84,7 @@ - Returns a generated item preview (a 3D rendering in isometric perspective). - [b]Note:[/b] Since item previews are only generated in an editor context, this function will return an empty [Texture] in a running project. + When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using [method set_item_preview]. Returns an empty [Texture] if no preview was manually set in a running project. diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index 754cad4defd..0e017f6f23b 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -29,7 +29,6 @@ /*************************************************************************/ #include "mesh_library.h" -#include "core/engine.h" bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { @@ -202,11 +201,6 @@ Transform MeshLibrary::get_item_navmesh_transform(int p_item) const { Ref MeshLibrary::get_item_preview(int p_item) const { - if (!Engine::get_singleton()->is_editor_hint()) { - ERR_PRINT("MeshLibrary item previews are only generated in an editor context, which means they aren't available in a running project."); - return Ref(); - } - ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'."); return item_map[p_item].preview; } From 73240f81d00c4c4c6dcbbb836771f47204367d73 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 18 Feb 2020 22:57:40 +0100 Subject: [PATCH 08/43] Decrease the script editor's default split width to 70 This also makes its value change to match the editor scale. (cherry picked from commit ac3c93077c3747535f1631eda6f7e9497705c849) --- editor/plugins/script_editor_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1da47196f80..955b2077af7 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3211,7 +3211,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { scripts_vbox->add_child(script_list); script_list->set_custom_minimum_size(Size2(150, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing script_list->set_v_size_flags(SIZE_EXPAND_FILL); - script_split->set_split_offset(140); + script_split->set_split_offset(70 * EDSCALE); _sort_list_on_update = true; script_list->connect("gui_input", this, "_script_list_gui_input", varray(), CONNECT_DEFERRED); script_list->set_allow_rmb_select(true); From ffea9fc39fbf945d35f2ad8980b4c05d6a40dafa Mon Sep 17 00:00:00 2001 From: janglee Date: Sat, 22 Feb 2020 22:22:22 +0530 Subject: [PATCH 09/43] Added tween support for Rect2 Fixes #34575 (cherry picked from commit 4bbe87abb7c4d7c814ce119c09f100ece0756414) --- scene/animation/tween.cpp | 179 ++++++++++++++++++++++++-------------- 1 file changed, 114 insertions(+), 65 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 331a6c769ce..1e0dd7429d0 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -67,7 +67,6 @@ void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const count = 0; // Add the specified arguments to the command - // TODO: Make this a switch statement? if (count > 0) cmd.arg[0] = p_arg1; if (count > 1) @@ -459,6 +458,20 @@ Variant Tween::_run_equation(InterpolateData &p_data) { result = r; } break; + case Variant::RECT2: { + // Get the Rect2 for initial and delta value + Rect2 i = initial_val; + Rect2 d = delta_val; + Rect2 r; + + // Execute the equation for the position and size of Rect2 + APPLY_EQUATION(position.x); + APPLY_EQUATION(position.y); + APPLY_EQUATION(size.x); + APPLY_EQUATION(size.y); + result = r; + } break; + case Variant::VECTOR3: { // Get vectors for initial and delta values Vector3 i = initial_val; @@ -473,6 +486,55 @@ Variant Tween::_run_equation(InterpolateData &p_data) { result = r; } break; + case Variant::TRANSFORM2D: { + // Get the transforms for initial and delta values + Transform2D i = initial_val; + Transform2D d = delta_val; + Transform2D r; + + // Execute the equation on the transforms and mutate the r transform + // This uses the custom APPLY_EQUATION macro defined above + APPLY_EQUATION(elements[0][0]); + APPLY_EQUATION(elements[0][1]); + APPLY_EQUATION(elements[1][0]); + APPLY_EQUATION(elements[1][1]); + APPLY_EQUATION(elements[2][0]); + APPLY_EQUATION(elements[2][1]); + result = r; + } break; + + case Variant::QUAT: { + // Get the quaternian for the initial and delta values + Quat i = initial_val; + Quat d = delta_val; + Quat r; + + // Execute the equation on the quaternian values and mutate the r quaternian + // This uses the custom APPLY_EQUATION macro defined above + APPLY_EQUATION(x); + APPLY_EQUATION(y); + APPLY_EQUATION(z); + APPLY_EQUATION(w); + result = r; + } break; + + case Variant::AABB: { + // Get the AABB's for the initial and delta values + AABB i = initial_val; + AABB d = delta_val; + AABB r; + + // Execute the equation for the position and size of the AABB's and mutate the r AABB + // This uses the custom APPLY_EQUATION macro defined above + APPLY_EQUATION(position.x); + APPLY_EQUATION(position.y); + APPLY_EQUATION(position.z); + APPLY_EQUATION(size.x); + APPLY_EQUATION(size.y); + APPLY_EQUATION(size.z); + result = r; + } break; + case Variant::BASIS: { // Get the basis for initial and delta values Basis i = initial_val; @@ -493,52 +555,6 @@ Variant Tween::_run_equation(InterpolateData &p_data) { result = r; } break; - case Variant::TRANSFORM2D: { - // Get the transforms for initial and delta values - Transform2D i = initial_val; - Transform2D d = delta_val; - Transform2D r; - - // Execute the equation on the transforms and mutate the r transform - // This uses the custom APPLY_EQUATION macro defined above - APPLY_EQUATION(elements[0][0]); - APPLY_EQUATION(elements[0][1]); - APPLY_EQUATION(elements[1][0]); - APPLY_EQUATION(elements[1][1]); - APPLY_EQUATION(elements[2][0]); - APPLY_EQUATION(elements[2][1]); - result = r; - } break; - case Variant::QUAT: { - // Get the quaternian for the initial and delta values - Quat i = initial_val; - Quat d = delta_val; - Quat r; - - // Execute the equation on the quaternian values and mutate the r quaternian - // This uses the custom APPLY_EQUATION macro defined above - APPLY_EQUATION(x); - APPLY_EQUATION(y); - APPLY_EQUATION(z); - APPLY_EQUATION(w); - result = r; - } break; - case Variant::AABB: { - // Get the AABB's for the initial and delta values - AABB i = initial_val; - AABB d = delta_val; - AABB r; - - // Execute the equation for the position and size of the AABB's and mutate the r AABB - // This uses the custom APPLY_EQUATION macro defined above - APPLY_EQUATION(position.x); - APPLY_EQUATION(position.y); - APPLY_EQUATION(position.z); - APPLY_EQUATION(size.x); - APPLY_EQUATION(size.y); - APPLY_EQUATION(size.z); - result = r; - } break; case Variant::TRANSFORM: { // Get the transforms for the initial and delta values Transform i = initial_val; @@ -561,6 +577,7 @@ Variant Tween::_run_equation(InterpolateData &p_data) { APPLY_EQUATION(origin.z); result = r; } break; + case Variant::COLOR: { // Get the Color for initial and delta value Color i = initial_val; @@ -575,6 +592,7 @@ Variant Tween::_run_equation(InterpolateData &p_data) { APPLY_EQUATION(a); result = r; } break; + default: { // If unknown, just return the initial value result = initial_val; @@ -1129,26 +1147,18 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final delta_val = final_val.operator Vector2() - initial_val.operator Vector2(); break; + case Variant::RECT2: { + // Build a new Rect2 and use the new position and sizes to make a delta + Rect2 i = initial_val; + Rect2 f = final_val; + delta_val = Rect2(f.position - i.position, f.size - i.size); + } break; + case Variant::VECTOR3: // Convert to Vectors and find the delta delta_val = final_val.operator Vector3() - initial_val.operator Vector3(); break; - case Variant::BASIS: { - // Build a new basis which is the delta between the initial and final values - Basis i = initial_val; - Basis f = final_val; - delta_val = Basis(f.elements[0][0] - i.elements[0][0], - f.elements[0][1] - i.elements[0][1], - f.elements[0][2] - i.elements[0][2], - f.elements[1][0] - i.elements[1][0], - f.elements[1][1] - i.elements[1][1], - f.elements[1][2] - i.elements[1][2], - f.elements[2][0] - i.elements[2][0], - f.elements[2][1] - i.elements[2][1], - f.elements[2][2] - i.elements[2][2]); - } break; - case Variant::TRANSFORM2D: { // Build a new transform which is the difference between the initial and final values Transform2D i = initial_val; @@ -1175,6 +1185,21 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final delta_val = AABB(f.position - i.position, f.size - i.size); } break; + case Variant::BASIS: { + // Build a new basis which is the delta between the initial and final values + Basis i = initial_val; + Basis f = final_val; + delta_val = Basis(f.elements[0][0] - i.elements[0][0], + f.elements[0][1] - i.elements[0][1], + f.elements[0][2] - i.elements[0][2], + f.elements[1][0] - i.elements[1][0], + f.elements[1][1] - i.elements[1][1], + f.elements[1][2] - i.elements[1][2], + f.elements[2][0] - i.elements[2][0], + f.elements[2][1] - i.elements[2][1], + f.elements[2][2] - i.elements[2][2]); + } break; + case Variant::TRANSFORM: { // Build a new transform which is the difference between the initial and final values Transform i = initial_val; @@ -1203,10 +1228,34 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a); } break; - default: - // TODO: Should move away from a 'magic string'? - ERR_PRINT("Invalid param type, except(int/real/vector2/vector/matrix/matrix32/quat/aabb/transform/color)"); + default: { + static Variant::Type supported_types[] = { + Variant::BOOL, + Variant::INT, + Variant::REAL, + Variant::VECTOR2, + Variant::RECT2, + Variant::VECTOR3, + Variant::TRANSFORM2D, + Variant::QUAT, + Variant::AABB, + Variant::BASIS, + Variant::TRANSFORM, + Variant::COLOR, + }; + + int length = *(&supported_types + 1) - supported_types; + String error_msg = "Invalid parameter type. Supported types are: "; + for (int i = 0; i < length; i++) { + if (i != 0) { + error_msg += ", "; + } + error_msg += Variant::get_type_name(supported_types[i]); + } + error_msg += "."; + ERR_PRINT(error_msg); return false; + } }; return true; } From 03c8e12d545c65c1be97306823abf36c68ac4376 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 21 Feb 2020 07:27:48 -0300 Subject: [PATCH 10/43] Add support for named binds in Skin. Helps better reutilization of skeletons from Maya exported files. (cherry picked from commit 9a34f39d320132f4a8fef4c231a4678a0159c3d3) --- editor/import/editor_scene_importer_gltf.cpp | 15 +++++-- editor/import/editor_scene_importer_gltf.h | 3 ++ editor/import/resource_importer_scene.cpp | 4 ++ editor/import/resource_importer_scene.h | 3 +- scene/3d/skeleton.cpp | 46 +++++++++++++++++++- scene/3d/skeleton.h | 5 +++ scene/resources/skin.cpp | 30 ++++++++++++- scene/resources/skin.h | 12 ++++- 8 files changed, 110 insertions(+), 8 deletions(-) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 2f9135c52c7..4c22ff1a989 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2179,6 +2179,8 @@ Error EditorSceneImporterGLTF::_map_skin_joints_indices_to_skeleton_bone_indices const GLTFNodeIndex node_i = skin.joints_original[joint_index]; const GLTFNode *node = state.nodes[node_i]; + skin.joint_i_to_name.insert(joint_index, node->name); + const int bone_index = skeleton.godot_skeleton->find_bone(node->name); ERR_FAIL_COND_V(bone_index < 0, FAILED); @@ -2200,12 +2202,18 @@ Error EditorSceneImporterGLTF::_create_skins(GLTFState &state) { const bool has_ibms = !gltf_skin.inverse_binds.empty(); for (int joint_i = 0; joint_i < gltf_skin.joints_original.size(); ++joint_i) { - int bone_i = gltf_skin.joint_i_to_bone_i[joint_i]; + Transform xform; if (has_ibms) { - skin->add_bind(bone_i, gltf_skin.inverse_binds[joint_i]); + xform = gltf_skin.inverse_binds[joint_i]; + } + + if (state.use_named_skin_binds) { + StringName name = gltf_skin.joint_i_to_name[joint_i]; + skin->add_named_bind(name, xform); } else { - skin->add_bind(bone_i, Transform()); + int bone_i = gltf_skin.joint_i_to_bone_i[joint_i]; + skin->add_bind(bone_i, xform); } } @@ -2991,6 +2999,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla state.major_version = version.get_slice(".", 0).to_int(); state.minor_version = version.get_slice(".", 1).to_int(); + state.use_named_skin_binds = p_flags & IMPORT_USE_NAMED_SKIN_BINDS; /* STEP 0 PARSE SCENE */ Error err = _parse_scenes(state); diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 78d7106b0d7..8e9c44db935 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -231,6 +231,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { // A mapping from the joint indices (in the order of joints_original) to the // Godot Skeleton's bone_indices Map joint_i_to_bone_i; + Map joint_i_to_name; // The Actual Skin that will be created as a mapping between the IBM's of this skin // to the generated skeleton for the mesh instances. @@ -298,6 +299,8 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { int minor_version; Vector glb_data; + bool use_named_skin_binds; + Vector nodes; Vector > buffers; Vector buffer_views; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 0774d0b5dcc..0a612c64b20 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -1171,6 +1171,7 @@ void ResourceImporterScene::get_import_options(List *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.mesh),Files (.tres)"), meshes_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/light_baking", PROPERTY_HINT_ENUM, "Disabled,Enable,Gen Lightmaps", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "meshes/lightmap_texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.1)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "skins/use_named_skins"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); @@ -1313,6 +1314,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p if (int(p_options["materials/location"]) == 0) import_flags |= EditorSceneImporter::IMPORT_MATERIALS_IN_INSTANCES; + if (bool(p_options["skins/use_named_skins"])) + import_flags |= EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS; + Error err = OK; List missing_deps; // for now, not much will be done with this Node *scene = importer->import_scene(src_path, import_flags, fps, &missing_deps, &err); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 2691b224eb5..20e7af15b5d 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -59,7 +59,8 @@ public: IMPORT_GENERATE_TANGENT_ARRAYS = 256, IMPORT_FAIL_ON_MISSING_DEPENDENCIES = 512, IMPORT_MATERIALS_IN_INSTANCES = 1024, - IMPORT_USE_COMPRESSION = 2048 + IMPORT_USE_COMPRESSION = 2048, + IMPORT_USE_NAMED_SKIN_BINDS = 4096, }; diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 5edce284b5f..be9bd93e621 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -40,6 +40,7 @@ void SkinReference::_skin_changed() { if (skeleton_node) { skeleton_node->_make_dirty(); } + skeleton_version = 0; } void SkinReference::_bind_methods() { @@ -321,10 +322,49 @@ void Skeleton::_notification(int p_what) { if (E->get()->bind_count != bind_count) { VS::get_singleton()->skeleton_allocate(skeleton, bind_count); E->get()->bind_count = bind_count; + E->get()->skin_bone_indices.resize(bind_count); + E->get()->skin_bone_indices_ptrs = E->get()->skin_bone_indices.ptrw(); + } + + if (E->get()->skeleton_version != version) { + + for (uint32_t i = 0; i < bind_count; i++) { + StringName bind_name = skin->get_bind_name(i); + + if (bind_name != StringName()) { + //bind name used, use this + bool found = false; + for (int j = 0; j < len; j++) { + if (bonesptr[j].name == bind_name) { + E->get()->skin_bone_indices_ptrs[i] = j; + found = true; + break; + } + } + + if (!found) { + ERR_PRINT("Skin bind #" + itos(i) + " contains named bind '" + String(bind_name) + "' but Skeleton has no bone by that name."); + E->get()->skin_bone_indices_ptrs[i] = 0; + } + } else if (skin->get_bind_bone(i) >= 0) { + int bind_index = skin->get_bind_bone(i); + if (bind_index >= len) { + ERR_PRINT("Skin bind #" + itos(i) + " contains bone index bind: " + itos(bind_index) + " , which is greater than the skeleton bone count: " + itos(len) + "."); + E->get()->skin_bone_indices_ptrs[i] = 0; + } else { + E->get()->skin_bone_indices_ptrs[i] = bind_index; + } + } else { + ERR_PRINT("Skin bind #" + itos(i) + " does not contain a name nor a bone index."); + E->get()->skin_bone_indices_ptrs[i] = 0; + } + } + + E->get()->skeleton_version = version; } for (uint32_t i = 0; i < bind_count; i++) { - uint32_t bone_index = skin->get_bind_bone(i); + uint32_t bone_index = E->get()->skin_bone_indices_ptrs[i]; ERR_CONTINUE(bone_index >= (uint32_t)len); vs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i)); } @@ -366,6 +406,7 @@ void Skeleton::add_bone(const String &p_name) { b.name = p_name; bones.push_back(b); process_order_dirty = true; + version++; _make_dirty(); update_gizmo(); } @@ -517,7 +558,7 @@ void Skeleton::clear_bones() { bones.clear(); process_order_dirty = true; - + version++; _make_dirty(); } @@ -849,6 +890,7 @@ void Skeleton::_bind_methods() { Skeleton::Skeleton() { dirty = false; + version = 1; process_order_dirty = true; } diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index 056f70e22be..6a69fbdb93f 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -51,6 +51,9 @@ class SkinReference : public Reference { RID skeleton; Ref skin; uint32_t bind_count = 0; + uint64_t skeleton_version = 0; + Vector skin_bone_indices; + uint32_t *skin_bone_indices_ptrs; void _skin_changed(); protected: @@ -122,6 +125,8 @@ private: void _make_dirty(); bool dirty; + uint64_t version; + // bind helpers Array _get_bound_child_nodes_to_bone(int p_bone) const { diff --git a/scene/resources/skin.cpp b/scene/resources/skin.cpp index 9c8710a59ca..68b9bafaec8 100644 --- a/scene/resources/skin.cpp +++ b/scene/resources/skin.cpp @@ -45,6 +45,24 @@ void Skin::add_bind(int p_bone, const Transform &p_pose) { set_bind_pose(index, p_pose); } +void Skin::add_named_bind(const String &p_name, const Transform &p_pose) { + + uint32_t index = bind_count; + set_bind_count(bind_count + 1); + set_bind_name(index, p_name); + set_bind_pose(index, p_pose); +} + +void Skin::set_bind_name(int p_index, const StringName &p_name) { + ERR_FAIL_INDEX(p_index, bind_count); + bool notify_change = (binds_ptr[p_index].name != StringName()) != (p_name != StringName()); + binds_ptr[p_index].name = p_name; + emit_changed(); + if (notify_change) { + _change_notify(); + } +} + void Skin::set_bind_bone(int p_index, int p_bone) { ERR_FAIL_INDEX(p_index, bind_count); binds_ptr[p_index].bone = p_bone; @@ -75,6 +93,9 @@ bool Skin::_set(const StringName &p_name, const Variant &p_value) { if (what == "bone") { set_bind_bone(index, p_value); return true; + } else if (what == "name") { + set_bind_name(index, p_value); + return true; } else if (what == "pose") { set_bind_pose(index, p_value); return true; @@ -95,6 +116,9 @@ bool Skin::_get(const StringName &p_name, Variant &r_ret) const { if (what == "bone") { r_ret = get_bind_bone(index); return true; + } else if (what == "name") { + r_ret = get_bind_name(index); + return true; } else if (what == "pose") { r_ret = get_bind_pose(index); return true; @@ -105,7 +129,8 @@ bool Skin::_get(const StringName &p_name, Variant &r_ret) const { void Skin::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "bind_count", PROPERTY_HINT_RANGE, "0,16384,1,or_greater")); for (int i = 0; i < get_bind_count(); i++) { - p_list->push_back(PropertyInfo(Variant::INT, "bind/" + itos(i) + "/bone", PROPERTY_HINT_RANGE, "0,16384,1,or_greater")); + p_list->push_back(PropertyInfo(Variant::STRING, "bind/" + itos(i) + "/name")); + p_list->push_back(PropertyInfo(Variant::INT, "bind/" + itos(i) + "/bone", PROPERTY_HINT_RANGE, "0,16384,1,or_greater", get_bind_name(i) != StringName() ? PROPERTY_USAGE_NOEDITOR : PROPERTY_USAGE_DEFAULT)); p_list->push_back(PropertyInfo(Variant::TRANSFORM, "bind/" + itos(i) + "/pose")); } } @@ -120,6 +145,9 @@ void Skin::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bind_pose", "bind_index", "pose"), &Skin::set_bind_pose); ClassDB::bind_method(D_METHOD("get_bind_pose", "bind_index"), &Skin::get_bind_pose); + ClassDB::bind_method(D_METHOD("set_bind_name", "bind_index", "name"), &Skin::set_bind_name); + ClassDB::bind_method(D_METHOD("get_bind_name", "bind_index"), &Skin::get_bind_name); + ClassDB::bind_method(D_METHOD("set_bind_bone", "bind_index", "bone"), &Skin::set_bind_bone); ClassDB::bind_method(D_METHOD("get_bind_bone", "bind_index"), &Skin::get_bind_bone); diff --git a/scene/resources/skin.h b/scene/resources/skin.h index ddc7c655f5a..57aaf1afd41 100644 --- a/scene/resources/skin.h +++ b/scene/resources/skin.h @@ -37,7 +37,8 @@ class Skin : public Resource { GDCLASS(Skin, Resource) struct Bind { - int bone; + int bone = -1; + StringName name; Transform pose; }; @@ -58,9 +59,11 @@ public: inline int get_bind_count() const { return bind_count; } void add_bind(int p_bone, const Transform &p_pose); + void add_named_bind(const String &p_name, const Transform &p_pose); void set_bind_bone(int p_index, int p_bone); void set_bind_pose(int p_index, const Transform &p_pose); + void set_bind_name(int p_index, const StringName &p_name); inline int get_bind_bone(int p_index) const { #ifdef DEBUG_ENABLED @@ -69,6 +72,13 @@ public: return binds_ptr[p_index].bone; } + inline StringName get_bind_name(int p_index) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_INDEX_V(p_index, bind_count, StringName()); +#endif + return binds_ptr[p_index].name; + } + inline Transform get_bind_pose(int p_index) const { #ifdef DEBUG_ENABLED ERR_FAIL_INDEX_V(p_index, bind_count, Transform()); From 6e300a0c491d0733d4b444c8eff0933a2e51217d Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Sat, 22 Feb 2020 18:41:22 -0300 Subject: [PATCH 11/43] Remove extra margin in the top of the debugger (cherry picked from commit 5c5a2b747271f879353ba3835972b10c1ed199ca) --- editor/editor_themes.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 8037045e773..4fd44ebb4cc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -855,6 +855,7 @@ Ref create_editor_theme(const Ref p_theme) { Ref style_panel_invisible_top = style_content_panel->duplicate(); int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height() + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP); style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset); + style_panel_invisible_top->set_default_margin(MARGIN_TOP, 0); theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); // LineEdit From d001ca320da6694058be2c0d5c92271a49986a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sun, 23 Feb 2020 09:28:54 +0100 Subject: [PATCH 12/43] Fix suspicious | and + operators (cherry picked from commit d0621b954b182bb5f30b256ec70a45d821985e58) --- modules/visual_script/visual_script_property_selector.cpp | 2 +- platform/android/export/export.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 99d7ffd05f5..2ad4a1261ec 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -355,7 +355,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt continue; } - bool in_modifier = false | p_modifiers.empty(); + bool in_modifier = p_modifiers.empty(); for (Set::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) { if (E->get().findn(F->get()) != -1) in_modifier = true; diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 884a239f7fe..4f5ce7b9a05 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -337,7 +337,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { Vector props = dp.split("\n"); String vendor; String device; - d.description + "Device ID: " + d.id + "\n"; + d.description = "Device ID: " + d.id + "\n"; d.api_level = 0; for (int j = 0; j < props.size(); j++) { From e13324a889431f70b2858b08bfecf7a82652e965 Mon Sep 17 00:00:00 2001 From: "Mateo Dev .59" Date: Mon, 24 Feb 2020 09:56:22 -0300 Subject: [PATCH 13/43] Core: Change _Marshall class inherit from Reference to Object (cherry picked from commit 9e8e5ebdc74f535df395eaf5d8031002edfe5a10) --- core/bind/core_bind.h | 4 ++-- doc/classes/@GlobalScope.xml | 2 +- doc/classes/Marshalls.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 87da51f97ed..06468c342d6 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -598,9 +598,9 @@ private: bool _list_skip_hidden; }; -class _Marshalls : public Reference { +class _Marshalls : public Object { - GDCLASS(_Marshalls, Reference); + GDCLASS(_Marshalls, Object); static _Marshalls *singleton; diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index e346a312cb6..11c1c57a436 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -50,7 +50,7 @@ The [JavaScript] singleton. [b]Note:[/b] Only implemented on HTML5. - + The [Marshalls] singleton. diff --git a/doc/classes/Marshalls.xml b/doc/classes/Marshalls.xml index a5770afacc3..f0de3afc41f 100644 --- a/doc/classes/Marshalls.xml +++ b/doc/classes/Marshalls.xml @@ -1,5 +1,5 @@ - + Data transformation (marshalling) and encoding helpers. From 105b7468b1e5784c0488f70c1ac50980e4e54348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 25 Feb 2020 13:20:04 +0100 Subject: [PATCH 14/43] Expression: Fix parsing integers as 32-bit (cherry picked from commit ceba2b67614c8393a8f11f5d8a913a5d13c35836) --- core/math/expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 655098376ca..88b72cc2ec4 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -1174,7 +1174,7 @@ Error Expression::_get_token(Token &r_token) { if (is_float) r_token.value = num.to_double(); else - r_token.value = num.to_int(); + r_token.value = num.to_int64(); return OK; } else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') { From e92669654aefc18195a674db571b161aec602318 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 25 Feb 2020 01:24:18 +0100 Subject: [PATCH 15/43] Fix debugger crash inspecting freed object. This seems to be the correct way to validate a reference. Why is cast_to failing? (cherry picked from commit d8ba07ea8f2a17e77549c56ce8eddcbc2fcead7c) --- scene/debugger/script_debugger_remote.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scene/debugger/script_debugger_remote.cpp b/scene/debugger/script_debugger_remote.cpp index 04d04ceb664..56b8e813c16 100644 --- a/scene/debugger/script_debugger_remote.cpp +++ b/scene/debugger/script_debugger_remote.cpp @@ -680,13 +680,17 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) { const PropertyInfo &pi = properties[i].first; Variant &var = properties[i].second; - WeakRef *ref = Object::cast_to(var); - if (ref) { - var = ref->get_ref(); - } - RES res = var; + if (var.get_type() == Variant::OBJECT && var.is_ref()) { + REF r = var; + if (r.is_valid()) { + res = *r; + } else { + res = RES(); + } + } + Array prop; prop.push_back(pi.name); prop.push_back(pi.type); From 6e4aa5a580373024bbcb368b9ea6b17bd4bd8210 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Wed, 26 Feb 2020 00:22:18 -0300 Subject: [PATCH 16/43] Don't show a copy of the property's name in the inspector's tooltip if there's no description (cherry picked from commit 28d3f85e64493de58ddd4f83a72545ff6fa617a6) --- editor/connections_dialog.cpp | 1 - editor/editor_inspector.cpp | 36 +++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index ef5075160e8..f6af92f231a 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -500,7 +500,6 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { String text = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]"; text += p_text.get_slice("::", 1).strip_edges() + "\n"; text += p_text.get_slice("::", 2).strip_edges(); - help_bit->set_text(text); help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene return help_bit; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 7c1e58862ea..7e83fe19dcd 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -778,10 +778,20 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const { help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); - String text = TTR("Property:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; - text += p_text.get_slice("::", 1).strip_edges(); - help_bit->set_text(text); - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + Vector slices = p_text.split("::", false); + if (!slices.empty()) { + String property_name = slices[0].strip_edges(); + String text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]"; + + if (slices.size() > 1) { + String property_doc = slices[1].strip_edges(); + if (property_name != property_doc) { + text += "\n" + property_doc; + } + } + help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + } + return help_bit; } @@ -1005,10 +1015,20 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); - String text = "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; - text += p_text.get_slice("::", 1).strip_edges(); - help_bit->set_text(text); - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + Vector slices = p_text.split("::", false); + if (!slices.empty()) { + String property_name = slices[0].strip_edges(); + String text = "[u][b]" + property_name + "[/b][/u]"; + + if (slices.size() > 1) { + String property_doc = slices[1].strip_edges(); + if (property_name != property_doc) { + text += "\n" + property_doc; + } + } + help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + } + return help_bit; } From 30688769f4a581d95f602c43143ef80edf53d034 Mon Sep 17 00:00:00 2001 From: Andrea Catania Date: Wed, 26 Feb 2020 14:50:22 +0100 Subject: [PATCH 17/43] Fixed editor crash when the animation player has no root assigned. (cherry picked from commit c9b86d54bfd762305ac48232f4a7f98c126fc37e) --- editor/animation_track_editor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 2edfcced602..896ed80ce62 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2480,6 +2480,9 @@ void AnimationTrackEdit::_path_entered(const String &p_text) { bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const { + if (root == nullptr) + return false; + RES res; Vector leftover_path; Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path); From 53b4689979d8dd15d86f1d36a9a9fdd74df52dd4 Mon Sep 17 00:00:00 2001 From: Maurizio Petrarota Date: Wed, 26 Feb 2020 14:35:57 +0100 Subject: [PATCH 18/43] Fixed TextureAtlas import. (cherry picked from commit 744c1fafff7fd63bfef4f26ae03711104690f3e8) --- editor/import/resource_importer_texture_atlas.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 335e1114e67..c9767b1b5f8 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -143,8 +143,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr int px = xi, py = yi; int sx = px, sy = py; - sx = CLAMP(sx, 0, src_width); - sy = CLAMP(sy, 0, src_height); + sx = CLAMP(sx, 0, src_width - 1); + sy = CLAMP(sy, 0, src_height - 1); Color color = p_src_image->get_pixel(sx, sy); if (p_transposed) { SWAP(px, py); @@ -165,8 +165,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) { int px = xi, py = yi; int sx = px, sy = py; - sx = CLAMP(sx, 0, src_width); - sy = CLAMP(sy, 0, src_height); + sx = CLAMP(sx, 0, src_width - 1); + sy = CLAMP(sy, 0, src_height - 1); Color color = p_src_image->get_pixel(sx, sy); if (p_transposed) { SWAP(px, py); From 64885702513a27dc0570140dc2e39b2a9929259e Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 26 Feb 2020 22:25:55 +0100 Subject: [PATCH 19/43] Fix a typo in the "Create Single Convex Collision Sibling" option (cherry picked from commit 7348dfb5b7aaf70c8ee9f99a3487a988c79b5018) --- editor/plugins/mesh_instance_editor_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp index 6e5307cebe8..ca50b847045 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_editor_plugin.cpp @@ -455,7 +455,7 @@ MeshInstanceEditor::MeshInstanceEditor() { options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection.")); - options->get_popup()->add_item(TTR("Create Single Convex Collision Siblings"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE); + options->get_popup()->add_item(TTR("Create Single Convex Collision Sibling"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection.")); options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between the two above options.")); From 8337cc5f7d3f87a9452e0af847df04b2b4965155 Mon Sep 17 00:00:00 2001 From: Ivan Shakhov Date: Thu, 27 Feb 2020 15:22:12 +0100 Subject: [PATCH 20/43] Support toolbox custom "Tools install location", by reading .settings.json (cherry picked from commit 33af53c1a6b944924981575c016528b6a5b431aa) --- .../GodotTools/Ides/Rider/RiderPathLocator.cs | 78 ++++++++++++++----- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs index 9038333d389..5965e0fbcfa 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs @@ -11,6 +11,10 @@ using Environment = System.Environment; using File = System.IO.File; using Path = System.IO.Path; using OS = GodotTools.Utils.OS; +// ReSharper disable UnassignedField.Local +// ReSharper disable InconsistentNaming +// ReSharper disable UnassignedField.Global +// ReSharper disable MemberHidesStaticFromOuterClass namespace GodotTools.Ides.Rider { @@ -131,28 +135,45 @@ namespace GodotTools.Ides.Rider if (OS.IsWindows) { var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - return Path.Combine(localAppData, @"JetBrains\Toolbox\apps\Rider"); + return GetToolboxRiderRootPath(localAppData); } if (OS.IsOSX) { var home = Environment.GetEnvironmentVariable("HOME"); - if (!string.IsNullOrEmpty(home)) - { - return Path.Combine(home, @"Library/Application Support/JetBrains/Toolbox/apps/Rider"); - } + if (string.IsNullOrEmpty(home)) + return string.Empty; + var localAppData = Path.Combine(home, @"Library/Application Support"); + return GetToolboxRiderRootPath(localAppData); } if (OS.IsUnixLike()) { var home = Environment.GetEnvironmentVariable("HOME"); - if (!string.IsNullOrEmpty(home)) - { - return Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider"); - } + if (string.IsNullOrEmpty(home)) + return string.Empty; + var localAppData = Path.Combine(home, @".local/share"); + return GetToolboxRiderRootPath(localAppData); } - throw new Exception("Unexpected OS."); + return string.Empty; + } + + + private static string GetToolboxRiderRootPath(string localAppData) + { + var toolboxPath = Path.Combine(localAppData, @"JetBrains\Toolbox"); + var settingsJson = Path.Combine(toolboxPath, ".settings.json"); + + if (File.Exists(settingsJson)) + { + var path = SettingsJson.GetInstallLocationFromJson(File.ReadAllText(settingsJson)); + if (!string.IsNullOrEmpty(path)) + toolboxPath = path; + } + + var toolboxRiderRootPath = Path.Combine(toolboxPath, @"apps\Rider"); + return toolboxRiderRootPath; } internal static ProductInfo GetBuildVersion(string path) @@ -226,8 +247,8 @@ namespace GodotTools.Ides.Rider { try { - // use history.json - last entry stands for the active build https://jetbrains.slack.com/archives/C07KNP99D/p1547807024066500?thread_ts=1547731708.057700&cid=C07KNP99D - var historyFile = Path.Combine(channelDir, ".history.json"); + // use history.json - last entry stands for the active build https://jetbrains.slack.com/archives/C07KNP99D/p1547807024066500?thread_ts=1547731708.057700&cid=C07KNP99D + var historyFile = Path.Combine(channelDir, ".history.json"); if (File.Exists(historyFile)) { var json = File.ReadAllText(historyFile); @@ -255,14 +276,14 @@ namespace GodotTools.Ides.Rider } } - // changes in toolbox json files format may brake the logic above, so return all found Rider installations - return Directory.GetDirectories(channelDir) - .SelectMany(buildDir => GetExecutablePaths(dirName, searchPattern, isMac, buildDir)); + // changes in toolbox json files format may brake the logic above, so return all found Rider installations + return Directory.GetDirectories(channelDir) + .SelectMany(buildDir => GetExecutablePaths(dirName, searchPattern, isMac, buildDir)); } catch (Exception e) { - // do not write to Debug.Log, just log it. - Logger.Warn($"Failed to get RiderPath from {channelDir}", e); + // do not write to Debug.Log, just log it. + Logger.Warn($"Failed to get RiderPath from {channelDir}", e); } return new string[0]; @@ -288,6 +309,27 @@ namespace GodotTools.Ides.Rider // Note that Unity disable this warning in the generated C# projects #pragma warning disable 0649 + [Serializable] + class SettingsJson + { + public string install_location; + + [CanBeNull] + public static string GetInstallLocationFromJson(string json) + { + try + { + return JsonConvert.DeserializeObject(json).install_location; + } + catch (Exception) + { + Logger.Warn($"Failed to get install_location from json {json}"); + } + + return null; + } + } + [Serializable] class ToolboxHistory { @@ -372,7 +414,6 @@ namespace GodotTools.Ides.Rider [Serializable] class ActiveApplication { - // ReSharper disable once InconsistentNaming public List builds; } @@ -380,6 +421,7 @@ namespace GodotTools.Ides.Rider public struct RiderInfo { + // ReSharper disable once NotAccessedField.Global public bool IsToolbox; public string Presentation; public Version BuildNumber; From f0b63b47aae33a497c6444f32c6e90cf6670f6bb Mon Sep 17 00:00:00 2001 From: Ivan Shakhov Date: Wed, 26 Feb 2020 20:56:52 +0100 Subject: [PATCH 21/43] use Rider MSBuild on Windows, when Rider is selected as external editor (cherry picked from commit a9c2ab81cf09cc278c188385a5c801d002f9fc55) --- .../GodotTools/Build/MsBuildFinder.cs | 7 +++++ .../GodotTools/GodotTools/BuildManager.cs | 21 +++++++++----- .../GodotTools/Ides/Rider/RiderPathManager.cs | 28 +++++++++---------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs index c3db52aa9e1..af8d070cbd4 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using Godot; +using GodotTools.Ides.Rider; using GodotTools.Internals; using Directory = System.IO.Directory; using Environment = System.Environment; @@ -54,6 +55,12 @@ namespace GodotTools.Build return msbuildPath; } + case BuildManager.BuildTool.JetBrainsMsBuild: + var editorPath = (string)editorSettings.GetSetting(RiderPathManager.EditorPathSettingName); + if (!File.Exists(editorPath)) + throw new FileNotFoundException($"Cannot find Rider executable. Tried with path: {editorPath}"); + var riderDir = new FileInfo(editorPath).Directory.Parent; + return Path.Combine(riderDir.FullName, @"tools\MSBuild\Current\Bin\MSBuild.exe"); default: throw new IndexOutOfRangeException("Invalid build tool in editor settings"); } diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs index fa6bf4dafdb..69a8c9cf4a1 100644 --- a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using GodotTools.Build; +using GodotTools.Ides.Rider; using GodotTools.Internals; using GodotTools.Utils; using static GodotTools.Internals.Globals; @@ -16,6 +17,7 @@ namespace GodotTools public const string PropNameMsbuildMono = "MSBuild (Mono)"; public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)"; + public const string PropNameMsbuildJetBrains = "MSBuild (JetBrains Rider)"; public const string MsBuildIssuesFileName = "msbuild_issues.csv"; public const string MsBuildLogFileName = "msbuild_log.txt"; @@ -23,7 +25,8 @@ namespace GodotTools public enum BuildTool { MsBuildMono, - MsBuildVs + MsBuildVs, + JetBrainsMsBuild } private static void RemoveOldIssuesFile(BuildInfo buildInfo) @@ -181,7 +184,7 @@ namespace GodotTools var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, config); // Add Godot defines - string constants = buildTool == BuildTool.MsBuildVs ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\""; + string constants = buildTool != BuildTool.MsBuildMono ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\""; foreach (var godotDefine in godotDefines) constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};"; @@ -189,7 +192,7 @@ namespace GodotTools if (Internal.GodotIsRealTDouble()) constants += "GODOT_REAL_T_IS_DOUBLE;"; - constants += buildTool == BuildTool.MsBuildVs ? "\"" : "\\\""; + constants += buildTool != BuildTool.MsBuildMono ? "\"" : "\\\""; buildInfo.CustomProperties.Add(constants); @@ -245,18 +248,22 @@ namespace GodotTools public static void Initialize() { // Build tool settings - - EditorDef("mono/builds/build_tool", OS.IsWindows ? BuildTool.MsBuildVs : BuildTool.MsBuildMono); - var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); + var msbuild = BuildTool.MsBuildMono; + if (OS.IsWindows) + msbuild = RiderPathManager.IsRider((string) editorSettings.GetSetting(RiderPathManager.EditorPathSettingName)) + ? BuildTool.JetBrainsMsBuild + : BuildTool.MsBuildVs; + EditorDef("mono/builds/build_tool", msbuild); + editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { ["type"] = Godot.Variant.Type.Int, ["name"] = "mono/builds/build_tool", ["hint"] = Godot.PropertyHint.Enum, ["hint_string"] = OS.IsWindows ? - $"{PropNameMsbuildMono},{PropNameMsbuildVs}" : + $"{PropNameMsbuildMono},{PropNameMsbuildVs},{PropNameMsbuildJetBrains}" : $"{PropNameMsbuildMono}" }); diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs index 558a242bf96..ee5677a6a88 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs @@ -9,13 +9,13 @@ namespace GodotTools.Ides.Rider { public static class RiderPathManager { - private static readonly string editorPathSettingName = "mono/editor/editor_path_optional"; + public static readonly string EditorPathSettingName = "mono/editor/editor_path_optional"; private static string GetRiderPathFromSettings() { var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); - if (editorSettings.HasSetting(editorPathSettingName)) - return (string)editorSettings.GetSetting(editorPathSettingName); + if (editorSettings.HasSetting(EditorPathSettingName)) + return (string)editorSettings.GetSetting(EditorPathSettingName); return null; } @@ -25,22 +25,22 @@ namespace GodotTools.Ides.Rider var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor"); if (editor == ExternalEditorId.Rider) { - if (!editorSettings.HasSetting(editorPathSettingName)) + if (!editorSettings.HasSetting(EditorPathSettingName)) { - Globals.EditorDef(editorPathSettingName, "Optional"); + Globals.EditorDef(EditorPathSettingName, "Optional"); editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { ["type"] = Variant.Type.String, - ["name"] = editorPathSettingName, + ["name"] = EditorPathSettingName, ["hint"] = PropertyHint.File, ["hint_string"] = "" }); } - var riderPath = (string)editorSettings.GetSetting(editorPathSettingName); + var riderPath = (string)editorSettings.GetSetting(EditorPathSettingName); if (IsRiderAndExists(riderPath)) { - Globals.EditorDef(editorPathSettingName, riderPath); + Globals.EditorDef(EditorPathSettingName, riderPath); return; } @@ -50,17 +50,15 @@ namespace GodotTools.Ides.Rider return; var newPath = paths.Last().Path; - Globals.EditorDef(editorPathSettingName, newPath); - editorSettings.SetSetting(editorPathSettingName, newPath); + Globals.EditorDef(EditorPathSettingName, newPath); + editorSettings.SetSetting(EditorPathSettingName, newPath); } } - private static bool IsRider(string path) + public static bool IsRider(string path) { if (string.IsNullOrEmpty(path)) - { return false; - } var fileInfo = new FileInfo(path); var filename = fileInfo.Name.ToLowerInvariant(); @@ -81,8 +79,8 @@ namespace GodotTools.Ides.Rider return null; var newPath = paths.Last().Path; - editorSettings.SetSetting(editorPathSettingName, newPath); - Globals.EditorDef(editorPathSettingName, newPath); + editorSettings.SetSetting(EditorPathSettingName, newPath); + Globals.EditorDef(EditorPathSettingName, newPath); return newPath; } From 4e879ed8039d2567536692e795de9a34efe63682 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 27 Feb 2020 22:19:57 +0100 Subject: [PATCH 22/43] Improve documentation related to fixed physics processing (cherry picked from commit b89a37269b1d8f201604ea56d31e6c9fa3a26ce6) --- doc/classes/Engine.xml | 4 ++-- doc/classes/ProjectSettings.xml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 45c65915758..4e05cd6032b 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -147,10 +147,10 @@ If [code]true[/code], it is running inside the editor. Useful for tool scripts. - The number of fixed iterations per second (for fixed process and physics). + The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run. This value should generally always be set to [code]60[/code] or above, as Godot doesn't interpolate the physics step. As a result, values lower than [code]60[/code] will look stuttery. This value can be increased to make input more reactive or work around tunneling issues, but keep in mind doing so will increase CPU usage. - Controls how much physic ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows to smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. + Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows to smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 9d5de1bb104..e9aa79742da 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -956,10 +956,12 @@ Enables [member Viewport.physics_object_picking] on the root viewport. - Frames per second used in the physics. Physics always needs a fixed amount of frames per second. + The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run. + [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.iterations_per_second] instead. Fix to improve physics jitter, specially on monitors where refresh rate is different than the physics FPS. + [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.physics_jitter_fix] instead. Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method VisualServer.set_default_clear_color]. From 21a45dda7abdd6697ed1b9a123f4f5fd72e8dafb Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 27 Feb 2020 22:49:05 +0100 Subject: [PATCH 23/43] Improve the `@GDScript.inverse_lerp()` documentation This closes https://github.com/godotengine/godot-docs/issues/2589. (cherry picked from commit 6b5573700bdce09fcbe8b64ed6357af560efcd8d) --- modules/gdscript/doc_classes/@GDScript.xml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 258e94f909b..759aba9453d 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -490,9 +490,13 @@ - Returns a normalized value considering the given range. + Returns a normalized value considering the given range. This is the opposite of [method lerp]. [codeblock] - inverse_lerp(3, 5, 4) # Returns 0.5 + var middle = lerp(20, 30, 0.75) + # `middle` is now 27.5. + # Now, we pretend to have forgotten the original ratio and want to get it back. + var ratio = inverse_lerp(20, 30, 27.5) + # `ratio` is now 0.75. [/codeblock] @@ -567,7 +571,7 @@ - Linearly interpolates between two values by a normalized value. + Linearly interpolates between two values by a normalized value. This is the opposite of [method inverse_lerp]. If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float]. If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method). [codeblock] @@ -587,7 +591,7 @@ Linearly interpolates between two angles (in radians) by a normalized value. - Similar to [method lerp] but interpolate correctly when the angles wrap around [constant @GDScript.TAU]. + Similar to [method lerp], but interpolates correctly when the angles wrap around [constant @GDScript.TAU]. [codeblock] extends Sprite var elapsed = 0.0 From d679edfa7f194710985fe35ff63be318038a8497 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 27 Feb 2020 22:49:46 +0100 Subject: [PATCH 24/43] Add a practical example for `@GDScript.linear2db()` One of its most common applications in games is for volume sliders. See https://www.dr-lex.be/info-stuff/volumecontrols.html for more information. (cherry picked from commit a6fd6b78dd267d21ea30cc644d8aad10bc0f66ce) --- modules/gdscript/doc_classes/@GDScript.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 759aba9453d..304c72f086c 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -609,7 +609,13 @@ - Converts from linear energy to decibels (audio). + Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear). Example: + [codeblock] + # "Slider" refers to a node that inherits Range such as HSlider or VSlider. + # Its range must be configured to go from 0 to 1. + # Change the bus name if you'd like to change the volume of a specific bus only. + AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), linear2db($Slider.value)) + [/codeblock] From 367048030bdd6b35bde0b0d56c17dfe27565433e Mon Sep 17 00:00:00 2001 From: Richard Menzies Date: Thu, 27 Feb 2020 21:28:17 +0000 Subject: [PATCH 25/43] Fix wrong selection on cloning a line down in the editor (cherry picked from commit 28f74327beca86325cb8f8f9c7926a60ea83c826) --- editor/code_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index d0e69b7adc8..7818f854844 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1261,7 +1261,7 @@ void CodeTextEditor::clone_lines_down() { text_editor->cursor_set_line(cursor_new_line); text_editor->cursor_set_column(cursor_new_column); if (selection_active) { - text_editor->select(to_line, to_column, 2 * to_line - from_line, 2 * to_column - from_column); + text_editor->select(to_line, to_column, 2 * to_line - from_line, to_line == from_line ? 2 * to_column - from_column : to_column); } text_editor->end_complex_operation(); From 08cb8420f7498c01f56682c1a13101e88c1bde88 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 27 Feb 2020 23:00:58 +0100 Subject: [PATCH 26/43] Mention the `duration` parameter unit in `UPNP.add_port_mapping()` (cherry picked from commit 810be27c78752d593efa67714f7a006205b25a79) --- modules/upnp/doc_classes/UPNP.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml index b66428e1237..a4ce569866b 100644 --- a/modules/upnp/doc_classes/UPNP.xml +++ b/modules/upnp/doc_classes/UPNP.xml @@ -45,7 +45,7 @@ Adds a mapping to forward the external [code]port[/code] (between 1 and 65535) on the default gateway (see [method get_gateway]) to the [code]internal_port[/code] on the local machine for the given protocol [code]proto[/code] (either [code]TCP[/code] or [code]UDP[/code], with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with [method get_gateway] and call [method add_port_mapping] on it, if any. If [code]internal_port[/code] is [code]0[/code] (the default), the same port number is used for both the external and the internal port (the [code]port[/code] value). - The description ([code]desc[/code]) is shown in some router UIs and can be used to point out which application added the mapping, and the lifetime of the mapping can be limited by [code]duration[/code]. However, some routers are incompatible with one or both of these, so use with caution and add fallback logic in case of errors to retry without them if in doubt. + The description ([code]desc[/code]) is shown in some router UIs and can be used to point out which application added the mapping. The mapping's lease duration can be limited by specifying a [code]duration[/code] (in seconds). However, some routers are incompatible with one or both of these, so use with caution and add fallback logic in case of errors to retry without them if in doubt. See [enum UPNPResult] for possible return values. From a78bbcf8ce1b00f1a127a9249069fd7f91732ab8 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 27 Feb 2020 23:09:32 +0100 Subject: [PATCH 27/43] Improve the RegEx class documentation This closes https://github.com/godotengine/godot-docs/issues/2522. (cherry picked from commit 5b78f5c46458a93a5c0b2fc539fa79845d7d8762) --- modules/regex/doc_classes/RegEx.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml index 91987c99b77..6e9a2efb0b3 100644 --- a/modules/regex/doc_classes/RegEx.xml +++ b/modules/regex/doc_classes/RegEx.xml @@ -10,7 +10,7 @@ var regex = RegEx.new() regex.compile("\\w-(\\d+)") [/codeblock] - The search pattern must be escaped first for gdscript before it is escaped for the expression. For example, [code]compile("\\d+")[/code] would be read by RegEx as [code]\d+[/code]. Similarly, [code]compile("\"(?:\\\\.|[^\"])*\"")[/code] would be read as [code]"(?:\\.|[^"])*"[/code]. + The search pattern must be escaped first for GDScript before it is escaped for the expression. For example, [code]compile("\\d+")[/code] would be read by RegEx as [code]\d+[/code]. Similarly, [code]compile("\"(?:\\\\.|[^\"])*\"")[/code] would be read as [code]"(?:\\.|[^"])*"[/code]. Using [method search] you can find the pattern within the given text. If a pattern is found, [RegExMatch] is returned and you can retrieve details of the results using functions such as [method RegExMatch.get_string] and [method RegExMatch.get_start]. [codeblock] var regex = RegEx.new() @@ -35,6 +35,8 @@ # Would print 01 03 3f 42 # Note that d0c would not match [/codeblock] + [b]Note:[/b] Godot's regex implementation is based on the [url=https://www.pcre.org/]PCRE2[/url] library. You can view the full pattern reference [url=https://www.pcre.org/current/doc/html/pcre2pattern.html]here[/url]. + [b]Tip:[/b] You can use [url=https://regexr.com/]Regexr[/url] to test regular expressions online. From 119176660945086ed6224dd06411c53122b085bf Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 27 Feb 2020 23:33:31 +0100 Subject: [PATCH 28/43] doc: Mention concatenation using the `+` operator in Array This closes https://github.com/godotengine/godot-docs/issues/2452. (cherry picked from commit 8d5356295433c6b9c0a4431eb92523b63b0087b7) --- doc/classes/Array.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 89ad8e17db0..ca7ab36df43 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -14,6 +14,12 @@ array[2] = "Three" print(array[-2]) # Three. [/codeblock] + Arrays can be concatenated using the [code]+[/code] operator: + [codeblock] + var array1 = ["One", 2] + var array2 = [3, "Four"] + print(array1 + array2) # ["One", 2, 3, "Four"] + [/codeblock] Arrays are always passed by reference. From 867ea694dac10a33e8aa33f392a33e296311fd11 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Fri, 28 Feb 2020 00:03:55 -0300 Subject: [PATCH 29/43] Fix import changing disabling checking on multiple files (cherry picked from commit d35386263fcd5e0f92b2e676e3692ff3091dc2df) --- editor/import_dock.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 987082b1eca..410b8193c93 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -107,6 +107,9 @@ void ImportDock::set_edit_path(const String &p_path) { return; } + params->paths.clear(); + params->paths.push_back(p_path); + _update_options(config); List > importers; @@ -129,8 +132,6 @@ void ImportDock::set_edit_path(const String &p_path) { } } - params->paths.clear(); - params->paths.push_back(p_path); import->set_disabled(false); import_as->set_disabled(false); preset->set_disabled(false); @@ -145,7 +146,7 @@ void ImportDock::_update_options(const Ref &p_config) { params->properties.clear(); params->values.clear(); - params->checking = false; + params->checking = params->paths.size() > 1; params->checked.clear(); for (List::Element *E = options.front(); E; E = E->next()) { From 621c20db90b974eb11ac86bd72517da30f301cb9 Mon Sep 17 00:00:00 2001 From: simpuid Date: Sat, 29 Feb 2020 08:55:28 +0530 Subject: [PATCH 30/43] Implement undo-redo feature for Parameter Paste in the Inspector EditorData::undo_redo.add_do_property and EditorData::undo_redo.add_undo_property is used in EditorData::paste_object_params to implement this feature. It's action name is set to "Paste Params" Changes made * Removed the call for clearing the history on paste params case. * Instead of directly setting the properties value, EditorData::undo_redo is used. (cherry picked from commit f817ba83795ed4a8a44e569cce58bc37522860c0) --- editor/editor_data.cpp | 8 ++++++-- editor/inspector_dock.cpp | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 0b43fd5ac09..01cc23aaa29 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -435,10 +435,14 @@ void EditorData::restore_editor_global_states() { void EditorData::paste_object_params(Object *p_object) { + ERR_FAIL_NULL(p_object); + undo_redo.create_action(TTR("Paste Params")); for (List::Element *E = clipboard.front(); E; E = E->next()) { - - p_object->set(E->get().name, E->get().value); + String name = E->get().name; + undo_redo.add_do_property(p_object, name, E->get().value); + undo_redo.add_undo_property(p_object, name, p_object->get(name)); } + undo_redo.commit_action(); } bool EditorData::call_build() { diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index b65482cc6bb..902ebd3d466 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -76,7 +76,6 @@ void InspectorDock::_menu_option(int p_option) { editor_data->apply_changes_in_editors(); if (current) editor_data->paste_object_params(current); - editor_data->get_undo_redo().clear_history(); } break; case OBJECT_UNIQUE_RESOURCES: { From cbeb22eb73637f17c735d0b1d7377c036ddb7814 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Sun, 1 Mar 2020 09:52:37 +0300 Subject: [PATCH 31/43] Fix InputEventKey::echo type from INT to BOOL (cherry picked from commit 5e3c64828aacc8e166a74e3a8df0cecd408a25ef) --- core/os/input_event.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 2e863c9c765..9878dd41c4e 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -348,7 +348,7 @@ void InputEventKey::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); ADD_PROPERTY(PropertyInfo(Variant::INT, "scancode"), "set_scancode", "get_scancode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "echo"), "set_echo", "is_echo"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo"); } InputEventKey::InputEventKey() { From 447acafa970841971ff60d57491811a004aca690 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Mon, 2 Mar 2020 16:26:29 +0100 Subject: [PATCH 32/43] Fix missing null check in Mono Binding of GD.print (cherry picked from commit 6b9c22542f6948592dd3007e61b6fe0aaa51f62f) --- modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index 19962d418a4..2a9c2d73b14 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -83,7 +83,7 @@ namespace Godot public static void Print(params object[] what) { - godot_icall_GD_print(Array.ConvertAll(what, x => x.ToString())); + godot_icall_GD_print(Array.ConvertAll(what, x => x?.ToString())); } public static void PrintStack() From 7de67f6c48177b350d04e04b98269bdf1332e330 Mon Sep 17 00:00:00 2001 From: fhuya Date: Mon, 2 Mar 2020 10:53:05 -0500 Subject: [PATCH 33/43] Fix android template install validation. (cherry picked from commit 5b80dc9a2ad6425533107f04ab0696f2c229baf2) --- editor/export_template_manager.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index cb636f8cdcc..45b132e481d 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -547,9 +547,7 @@ void ExportTemplateManager::_notification(int p_what) { bool ExportTemplateManager::can_install_android_template() { const String templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG); - return FileAccess::exists(templates_dir.plus_file("android_source.zip")) && - FileAccess::exists(templates_dir.plus_file("android_release.apk")) && - FileAccess::exists(templates_dir.plus_file("android_debug.apk")); + return FileAccess::exists(templates_dir.plus_file("android_source.zip")); } Error ExportTemplateManager::install_android_template() { From d6c94fd5270beaf892987fb40723f7bfe82641e7 Mon Sep 17 00:00:00 2001 From: "Mateo Dev .59" Date: Wed, 19 Feb 2020 15:59:37 -0300 Subject: [PATCH 34/43] os: execute parse the command output from utf8 (cherry picked from commit 8a88637705ecf58a069b3ea631fee8501fd8e6f4) --- drivers/unix/os_unix.cpp | 2 +- platform/windows/os_windows.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index c5eb343cc84..9a535c4f2eb 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -310,7 +310,7 @@ Error OS_Unix::execute(const String &p_path, const List &p_arguments, bo if (p_pipe_mutex) { p_pipe_mutex->lock(); } - (*r_pipe) += buf; + (*r_pipe) += String::utf8(buf); if (p_pipe_mutex) { p_pipe_mutex->unlock(); } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index a6977a7a86d..118deb90584 100755 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2713,7 +2713,7 @@ Error OS_Windows::execute(const String &p_path, const List &p_arguments, if (p_pipe_mutex) { p_pipe_mutex->lock(); } - (*r_pipe) += buf; + (*r_pipe) += String::utf8(buf); if (p_pipe_mutex) { p_pipe_mutex->unlock(); } From 4bf0c52a30519ea639bbf0557c698debbe758567 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Mon, 24 Feb 2020 18:37:46 +0300 Subject: [PATCH 35/43] Minor fix in Node class documentation The name of the property responsible for physics fps is fixed: this is `Engine.iterations_per_second`, not `Engine.target_fps`. (cherry picked from commit 6e5cd36b12b535f31a2b453c39723a77adc182ed) --- doc/classes/Node.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 04d3fc42352..36908ab1316 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -326,7 +326,7 @@ - Returns the time elapsed since the last physics-bound frame (see [method _physics_process]). This is always a constant value in physics processing unless the frames per second is changed via [member Engine.target_fps]. + Returns the time elapsed since the last physics-bound frame (see [method _physics_process]). This is always a constant value in physics processing unless the frames per second is changed via [member Engine.iterations_per_second]. @@ -745,7 +745,7 @@ - Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a [constant NOTIFICATION_PHYSICS_PROCESS] at a fixed (usually 60 FPS, see [member Engine.target_fps] to change) interval (and the [method _physics_process] callback will be called if exists). Enabled automatically if [method _physics_process] is overridden. Any calls to this before [method _ready] will be ignored. + Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a [constant NOTIFICATION_PHYSICS_PROCESS] at a fixed (usually 60 FPS, see [member Engine.iterations_per_second] to change) interval (and the [method _physics_process] callback will be called if exists). Enabled automatically if [method _physics_process] is overridden. Any calls to this before [method _ready] will be ignored. From fa60e77964f54f58b34eba7a02626715d4435362 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 3 Mar 2020 03:18:52 -0500 Subject: [PATCH 36/43] Document that SpringArm exclusions only work with PhysicsBody objects (cherry picked from commit d96166370725b81527d1783f58d5cd7686608a28) --- doc/classes/SpringArm.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/classes/SpringArm.xml b/doc/classes/SpringArm.xml index bcab90279c4..f72156b3ade 100644 --- a/doc/classes/SpringArm.xml +++ b/doc/classes/SpringArm.xml @@ -18,14 +18,14 @@ - Adds the object with the given [RID] to the list of objects excluded from the collision check. + Adds the [PhysicsBody] object with the given [RID] to the list of [PhysicsBody] objects excluded from the collision check. - Clears the list of objects excluded from the collision check. + Clears the list of [PhysicsBody] objects excluded from the collision check. @@ -41,7 +41,7 @@ - Removes the given [RID] from the list of objects excluded from the collision check. + Removes the given [RID] from the list of [PhysicsBody] objects excluded from the collision check. From 88f0cd0b2744c0453d75c5c1289581f68b5587be Mon Sep 17 00:00:00 2001 From: Ivan Shakhov Date: Fri, 28 Feb 2020 21:34:20 +0100 Subject: [PATCH 37/43] On Windows find Rider installed for CurrentUser (cherry picked from commit c95e20a089b7ef1bcc2bd0955bbb7504fdd5729f) --- .../GodotTools/Ides/Rider/RiderPathLocator.cs | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs index 5965e0fbcfa..77740f0e536 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs @@ -218,20 +218,29 @@ namespace GodotTools.Ides.Rider private static void CollectPathsFromRegistry(string registryKey, List installPaths) { + using (var key = Registry.CurrentUser.OpenSubKey(registryKey)) + { + CollectPathsFromRegistry(installPaths, key); + } using (var key = Registry.LocalMachine.OpenSubKey(registryKey)) { - if (key == null) return; - foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider"))) + CollectPathsFromRegistry(installPaths, key); + } + } + + private static void CollectPathsFromRegistry(List installPaths, RegistryKey key) + { + if (key == null) return; + foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider"))) + { + using (var subkey = key.OpenSubKey(subkeyName)) { - using (var subkey = key.OpenSubKey(subkeyName)) - { - var folderObject = subkey?.GetValue("InstallLocation"); - if (folderObject == null) continue; - var folder = folderObject.ToString(); - var possiblePath = Path.Combine(folder, @"bin\rider64.exe"); - if (File.Exists(possiblePath)) - installPaths.Add(possiblePath); - } + var folderObject = subkey?.GetValue("InstallLocation"); + if (folderObject == null) continue; + var folder = folderObject.ToString(); + var possiblePath = Path.Combine(folder, @"bin\rider64.exe"); + if (File.Exists(possiblePath)) + installPaths.Add(possiblePath); } } } From a2bc4f0b3057fead94bdc3a0b243e0784489d800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=27dreamsComeTrue=27=20Jasi=C5=84ski?= Date: Sun, 1 Mar 2020 09:44:48 +0100 Subject: [PATCH 38/43] Take correct part of extension with File Dialog Fixes #36697 (cherry picked from commit 319840bad1754ce33ec60000df7972e73401860d) --- editor/editor_file_dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 625f46f9d3c..c148b134de1 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -691,7 +691,7 @@ void EditorFileDialog::update_file_name() { String base_name = file_str.get_basename(); Vector filter_substr = filter_str.split(";"); if (filter_substr.size() >= 2) { - file_str = base_name + "." + filter_substr[1].strip_edges().to_lower(); + file_str = base_name + "." + filter_substr[0].strip_edges().lstrip("*.").to_lower(); } else { file_str = base_name + "." + filter_str.get_extension().strip_edges().to_lower(); } From 031aed3bb77a46df16be0789769340b1c68e2735 Mon Sep 17 00:00:00 2001 From: Christoph Schroeder Date: Wed, 26 Feb 2020 12:03:49 +0100 Subject: [PATCH 39/43] Fixes touch events for HTML Without this patch, the following exception is thrown when the touch screen is used: TypeError: e.getBoundingClientRect is not a function. No touch events arrive in the engine. From my testing, this PR fixes the issue and behaves as expected. Tested with godot-demo-projects/misc/multitouch_view/, emscripten 1.39.8 and Firefox mobile emulator as well as FF on Android (cherry picked from commit 5134317afc8cbb1f51b29e9862c19d4f54d3a1d9) --- platform/javascript/os_javascript.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index d904cc3c961..f9c75cd1b37 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -1012,10 +1012,10 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, mousedown, mouse_button_callback) SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, mouseup, mouse_button_callback) SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, wheel, wheel_callback) - SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchstart, touch_press_callback) - SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchmove, touchmove_callback) - SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchend, touch_press_callback) - SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, touchcancel, touch_press_callback) + SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchstart, touch_press_callback) + SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchmove, touchmove_callback) + SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchend, touch_press_callback) + SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchcancel, touch_press_callback) SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, keydown, keydown_callback) SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, keypress, keypress_callback) SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, keyup, keyup_callback) From 0ab8889c0d245de0ff0a6c5b985d2a671dfaf8ac Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Thu, 27 Feb 2020 22:09:23 +1100 Subject: [PATCH 40/43] Exposing get_tracker_id for ARVRPositionalTracker to GDScript (cherry picked from commit f0b1edef8b5e3751caae6b1bc8fadf004c1578a9) --- doc/classes/ARVRPositionalTracker.xml | 7 +++++++ servers/arvr/arvr_positional_tracker.cpp | 1 + 2 files changed, 8 insertions(+) diff --git a/doc/classes/ARVRPositionalTracker.xml b/doc/classes/ARVRPositionalTracker.xml index a281d02be1b..3255ad9bccb 100644 --- a/doc/classes/ARVRPositionalTracker.xml +++ b/doc/classes/ARVRPositionalTracker.xml @@ -54,6 +54,13 @@ Returns the world-space controller position. + + + + + Returns the internal tracker ID. This uniquely identifies the tracker per tracker type and matches the ID you need to specify for nodes such as the [ARVRController] and [ARVRAnchor] nodes. + + diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp index 4438475d441..fc473c1fc8f 100644 --- a/servers/arvr/arvr_positional_tracker.cpp +++ b/servers/arvr/arvr_positional_tracker.cpp @@ -38,6 +38,7 @@ void ARVRPositionalTracker::_bind_methods() { // this class is read only from GDScript, so we only have access to getters.. ClassDB::bind_method(D_METHOD("get_type"), &ARVRPositionalTracker::get_type); + ClassDB::bind_method(D_METHOD("get_tracker_id"), &ARVRPositionalTracker::get_tracker_id); ClassDB::bind_method(D_METHOD("get_name"), &ARVRPositionalTracker::get_name); ClassDB::bind_method(D_METHOD("get_joy_id"), &ARVRPositionalTracker::get_joy_id); ClassDB::bind_method(D_METHOD("get_tracks_orientation"), &ARVRPositionalTracker::get_tracks_orientation); From 1350c1371ef337c50dc4b770d8e478a276860925 Mon Sep 17 00:00:00 2001 From: Pierre Caye Date: Fri, 28 Feb 2020 15:56:06 +0100 Subject: [PATCH 41/43] add a precision about the intended use of the ConcavePolygonShape (cherry picked from commit 222a934e608640c598cc0f99780a74d66b5ac556) --- doc/classes/ConcavePolygonShape.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/classes/ConcavePolygonShape.xml b/doc/classes/ConcavePolygonShape.xml index 6c9872f2666..f5d40fc9d5b 100644 --- a/doc/classes/ConcavePolygonShape.xml +++ b/doc/classes/ConcavePolygonShape.xml @@ -5,6 +5,7 @@ Concave polygon shape resource, which can be set into a [PhysicsBody] or area. This shape is created by feeding a list of triangles. + Note: when used for collision, [ConcavePolygonShape] is intended to work with static [PhysicsBody] nodes like [StaticBody] and will not work with [KinematicBody] or [RigidBody] with a mode other than Static. From c34b351b241dcae10ace3a819d73240b88078b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 20 Feb 2020 11:09:20 +0100 Subject: [PATCH 42/43] SCons: Explicitly define our C (C11) and C++ (C++14) standards On GCC and Clang, we use C11 and C++14 with GNU extensions (`std=gnu11` and `std=gnu++14`). Those are the defaults for current GCC and Clang, and also match the feature sets we want to use in Godot. On MSVC, we require C++14 support explicitly with `/std:c++14`, and make it strict with the use of `/permissive-` (so features of C++17 or later can't be used). Moves the definition before querying environment flags and platform config so that it can be overridden when necessary. (cherry picked from commit 342f127362108bfb0fb954c9150b5a937ecfef30) --- SConstruct | 18 +++++++++++++++--- platform/android/detect.py | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 6703038bedf..3b7746527f8 100644 --- a/SConstruct +++ b/SConstruct @@ -291,6 +291,7 @@ if selected_platform in platform_list: if env["extra_suffix"] != '': env.extra_suffix += '.' + env["extra_suffix"] + # Environment flags CCFLAGS = env.get('CCFLAGS', '') env['CCFLAGS'] = '' env.Append(CCFLAGS=str(CCFLAGS).split()) @@ -307,17 +308,28 @@ if selected_platform in platform_list: env['LINKFLAGS'] = '' env.Append(LINKFLAGS=str(LINKFLAGS).split()) + # Platform specific flags flag_list = platform_flags[selected_platform] for f in flag_list: if not (f[0] in ARGUMENTS): # allow command line to override platform flags env[f[0]] = f[1] - # must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11) + # Must happen after the flags definition, so that they can be used by platform detect detect.configure(env) - # Enable C++11 support + # Set our C and C++ standard requirements. + # Prepending to make it possible to override + # This needs to come after `configure`, otherwise we don't have env.msvc. if not env.msvc: - env.Append(CXXFLAGS=['-std=c++11']) + # Specifying GNU extensions support explicitly, which are supported by + # both GCC and Clang. This mirrors GCC and Clang's current default + # compile flags if no -std is specified. + env.Prepend(CFLAGS=['-std=gnu11']) + env.Prepend(CXXFLAGS=['-std=gnu++14']) + else: + # MSVC doesn't have clear C standard support, /std only covers C++. + # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features. + env.Prepend(CCFLAGS=['/std:c++14']) # Configure compiler warnings if env.msvc: diff --git a/platform/android/detect.py b/platform/android/detect.py index 8b62360888e..8f74ae0ef09 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -205,7 +205,6 @@ def configure(env): env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"]) env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"]) - env.Append(CXXFLAGS=["-std=gnu++14"]) # Disable exceptions and rtti on non-tools (template) builds if env['tools']: From 75164169c43f6dcef237ac9a7bf842598f5f20f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 26 Feb 2020 13:23:37 +0100 Subject: [PATCH 43/43] SCons: Fix get_compiler_version() to return ints Otherwise comparisons would fail for compiler versions above 10. Also simplified code somewhat to avoid using subprocess too much needlessly. (cherry picked from commits c7dc5142b56b3f52ba9c2746eb4855fae68ed26e and df7ecfc4a7f8403144be2aa49bb47f9ead25926b) --- SConstruct | 8 ++++---- methods.py | 24 ++++++++++++++++-------- platform/x11/detect.py | 7 +++---- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/SConstruct b/SConstruct index 3b7746527f8..39c34737dad 100644 --- a/SConstruct +++ b/SConstruct @@ -350,12 +350,13 @@ if selected_platform in platform_list: # Force to use Unicode encoding env.Append(MSVC_FLAGS=['/utf8']) else: # Rest of the world + version = methods.get_compiler_version(env) or [-1, -1] + shadow_local_warning = [] all_plus_warnings = ['-Wwrite-strings'] if methods.using_gcc(env): - version = methods.get_compiler_version(env) - if version != None and version[0] >= '7': + if version[0] >= 7: shadow_local_warning = ['-Wshadow-local'] if (env["warnings"] == 'extra'): @@ -369,8 +370,7 @@ if selected_platform in platform_list: '-Wduplicated-branches', '-Wduplicated-cond', '-Wstringop-overflow=4', '-Wlogical-op']) env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1']) - version = methods.get_compiler_version(env) - if version != None and version[0] >= '9': + if version[0] >= 9: env.Append(CCFLAGS=['-Wattribute-alias=2']) elif (env["warnings"] == 'all'): env.Append(CCFLAGS=['-Wall'] + shadow_local_warning) diff --git a/methods.py b/methods.py index 33b8f1cbe75..6b97acf822b 100644 --- a/methods.py +++ b/methods.py @@ -1,5 +1,4 @@ import os -import os.path import re import glob import subprocess @@ -626,14 +625,23 @@ def detect_darwin_sdk_path(platform, env): raise def get_compiler_version(env): - # Not using this method on clang because it returns 4.2.1 # https://reviews.llvm.org/D56803 - if using_gcc(env): - version = decode_utf8(subprocess.check_output([env['CXX'], '-dumpversion']).strip()) - else: - version = decode_utf8(subprocess.check_output([env['CXX'], '--version']).strip()) - match = re.search('[0-9][0-9.]*', version) + """ + Returns an array of version numbers as ints: [major, minor, patch]. + The return array should have at least two values (major, minor). + """ + if not env.msvc: + # Not using -dumpversion as some GCC distros only return major, and + # Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803 + try: + version = decode_utf8(subprocess.check_output([env.subst(env['CXX']), '--version']).strip()) + except (subprocess.CalledProcessError, OSError): + print("Couldn't parse CXX environment variable to infer compiler version.") + return None + else: # TODO: Implement for MSVC + return None + match = re.search('[0-9]+\.[0-9.]+', version) if match is not None: - return match.group().split('.') + return list(map(int, match.group().split('.'))) else: return None diff --git a/platform/x11/detect.py b/platform/x11/detect.py index bd5e5e08124..b471ff53d18 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -180,15 +180,14 @@ def configure(env): env.Append(LINKFLAGS=['-pipe']) # Check for gcc version >= 6 before adding -no-pie + version = get_compiler_version(env) or [-1, -1] if using_gcc(env): - version = get_compiler_version(env) - if version != None and version[0] >= '6': + if version[0] >= 6: env.Append(CCFLAGS=['-fpie']) env.Append(LINKFLAGS=['-no-pie']) # Do the same for clang should be fine with Clang 4 and higher if using_clang(env): - version = get_compiler_version(env) - if version != None and version[0] >= '4': + if version[0] >= 4: env.Append(CCFLAGS=['-fpie']) env.Append(LINKFLAGS=['-no-pie'])