diff --git a/SConstruct b/SConstruct index 6703038bedf..39c34737dad 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: @@ -338,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'): @@ -357,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/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/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 == '_') { 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() { 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/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/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. 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. 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/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. 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/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. 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]. 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. 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/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); 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(); 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_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/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(); } 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; } 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 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() { 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; 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/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); 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()) { 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: { 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.")); 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); 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/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; diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 258e94f909b..304c72f086c 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 @@ -605,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] 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/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs index 9038333d389..77740f0e536 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) @@ -197,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); } } } @@ -226,8 +256,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 +285,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 +318,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 +423,6 @@ namespace GodotTools.Ides.Rider [Serializable] class ActiveApplication { - // ReSharper disable once InconsistentNaming public List builds; } @@ -380,6 +430,7 @@ namespace GodotTools.Ides.Rider public struct RiderInfo { + // ReSharper disable once NotAccessedField.Global public bool IsToolbox; public string Presentation; public Version BuildNumber; 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; } 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() 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. 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++; 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. 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/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']: 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++) { 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) 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(); } 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']) 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; 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/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; } 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); 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); } 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); } 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; } 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()); 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);