diff options
28 files changed, 329 insertions, 270 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index 89ba73b35e..dc3fe29dca 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -146,6 +146,10 @@ bool OS::is_stdout_verbose() const { return _verbose_stdout; } +bool OS::is_single_window() const { + return _single_window; +} + bool OS::is_stdout_debug_enabled() const { return _debug_stdout; } diff --git a/core/os/os.h b/core/os/os.h index 55b21266fc..f585483300 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -52,6 +52,7 @@ class OS { int low_processor_usage_mode_sleep_usec = 10000; bool _verbose_stdout = false; bool _debug_stdout = false; + bool _single_window = false; String _local_clipboard; int _exit_code = EXIT_FAILURE; // unexpected exit is marked as failure int _orientation; @@ -224,6 +225,8 @@ public: void set_stdout_enabled(bool p_enabled); void set_stderr_enabled(bool p_enabled); + bool is_single_window() const; + virtual void disable_crash_handler() {} virtual bool is_disable_crash_handler() const { return false; } virtual void initialize_debugging() {} diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 25250e231e..4ad45f9649 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -70,6 +70,7 @@ void EditorCommandPalette::_update_command_search(const String &search_text) { r.key_name = command_keys[i]; r.display_name = commands[r.key_name].name; r.shortcut_text = commands[r.key_name].shortcut; + r.last_used = commands[r.key_name].last_used; if (search_text.is_subsequence_ofi(r.display_name)) { if (!search_text.is_empty()) { @@ -94,6 +95,9 @@ void EditorCommandPalette::_update_command_search(const String &search_text) { if (!search_text.is_empty()) { SortArray<CommandEntry, CommandEntryComparator> sorter; sorter.sort(entries.ptrw(), entries.size()); + } else { + SortArray<CommandEntry, CommandHistoryComparator> sorter; + sorter.sort(entries.ptrw(), entries.size()); } const int entry_limit = MIN(entries.size(), 300); @@ -213,7 +217,9 @@ void EditorCommandPalette::_add_command(String p_command_name, String p_key_name void EditorCommandPalette::execute_command(String &p_command_key) { ERR_FAIL_COND_MSG(!commands.has(p_command_key), p_command_key + " not found."); + commands[p_command_key].last_used = OS::get_singleton()->get_unix_time(); commands[p_command_key].callable.call_deferred(nullptr, 0); + _save_history(); } void EditorCommandPalette::register_shortcuts_as_command() { @@ -230,6 +236,14 @@ void EditorCommandPalette::register_shortcuts_as_command() { key = unregistered_shortcuts.next(key); } unregistered_shortcuts.clear(); + + // Load command use history. + Dictionary command_history = EditorSettings::get_singleton()->get_project_metadata("command_palette", "command_history", Dictionary()); + Array history_entries = command_history.keys(); + for (int i = 0; i < history_entries.size(); i++) { + const String &history_key = history_entries[i]; + commands[history_key].last_used = command_history[history_key]; + } } Ref<Shortcut> EditorCommandPalette::add_shortcut_command(const String &p_command, const String &p_key, Ref<Shortcut> p_shortcut) { @@ -252,6 +266,19 @@ void EditorCommandPalette::_theme_changed() { command_search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); } +void EditorCommandPalette::_save_history() const { + Dictionary command_history; + List<String> command_keys; + commands.get_key_list(&command_keys); + + for (const String &key : command_keys) { + if (commands[key].last_used > 0) { + command_history[key] = commands[key].last_used; + } + } + EditorSettings::get_singleton()->set_project_metadata("command_palette", "command_history", command_history); +} + EditorCommandPalette *EditorCommandPalette::get_singleton() { if (singleton == nullptr) { singleton = memnew(EditorCommandPalette); diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h index 093f4b797d..39821a1169 100644 --- a/editor/editor_command_palette.h +++ b/editor/editor_command_palette.h @@ -47,13 +47,15 @@ class EditorCommandPalette : public ConfirmationDialog { Callable callable; String name; String shortcut; + int last_used = 0; // Store time as int, because doubles have problems with text serialization. }; struct CommandEntry { String key_name; String display_name; String shortcut_text; - float score; + int last_used = 0; + float score = 0; }; struct CommandEntryComparator { @@ -62,6 +64,12 @@ class EditorCommandPalette : public ConfirmationDialog { } }; + struct CommandHistoryComparator { + _FORCE_INLINE_ bool operator()(const CommandEntry &A, const CommandEntry &B) const { + return A.last_used > B.last_used; + } + }; + HashMap<String, Command> commands; HashMap<String, Pair<String, Ref<Shortcut>>> unregistered_shortcuts; @@ -74,6 +82,7 @@ class EditorCommandPalette : public ConfirmationDialog { void _update_command_keys(); void _add_command(String p_command_name, String p_key_name, Callable p_binded_action, String p_shortcut_text = "None"); void _theme_changed(); + void _save_history() const; EditorCommandPalette(); protected: diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 6bbf0f965e..7631e425e8 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -815,6 +815,19 @@ void EditorProperty::unhandled_key_input(const Ref<InputEvent> &p_event) { } } +const Color *EditorProperty::_get_property_colors() { + const Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const float saturation = base.get_s() * 0.75; + const float value = base.get_v(); + + static Color c[4]; + c[0].set_hsv(0.0 / 3.0 + 0.05, saturation, value); + c[1].set_hsv(1.0 / 3.0 + 0.05, saturation, value); + c[2].set_hsv(2.0 / 3.0 + 0.05, saturation, value); + c[3].set_hsv(1.5 / 3.0 + 0.05, saturation, value); + return c; +} + void EditorProperty::set_label_reference(Control *p_control) { label_reference = p_control; } diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 5992c23f8c..b71efe8f19 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -123,6 +123,7 @@ protected: virtual void gui_input(const Ref<InputEvent> &p_event) override; virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; + const Color *_get_property_colors(); public: void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index cf4f8c0b7d..9c7f80b2b0 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -524,6 +524,26 @@ void EditorNode::_update_from_settings() { RS::get_singleton()->light_projectors_set_filter(RS::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter")))); } +void EditorNode::_select_default_main_screen_plugin() { + if (EDITOR_3D < main_editor_buttons.size() && main_editor_buttons[EDITOR_3D]->is_visible()) { + // If the 3D editor is enabled, use this as the default. + _editor_select(EDITOR_3D); + return; + } + + // Switch to the first main screen plugin that is enabled. Usually this is + // 2D, but may be subsequent ones if 2D is disabled in the feature profile. + for (int i = 0; i < main_editor_buttons.size(); i++) { + Button *editor_button = main_editor_buttons[i]; + if (editor_button->is_visible()) { + _editor_select(i); + return; + } + } + + _editor_select(-1); +} + void EditorNode::_notification(int p_what) { switch (p_what) { case NOTIFICATION_PROCESS: { @@ -613,11 +633,7 @@ void EditorNode::_notification(int p_what) { feature_profile_manager->notify_changed(); - if (!main_editor_buttons[EDITOR_3D]->is_visible()) { //may be hidden due to feature profile - _editor_select(EDITOR_2D); - } else { - _editor_select(EDITOR_3D); - } + _select_default_main_screen_plugin(); // Save the project after opening to mark it as last modified, except in headless mode. if (DisplayServer::get_singleton()->window_can_draw()) { @@ -3100,9 +3116,10 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_flat(true); tb->set_toggle_mode(true); tb->connect("pressed", callable_mp(singleton, &EditorNode::_editor_select), varray(singleton->main_editor_buttons.size())); + tb->set_name(p_editor->get_name()); tb->set_text(p_editor->get_name()); - Ref<Texture2D> icon = p_editor->get_icon(); + Ref<Texture2D> icon = p_editor->get_icon(); if (icon.is_valid()) { tb->set_icon(icon); } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), "EditorIcons")) { @@ -3112,7 +3129,6 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->add_theme_font_override("font", singleton->gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); - tb->set_name(p_editor->get_name()); singleton->main_editor_buttons.push_back(tb); singleton->main_editor_button_vb->add_child(tb); singleton->editor_table.push_back(p_editor); diff --git a/editor/editor_node.h b/editor/editor_node.h index 488957b1df..2e8b850c7b 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -32,7 +32,6 @@ #define EDITOR_NODE_H #include "core/templates/safe_refcount.h" -#include "editor/editor_command_palette.h" #include "editor/editor_data.h" #include "editor/editor_export.h" #include "editor/editor_folding.h" @@ -682,6 +681,8 @@ private: bool immediate_dialog_confirmed = false; void _immediate_dialog_confirmed(); + void _select_default_main_screen_plugin(); + protected: void _notification(int p_what); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 73ea4fb5ef..5baffb6f9d 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -30,6 +30,7 @@ #include "editor_plugin.h" +#include "editor/editor_command_palette.h" #include "editor/editor_export.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 1729705be5..c1e60e141c 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1510,11 +1510,9 @@ void EditorPropertyVector2::update_property() { void EditorPropertyVector2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 2; i++) { - Color c = base; - c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i]); } } } @@ -1603,11 +1601,9 @@ void EditorPropertyRect2::update_property() { void EditorPropertyRect2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { - Color c = base; - c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i % 2]); } } } @@ -1731,11 +1727,9 @@ Vector3 EditorPropertyVector3::get_vector() { void EditorPropertyVector3::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 3; i++) { - Color c = base; - c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i]); } } } @@ -1820,11 +1814,9 @@ void EditorPropertyVector2i::update_property() { void EditorPropertyVector2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 2; i++) { - Color c = base; - c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i]); } } } @@ -1913,11 +1905,9 @@ void EditorPropertyRect2i::update_property() { void EditorPropertyRect2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { - Color c = base; - c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i % 2]); } } } @@ -2014,11 +2004,9 @@ void EditorPropertyVector3i::update_property() { void EditorPropertyVector3i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 3; i++) { - Color c = base; - c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i]); } } } @@ -2106,11 +2094,9 @@ void EditorPropertyPlane::update_property() { void EditorPropertyPlane::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - for (int i = 0; i < 3; i++) { - Color c = base; - c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + const Color *colors = _get_property_colors(); + for (int i = 0; i < 4; i++) { + spin[i]->set_custom_label_color(true, colors[i]); } } } @@ -2199,11 +2185,9 @@ void EditorPropertyQuaternion::update_property() { void EditorPropertyQuaternion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - for (int i = 0; i < 3; i++) { - Color c = base; - c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + const Color *colors = _get_property_colors(); + for (int i = 0; i < 4; i++) { + spin[i]->set_custom_label_color(true, colors[i]); } } } @@ -2295,11 +2279,9 @@ void EditorPropertyAABB::update_property() { void EditorPropertyAABB::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 6; i++) { - Color c = base; - c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i % 3]); } } } @@ -2354,10 +2336,10 @@ void EditorPropertyTransform2D::_value_changed(double val, const String &p_name) Transform2D p; p[0][0] = spin[0]->get_value(); - p[0][1] = spin[1]->get_value(); - p[1][0] = spin[2]->get_value(); - p[1][1] = spin[3]->get_value(); - p[2][0] = spin[4]->get_value(); + p[1][0] = spin[1]->get_value(); + p[2][0] = spin[2]->get_value(); + p[0][1] = spin[3]->get_value(); + p[1][1] = spin[4]->get_value(); p[2][1] = spin[5]->get_value(); emit_changed(get_edited_property(), p, p_name); @@ -2367,10 +2349,10 @@ void EditorPropertyTransform2D::update_property() { Transform2D val = get_edited_object()->get(get_edited_property()); setting = true; spin[0]->set_value(val[0][0]); - spin[1]->set_value(val[0][1]); - spin[2]->set_value(val[1][0]); - spin[3]->set_value(val[1][1]); - spin[4]->set_value(val[2][0]); + spin[1]->set_value(val[1][0]); + spin[2]->set_value(val[2][0]); + spin[3]->set_value(val[0][1]); + spin[4]->set_value(val[1][1]); spin[5]->set_value(val[2][1]); setting = false; @@ -2378,11 +2360,14 @@ void EditorPropertyTransform2D::update_property() { void EditorPropertyTransform2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 6; i++) { - Color c = base; - c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + // For Transform2D, use the 4th color (cyan) for the origin vector. + if (i % 3 == 2) { + spin[i]->set_custom_label_color(true, colors[3]); + } else { + spin[i]->set_custom_label_color(true, colors[i % 3]); + } } } } @@ -2402,17 +2387,19 @@ void EditorPropertyTransform2D::setup(double p_min, double p_max, double p_step, } } -EditorPropertyTransform2D::EditorPropertyTransform2D() { +EditorPropertyTransform2D::EditorPropertyTransform2D(bool p_include_origin) { GridContainer *g = memnew(GridContainer); - g->set_columns(2); + g->set_columns(p_include_origin ? 3 : 2); add_child(g); - static const char *desc[6] = { "x", "y", "x", "y", "x", "y" }; + static const char *desc[6] = { "xx", "xy", "xo", "yx", "yy", "yo" }; for (int i = 0; i < 6; i++) { spin[i] = memnew(EditorSpinSlider); spin[i]->set_label(desc[i]); spin[i]->set_flat(true); - g->add_child(spin[i]); + if (p_include_origin || i % 3 != 2) { + g->add_child(spin[i]); + } spin[i]->set_h_size_flags(SIZE_EXPAND_FILL); add_focusable(spin[i]); spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyTransform2D::_value_changed), varray(desc[i])); @@ -2436,13 +2423,13 @@ void EditorPropertyBasis::_value_changed(double val, const String &p_name) { Basis p; p[0][0] = spin[0]->get_value(); - p[1][0] = spin[1]->get_value(); - p[2][0] = spin[2]->get_value(); - p[0][1] = spin[3]->get_value(); + p[0][1] = spin[1]->get_value(); + p[0][2] = spin[2]->get_value(); + p[1][0] = spin[3]->get_value(); p[1][1] = spin[4]->get_value(); - p[2][1] = spin[5]->get_value(); - p[0][2] = spin[6]->get_value(); - p[1][2] = spin[7]->get_value(); + p[1][2] = spin[5]->get_value(); + p[2][0] = spin[6]->get_value(); + p[2][1] = spin[7]->get_value(); p[2][2] = spin[8]->get_value(); emit_changed(get_edited_property(), p, p_name); @@ -2452,13 +2439,13 @@ void EditorPropertyBasis::update_property() { Basis val = get_edited_object()->get(get_edited_property()); setting = true; spin[0]->set_value(val[0][0]); - spin[1]->set_value(val[1][0]); - spin[2]->set_value(val[2][0]); - spin[3]->set_value(val[0][1]); + spin[1]->set_value(val[0][1]); + spin[2]->set_value(val[0][2]); + spin[3]->set_value(val[1][0]); spin[4]->set_value(val[1][1]); - spin[5]->set_value(val[2][1]); - spin[6]->set_value(val[0][2]); - spin[7]->set_value(val[1][2]); + spin[5]->set_value(val[1][2]); + spin[6]->set_value(val[2][0]); + spin[7]->set_value(val[2][1]); spin[8]->set_value(val[2][2]); setting = false; @@ -2466,11 +2453,9 @@ void EditorPropertyBasis::update_property() { void EditorPropertyBasis::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 9; i++) { - Color c = base; - c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i % 3]); } } } @@ -2495,7 +2480,7 @@ EditorPropertyBasis::EditorPropertyBasis() { g->set_columns(3); add_child(g); - static const char *desc[9] = { "x", "y", "z", "x", "y", "z", "x", "y", "z" }; + static const char *desc[9] = { "xx", "xy", "xz", "yx", "yy", "yz", "zx", "zy", "zz" }; for (int i = 0; i < 9; i++) { spin[i] = memnew(EditorSpinSlider); spin[i]->set_label(desc[i]); @@ -2524,16 +2509,16 @@ void EditorPropertyTransform3D::_value_changed(double val, const String &p_name) Transform3D p; p.basis[0][0] = spin[0]->get_value(); - p.basis[1][0] = spin[1]->get_value(); - p.basis[2][0] = spin[2]->get_value(); - p.basis[0][1] = spin[3]->get_value(); - p.basis[1][1] = spin[4]->get_value(); - p.basis[2][1] = spin[5]->get_value(); - p.basis[0][2] = spin[6]->get_value(); - p.basis[1][2] = spin[7]->get_value(); - p.basis[2][2] = spin[8]->get_value(); - p.origin[0] = spin[9]->get_value(); - p.origin[1] = spin[10]->get_value(); + p.basis[0][1] = spin[1]->get_value(); + p.basis[0][2] = spin[2]->get_value(); + p.origin[0] = spin[3]->get_value(); + p.basis[1][0] = spin[4]->get_value(); + p.basis[1][1] = spin[5]->get_value(); + p.basis[1][2] = spin[6]->get_value(); + p.origin[1] = spin[7]->get_value(); + p.basis[2][0] = spin[8]->get_value(); + p.basis[2][1] = spin[9]->get_value(); + p.basis[2][2] = spin[10]->get_value(); p.origin[2] = spin[11]->get_value(); emit_changed(get_edited_property(), p, p_name); @@ -2546,27 +2531,25 @@ void EditorPropertyTransform3D::update_property() { void EditorPropertyTransform3D::update_using_transform(Transform3D p_transform) { setting = true; spin[0]->set_value(p_transform.basis[0][0]); - spin[1]->set_value(p_transform.basis[1][0]); - spin[2]->set_value(p_transform.basis[2][0]); - spin[3]->set_value(p_transform.basis[0][1]); - spin[4]->set_value(p_transform.basis[1][1]); - spin[5]->set_value(p_transform.basis[2][1]); - spin[6]->set_value(p_transform.basis[0][2]); - spin[7]->set_value(p_transform.basis[1][2]); - spin[8]->set_value(p_transform.basis[2][2]); - spin[9]->set_value(p_transform.origin[0]); - spin[10]->set_value(p_transform.origin[1]); + spin[1]->set_value(p_transform.basis[0][1]); + spin[2]->set_value(p_transform.basis[0][2]); + spin[3]->set_value(p_transform.origin[0]); + spin[4]->set_value(p_transform.basis[1][0]); + spin[5]->set_value(p_transform.basis[1][1]); + spin[6]->set_value(p_transform.basis[1][2]); + spin[7]->set_value(p_transform.origin[1]); + spin[8]->set_value(p_transform.basis[2][0]); + spin[9]->set_value(p_transform.basis[2][1]); + spin[10]->set_value(p_transform.basis[2][2]); spin[11]->set_value(p_transform.origin[2]); setting = false; } void EditorPropertyTransform3D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color *colors = _get_property_colors(); for (int i = 0; i < 12; i++) { - Color c = base; - c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); - spin[i]->set_custom_label_color(true, c); + spin[i]->set_custom_label_color(true, colors[i % 4]); } } } @@ -2588,10 +2571,10 @@ void EditorPropertyTransform3D::setup(double p_min, double p_max, double p_step, EditorPropertyTransform3D::EditorPropertyTransform3D() { GridContainer *g = memnew(GridContainer); - g->set_columns(3); + g->set_columns(4); add_child(g); - static const char *desc[12] = { "x", "y", "z", "x", "y", "z", "x", "y", "z", "x", "y", "z" }; + static const char *desc[12] = { "xx", "xy", "xz", "xo", "yx", "yy", "yz", "yo", "zx", "zy", "zz", "zo" }; for (int i = 0; i < 12; i++) { spin[i] = memnew(EditorSpinSlider); spin[i]->set_label(desc[i]); @@ -3448,7 +3431,6 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); return editor; - } break; case Variant::PLANE: { EditorPropertyPlane *editor = memnew(EditorPropertyPlane(p_wide)); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index cee5ab96a7..9a687f1a72 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -554,7 +554,7 @@ protected: public: virtual void update_property() override; void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); - EditorPropertyTransform2D(); + EditorPropertyTransform2D(bool p_include_origin = true); }; class EditorPropertyBasis : public EditorProperty { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 05cf3791f4..81554c9550 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2051,6 +2051,10 @@ void ProjectManager::_open_selected_projects() { args.push_back("--disable-crash-handler"); } + if (OS::get_singleton()->is_single_window()) { + args.push_back("--single-window"); + } + String exec = OS::get_singleton()->get_executable_path(); Error err = OS::get_singleton()->create_process(exec, args); ERR_FAIL_COND(err); diff --git a/main/main.cpp b/main/main.cpp index 94fed8aa6e..5513e571d6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -135,7 +135,6 @@ static int audio_driver_idx = -1; // Engine config/tools -static bool single_window = false; static bool editor = false; static bool project_manager = false; static bool cmdline_tool = false; @@ -755,7 +754,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } } else if (I->get() == "--single-window") { // force single window - single_window = true; + OS::get_singleton()->_single_window = true; } else if (I->get() == "-t" || I->get() == "--always-on-top") { // force always-on-top window init_always_on_top = true; @@ -2131,7 +2130,7 @@ bool Main::start() { bool embed_subwindows = GLOBAL_DEF("display/window/subwindows/embed_subwindows", false); - if (single_window || (!project_manager && !editor && embed_subwindows)) { + if (OS::get_singleton()->is_single_window() || (!project_manager && !editor && embed_subwindows)) { sml->get_root()->set_embed_subwindows_hint(true); } ResourceLoader::add_custom_loaders(); diff --git a/modules/gltf/doc_classes/GLTFCamera.xml b/modules/gltf/doc_classes/GLTFCamera.xml index 0b95f2c802..ec25d84756 100644 --- a/modules/gltf/doc_classes/GLTFCamera.xml +++ b/modules/gltf/doc_classes/GLTFCamera.xml @@ -9,13 +9,13 @@ <methods> </methods> <members> - <member name="fov_size" type="float" setter="set_fov_size" getter="get_fov_size" default="75.0"> + <member name="depth_far" type="float" setter="set_depth_far" getter="get_depth_far" default="4000.0"> </member> - <member name="perspective" type="bool" setter="set_perspective" getter="get_perspective" default="true"> + <member name="depth_near" type="float" setter="set_depth_near" getter="get_depth_near" default="0.05"> </member> - <member name="zfar" type="float" setter="set_zfar" getter="get_zfar" default="4000.0"> + <member name="fov_size" type="float" setter="set_fov_size" getter="get_fov_size" default="75.0"> </member> - <member name="znear" type="float" setter="set_znear" getter="get_znear" default="0.05"> + <member name="perspective" type="bool" setter="set_perspective" getter="get_perspective" default="true"> </member> </members> <constants> diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml index f51d287685..2eb5ee9070 100644 --- a/modules/gltf/doc_classes/GLTFLight.xml +++ b/modules/gltf/doc_classes/GLTFLight.xml @@ -15,12 +15,12 @@ </member> <member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="0.0"> </member> + <member name="light_type" type="String" setter="set_light_type" getter="get_light_type" default=""""> + </member> <member name="outer_cone_angle" type="float" setter="set_outer_cone_angle" getter="get_outer_cone_angle" default="0.0"> </member> <member name="range" type="float" setter="set_range" getter="get_range" default="0.0"> </member> - <member name="type" type="String" setter="set_type" getter="get_type" default=""""> - </member> </members> <constants> </constants> diff --git a/modules/gltf/doc_classes/GLTFNode.xml b/modules/gltf/doc_classes/GLTFNode.xml index bfbb12df4d..95d7283398 100644 --- a/modules/gltf/doc_classes/GLTFNode.xml +++ b/modules/gltf/doc_classes/GLTFNode.xml @@ -23,6 +23,8 @@ </member> <member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1"> </member> + <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3(0, 0, 0)"> + </member> <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion(0, 0, 0, 1)"> </member> <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)"> @@ -31,8 +33,6 @@ </member> <member name="skin" type="int" setter="set_skin" getter="get_skin" default="-1"> </member> - <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3(0, 0, 0)"> - </member> <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> </member> </members> diff --git a/modules/gltf/gltf_animation.h b/modules/gltf/gltf_animation.h index 216d2161c4..be0ed2d4c6 100644 --- a/modules/gltf/gltf_animation.h +++ b/modules/gltf/gltf_animation.h @@ -55,7 +55,7 @@ public: }; struct Track { - Channel<Vector3> translation_track; + Channel<Vector3> position_track; Channel<Quaternion> rotation_track; Channel<Vector3> scale_track; Vector<Channel<float>> weight_tracks; diff --git a/modules/gltf/gltf_camera.cpp b/modules/gltf/gltf_camera.cpp index efa7c5d6d7..0f895fb989 100644 --- a/modules/gltf/gltf_camera.cpp +++ b/modules/gltf/gltf_camera.cpp @@ -35,13 +35,13 @@ void GLTFCamera::_bind_methods() { ClassDB::bind_method(D_METHOD("set_perspective", "perspective"), &GLTFCamera::set_perspective); ClassDB::bind_method(D_METHOD("get_fov_size"), &GLTFCamera::get_fov_size); ClassDB::bind_method(D_METHOD("set_fov_size", "fov_size"), &GLTFCamera::set_fov_size); - ClassDB::bind_method(D_METHOD("get_zfar"), &GLTFCamera::get_zfar); - ClassDB::bind_method(D_METHOD("set_zfar", "zfar"), &GLTFCamera::set_zfar); - ClassDB::bind_method(D_METHOD("get_znear"), &GLTFCamera::get_znear); - ClassDB::bind_method(D_METHOD("set_znear", "znear"), &GLTFCamera::set_znear); + ClassDB::bind_method(D_METHOD("get_depth_far"), &GLTFCamera::get_depth_far); + ClassDB::bind_method(D_METHOD("set_depth_far", "zdepth_far"), &GLTFCamera::set_depth_far); + ClassDB::bind_method(D_METHOD("get_depth_near"), &GLTFCamera::get_depth_near); + ClassDB::bind_method(D_METHOD("set_depth_near", "zdepth_near"), &GLTFCamera::set_depth_near); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "perspective"), "set_perspective", "get_perspective"); // bool ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fov_size"), "set_fov_size", "get_fov_size"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "zfar"), "set_zfar", "get_zfar"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "znear"), "set_znear", "get_znear"); // float + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_far"), "set_depth_far", "get_depth_far"); // float + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_near"), "set_depth_near", "get_depth_near"); // float } diff --git a/modules/gltf/gltf_camera.h b/modules/gltf/gltf_camera.h index bf94b80bef..843ff417a4 100644 --- a/modules/gltf/gltf_camera.h +++ b/modules/gltf/gltf_camera.h @@ -39,8 +39,8 @@ class GLTFCamera : public Resource { private: bool perspective = true; float fov_size = 75.0; - float zfar = 4000.0; - float znear = 0.05; + float depth_far = 4000.0; + float depth_near = 0.05; protected: static void _bind_methods(); @@ -50,9 +50,9 @@ public: void set_perspective(bool p_val) { perspective = p_val; } float get_fov_size() const { return fov_size; } void set_fov_size(float p_val) { fov_size = p_val; } - float get_zfar() const { return zfar; } - void set_zfar(float p_val) { zfar = p_val; } - float get_znear() const { return znear; } - void set_znear(float p_val) { znear = p_val; } + float get_depth_far() const { return depth_far; } + void set_depth_far(float p_val) { depth_far = p_val; } + float get_depth_near() const { return depth_near; } + void set_depth_near(float p_val) { depth_near = p_val; } }; #endif // GLTF_CAMERA_H diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index db324e23b7..d4f4221663 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -429,8 +429,8 @@ Error GLTFDocument::_serialize_nodes(Ref<GLTFState> state) { node["scale"] = _vec3_to_arr(n->scale); } - if (!n->translation.is_equal_approx(Vector3())) { - node["translation"] = _vec3_to_arr(n->translation); + if (!n->position.is_equal_approx(Vector3())) { + node["translation"] = _vec3_to_arr(n->position); } if (n->children.size()) { Array children; @@ -584,7 +584,7 @@ Error GLTFDocument::_parse_nodes(Ref<GLTFState> state) { node->xform = _arr_to_xform(n["matrix"]); } else { if (n.has("translation")) { - node->translation = _arr_to_vec3(n["translation"]); + node->position = _arr_to_vec3(n["translation"]); } if (n.has("rotation")) { node->rotation = _arr_to_quaternion(n["rotation"]); @@ -594,7 +594,7 @@ Error GLTFDocument::_parse_nodes(Ref<GLTFState> state) { } node->xform.basis.set_quaternion_scale(node->rotation, node->scale); - node->xform.origin = node->translation; + node->xform.origin = node->position; } if (n.has("extensions")) { @@ -4470,8 +4470,8 @@ Error GLTFDocument::_serialize_lights(Ref<GLTFState> state) { color[1] = light->color.g; color[2] = light->color.b; d["color"] = color; - d["type"] = light->type; - if (light->type == "spot") { + d["type"] = light->light_type; + if (light->light_type == "spot") { Dictionary s; float inner_cone_angle = light->inner_cone_angle; s["innerConeAngle"] = inner_cone_angle; @@ -4517,16 +4517,16 @@ Error GLTFDocument::_serialize_cameras(Ref<GLTFState> state) { Dictionary og; og["ymag"] = Math::deg2rad(camera->get_fov_size()); og["xmag"] = Math::deg2rad(camera->get_fov_size()); - og["zfar"] = camera->get_zfar(); - og["znear"] = camera->get_znear(); + og["zfar"] = camera->get_depth_far(); + og["znear"] = camera->get_depth_near(); d["orthographic"] = og; d["type"] = "orthographic"; } else if (camera->get_perspective()) { Dictionary ppt; // GLTF spec is in radians, Godot's camera is in degrees. ppt["yfov"] = Math::deg2rad(camera->get_fov_size()); - ppt["zfar"] = camera->get_zfar(); - ppt["znear"] = camera->get_znear(); + ppt["zfar"] = camera->get_depth_far(); + ppt["znear"] = camera->get_depth_near(); d["perspective"] = ppt; d["type"] = "perspective"; } @@ -4566,7 +4566,7 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) { light.instantiate(); ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); const String &type = d["type"]; - light->type = type; + light->light_type = type; if (d.has("color")) { const Array &arr = d["color"]; @@ -4617,8 +4617,8 @@ Error GLTFDocument::_parse_cameras(Ref<GLTFState> state) { const Dictionary &og = d["orthographic"]; // GLTF spec is in radians, Godot's camera is in degrees. camera->set_fov_size(Math::rad2deg(real_t(og["ymag"]))); - camera->set_zfar(og["zfar"]); - camera->set_znear(og["znear"]); + camera->set_depth_far(og["zfar"]); + camera->set_depth_near(og["znear"]); } else { camera->set_fov_size(10); } @@ -4628,8 +4628,8 @@ Error GLTFDocument::_parse_cameras(Ref<GLTFState> state) { const Dictionary &ppt = d["perspective"]; // GLTF spec is in radians, Godot's camera is in degrees. camera->set_fov_size(Math::rad2deg(real_t(ppt["yfov"]))); - camera->set_zfar(ppt["zfar"]); - camera->set_znear(ppt["znear"]); + camera->set_depth_far(ppt["zfar"]); + camera->set_depth_near(ppt["znear"]); } else { camera->set_fov_size(10); } @@ -4690,15 +4690,15 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { for (Map<int, GLTFAnimation::Track>::Element *track_i = gltf_animation->get_tracks().front(); track_i; track_i = track_i->next()) { GLTFAnimation::Track track = track_i->get(); - if (track.translation_track.times.size()) { + if (track.position_track.times.size()) { Dictionary t; t["sampler"] = samplers.size(); Dictionary s; - s["interpolation"] = interpolation_to_string(track.translation_track.interpolation); - Vector<real_t> times = Variant(track.translation_track.times); + s["interpolation"] = interpolation_to_string(track.position_track.interpolation); + Vector<real_t> times = Variant(track.position_track.times); s["input"] = _encode_accessor_as_floats(state, times, false); - Vector<Vector3> values = Variant(track.translation_track.values); + Vector<Vector3> values = Variant(track.position_track.values); s["output"] = _encode_accessor_as_vec3(state, values, false); samplers.push_back(s); @@ -4883,10 +4883,10 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) { const Vector<float> times = _decode_accessor_as_floats(state, input, false); if (path == "translation") { - const Vector<Vector3> translations = _decode_accessor_as_vec3(state, output, false); - track->translation_track.interpolation = interp; - track->translation_track.times = Variant(times); //convert via variant - track->translation_track.values = Variant(translations); //convert via variant + const Vector<Vector3> positions = _decode_accessor_as_vec3(state, output, false); + track->position_track.interpolation = interp; + track->position_track.times = Variant(times); //convert via variant + track->position_track.values = Variant(positions); //convert via variant } else if (path == "rotation") { const Vector<Quaternion> rotations = _decode_accessor_as_quaternion(state, output, false); track->rotation_track.interpolation = interp; @@ -5064,7 +5064,7 @@ Node3D *GLTFDocument::_generate_light(Ref<GLTFState> state, Node *scene_parent, intensity /= 100; } - if (l->type == "directional") { + if (l->light_type == "directional") { DirectionalLight3D *light = memnew(DirectionalLight3D); light->set_param(Light3D::PARAM_ENERGY, intensity); light->set_color(l->color); @@ -5075,14 +5075,14 @@ Node3D *GLTFDocument::_generate_light(Ref<GLTFState> state, Node *scene_parent, // Doubling the range will double the effective brightness, so we need double attenuation (half brightness). // We want to have double intensity give double brightness, so we need half the attenuation. const float attenuation = range / intensity; - if (l->type == "point") { + if (l->light_type == "point") { OmniLight3D *light = memnew(OmniLight3D); light->set_param(OmniLight3D::PARAM_ATTENUATION, attenuation); light->set_param(OmniLight3D::PARAM_RANGE, range); light->set_color(l->color); return light; } - if (l->type == "spot") { + if (l->light_type == "spot") { SpotLight3D *light = memnew(SpotLight3D); light->set_param(SpotLight3D::PARAM_ATTENUATION, attenuation); light->set_param(SpotLight3D::PARAM_RANGE, range); @@ -5109,9 +5109,9 @@ Camera3D *GLTFDocument::_generate_camera(Ref<GLTFState> state, Node *scene_paren Ref<GLTFCamera> c = state->cameras[gltf_node->camera]; if (c->get_perspective()) { - camera->set_perspective(c->get_fov_size(), c->get_znear(), c->get_zfar()); + camera->set_perspective(c->get_fov_size(), c->get_depth_near(), c->get_depth_far()); } else { - camera->set_orthogonal(c->get_fov_size(), c->get_znear(), c->get_zfar()); + camera->set_orthogonal(c->get_fov_size(), c->get_depth_near(), c->get_depth_far()); } return camera; @@ -5125,14 +5125,10 @@ GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_ if (p_camera->get_projection() == Camera3D::Projection::PROJECTION_PERSPECTIVE) { c->set_perspective(true); - c->set_fov_size(p_camera->get_fov()); - c->set_zfar(p_camera->get_far()); - c->set_znear(p_camera->get_near()); - } else { - c->set_fov_size(p_camera->get_fov()); - c->set_zfar(p_camera->get_far()); - c->set_znear(p_camera->get_near()); } + c->set_fov_size(p_camera->get_fov()); + c->set_depth_far(p_camera->get_far()); + c->set_depth_near(p_camera->get_near()); GLTFCameraIndex camera_index = state->cameras.size(); state->cameras.push_back(c); return camera_index; @@ -5145,18 +5141,18 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig l.instantiate(); l->color = p_light->get_color(); if (cast_to<DirectionalLight3D>(p_light)) { - l->type = "directional"; + l->light_type = "directional"; DirectionalLight3D *light = cast_to<DirectionalLight3D>(p_light); l->intensity = light->get_param(DirectionalLight3D::PARAM_ENERGY); l->range = FLT_MAX; // Range for directional lights is infinite in Godot. } else if (cast_to<OmniLight3D>(p_light)) { - l->type = "point"; + l->light_type = "point"; OmniLight3D *light = cast_to<OmniLight3D>(p_light); l->range = light->get_param(OmniLight3D::PARAM_RANGE); float attenuation = p_light->get_param(OmniLight3D::PARAM_ATTENUATION); l->intensity = l->range / attenuation; } else if (cast_to<SpotLight3D>(p_light)) { - l->type = "spot"; + l->light_type = "spot"; SpotLight3D *light = cast_to<SpotLight3D>(p_light); l->range = light->get_param(SpotLight3D::PARAM_RANGE); float attenuation = light->get_param(SpotLight3D::PARAM_ATTENUATION); @@ -5189,7 +5185,7 @@ void GLTFDocument::_convert_spatial(Ref<GLTFState> state, Node3D *p_spatial, Ref Transform3D xform = p_spatial->get_transform(); p_node->scale = xform.basis.get_scale(); p_node->rotation = xform.basis.get_rotation_quaternion(); - p_node->translation = xform.origin; + p_node->position = xform.origin; } Node3D *GLTFDocument::_generate_spatial(Ref<GLTFState> state, Node *scene_parent, const GLTFNodeIndex node_index) { @@ -5772,8 +5768,8 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, for (int i = 0; i < track.rotation_track.times.size(); i++) { length = MAX(length, track.rotation_track.times[i]); } - for (int i = 0; i < track.translation_track.times.size(); i++) { - length = MAX(length, track.translation_track.times[i]); + for (int i = 0; i < track.position_track.times.size(); i++) { + length = MAX(length, track.position_track.times[i]); } for (int i = 0; i < track.scale_track.times.size(); i++) { length = MAX(length, track.scale_track.times[i]); @@ -5787,7 +5783,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, // Animated TRS properties will not affect a skinned mesh. const bool transform_affects_skinned_mesh_instance = gltf_node->skeleton < 0 && gltf_node->skin >= 0; - if ((track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) && !transform_affects_skinned_mesh_instance) { + if ((track.rotation_track.values.size() || track.position_track.values.size() || track.scale_track.values.size()) && !transform_affects_skinned_mesh_instance) { //make transform track int track_idx = animation->get_track_count(); animation->add_track(Animation::TYPE_TRANSFORM3D); @@ -5805,8 +5801,8 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, base_rot = state->nodes[track_i->key()]->rotation.normalized(); } - if (!track.translation_track.values.size()) { - base_pos = state->nodes[track_i->key()]->translation; + if (!track.position_track.values.size()) { + base_pos = state->nodes[track_i->key()]->position; } if (!track.scale_track.values.size()) { @@ -5819,8 +5815,8 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, Quaternion rot = base_rot; Vector3 scale = base_scale; - if (track.translation_track.times.size()) { - pos = _interpolate_track<Vector3>(track.translation_track.times, track.translation_track.values, time, track.translation_track.interpolation); + if (track.position_track.times.size()) { + pos = _interpolate_track<Vector3>(track.position_track.times, track.position_track.values, time, track.position_track.interpolation); } if (track.rotation_track.times.size()) { @@ -5928,7 +5924,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) { Transform3D mi_xform = mi->get_transform(); node->scale = mi_xform.basis.get_scale(); node->rotation = mi_xform.basis.get_rotation_quaternion(); - node->translation = mi_xform.origin; + node->position = mi_xform.origin; Dictionary json_skin; Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(mi->get_node(mi->get_skeleton_path())); @@ -5992,7 +5988,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) { Transform3D bone_rest_xform = skeleton->get_bone_rest(bone_index); joint_node->scale = bone_rest_xform.basis.get_scale(); joint_node->rotation = bone_rest_xform.basis.get_rotation_quaternion(); - joint_node->translation = bone_rest_xform.origin; + joint_node->position = bone_rest_xform.origin; joint_node->joint = true; int32_t joint_node_i = state->nodes.size(); @@ -6138,8 +6134,8 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state } const float BAKE_FPS = 30.0f; if (track_type == Animation::TYPE_TRANSFORM3D) { - p_track.translation_track.times = times; - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.times = times; + p_track.position_track.interpolation = gltf_interpolation; p_track.rotation_track.times = times; p_track.rotation_track.interpolation = gltf_interpolation; p_track.scale_track.times = times; @@ -6147,27 +6143,27 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state p_track.scale_track.values.resize(key_count); p_track.scale_track.interpolation = gltf_interpolation; - p_track.translation_track.values.resize(key_count); - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.values.resize(key_count); + p_track.position_track.interpolation = gltf_interpolation; p_track.rotation_track.values.resize(key_count); p_track.rotation_track.interpolation = gltf_interpolation; for (int32_t key_i = 0; key_i < key_count; key_i++) { - Vector3 translation; + Vector3 position; Quaternion rotation; Vector3 scale; - Error err = p_animation->transform_track_get_key(p_track_i, key_i, &translation, &rotation, &scale); + Error err = p_animation->transform_track_get_key(p_track_i, key_i, &position, &rotation, &scale); ERR_CONTINUE(err != OK); Transform3D xform; xform.basis.set_quaternion_scale(rotation, scale); - xform.origin = translation; + xform.origin = position; xform = p_bone_rest * xform; - p_track.translation_track.values.write[key_i] = xform.get_origin(); + p_track.position_track.values.write[key_i] = xform.get_origin(); p_track.rotation_track.values.write[key_i] = xform.basis.get_rotation_quaternion(); p_track.scale_track.values.write[key_i] = xform.basis.get_scale(); } } else if (path.find(":transform") != -1) { - p_track.translation_track.times = times; - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.times = times; + p_track.position_track.interpolation = gltf_interpolation; p_track.rotation_track.times = times; p_track.rotation_track.interpolation = gltf_interpolation; p_track.scale_track.times = times; @@ -6175,13 +6171,13 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state p_track.scale_track.values.resize(key_count); p_track.scale_track.interpolation = gltf_interpolation; - p_track.translation_track.values.resize(key_count); - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.values.resize(key_count); + p_track.position_track.interpolation = gltf_interpolation; p_track.rotation_track.values.resize(key_count); p_track.rotation_track.interpolation = gltf_interpolation; for (int32_t key_i = 0; key_i < key_count; key_i++) { Transform3D xform = p_animation->track_get_key_value(p_track_i, key_i); - p_track.translation_track.values.write[key_i] = xform.get_origin(); + p_track.position_track.values.write[key_i] = xform.get_origin(); p_track.rotation_track.values.write[key_i] = xform.basis.get_rotation_quaternion(); p_track.scale_track.values.write[key_i] = xform.basis.get_scale(); } @@ -6197,16 +6193,16 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state Quaternion rotation_track = p_animation->track_get_key_value(p_track_i, key_i); p_track.rotation_track.values.write[key_i] = rotation_track; } - } else if (path.find(":translation") != -1) { - p_track.translation_track.times = times; - p_track.translation_track.interpolation = gltf_interpolation; + } else if (path.find(":position") != -1) { + p_track.position_track.times = times; + p_track.position_track.interpolation = gltf_interpolation; - p_track.translation_track.values.resize(key_count); - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.values.resize(key_count); + p_track.position_track.interpolation = gltf_interpolation; for (int32_t key_i = 0; key_i < key_count; key_i++) { - Vector3 translation = p_animation->track_get_key_value(p_track_i, key_i); - p_track.translation_track.values.write[key_i] = translation; + Vector3 position = p_animation->track_get_key_value(p_track_i, key_i); + p_track.position_track.values.write[key_i] = position; } } else if (path.find(":rotation") != -1) { p_track.rotation_track.times = times; @@ -6265,34 +6261,34 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state } p_track.scale_track.values.write[key_i] = bezier_track; } - } else if (path.find("/translation") != -1) { + } else if (path.find("/position") != -1) { const int32_t keys = p_animation->track_get_key_time(p_track_i, key_count - 1) * BAKE_FPS; - if (!p_track.translation_track.times.size()) { + if (!p_track.position_track.times.size()) { Vector<float> new_times; new_times.resize(keys); for (int32_t key_i = 0; key_i < keys; key_i++) { new_times.write[key_i] = key_i / BAKE_FPS; } - p_track.translation_track.times = new_times; - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.times = new_times; + p_track.position_track.interpolation = gltf_interpolation; - p_track.translation_track.values.resize(keys); - p_track.translation_track.interpolation = gltf_interpolation; + p_track.position_track.values.resize(keys); + p_track.position_track.interpolation = gltf_interpolation; } for (int32_t key_i = 0; key_i < keys; key_i++) { - Vector3 bezier_track = p_track.translation_track.values[key_i]; - if (path.find("/translation:x") != -1) { + Vector3 bezier_track = p_track.position_track.values[key_i]; + if (path.find("/position:x") != -1) { bezier_track.x = p_animation->bezier_track_interpolate(p_track_i, key_i / BAKE_FPS); bezier_track.x = p_bone_rest.affine_inverse().origin.x * bezier_track.x; - } else if (path.find("/translation:y") != -1) { + } else if (path.find("/position:y") != -1) { bezier_track.y = p_animation->bezier_track_interpolate(p_track_i, key_i / BAKE_FPS); bezier_track.y = p_bone_rest.affine_inverse().origin.y * bezier_track.y; - } else if (path.find("/translation:z") != -1) { + } else if (path.find("/position:z") != -1) { bezier_track.z = p_animation->bezier_track_interpolate(p_track_i, key_i / BAKE_FPS); bezier_track.z = p_bone_rest.affine_inverse().origin.z * bezier_track.z; } - p_track.translation_track.values.write[key_i] = bezier_track; + p_track.position_track.values.write[key_i] = bezier_track; } } } @@ -6311,17 +6307,17 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, continue; } String orig_track_path = animation->track_get_path(track_i); - if (String(orig_track_path).find(":translation") != -1) { - const Vector<String> node_suffix = String(orig_track_path).split(":translation"); + if (String(orig_track_path).find(":position") != -1) { + const Vector<String> node_suffix = String(orig_track_path).split(":position"); const NodePath path = node_suffix[0]; const Node *node = ap->get_parent()->get_node_or_null(path); - for (Map<GLTFNodeIndex, Node *>::Element *translation_scene_node_i = state->scene_nodes.front(); translation_scene_node_i; translation_scene_node_i = translation_scene_node_i->next()) { - if (translation_scene_node_i->get() == node) { - GLTFNodeIndex node_index = translation_scene_node_i->key(); - Map<int, GLTFAnimation::Track>::Element *translation_track_i = gltf_animation->get_tracks().find(node_index); + for (Map<GLTFNodeIndex, Node *>::Element *position_scene_node_i = state->scene_nodes.front(); position_scene_node_i; position_scene_node_i = position_scene_node_i->next()) { + if (position_scene_node_i->get() == node) { + GLTFNodeIndex node_index = position_scene_node_i->key(); + Map<int, GLTFAnimation::Track>::Element *position_track_i = gltf_animation->get_tracks().find(node_index); GLTFAnimation::Track track; - if (translation_track_i) { - track = translation_track_i->get(); + if (position_track_i) { + track = position_track_i->get(); } track = _convert_animation_track(state, track, animation, Transform3D(), track_i, node_index); gltf_animation->get_tracks().insert(node_index, track); diff --git a/modules/gltf/gltf_light.cpp b/modules/gltf/gltf_light.cpp index 95cca9cf71..c5aa8d5724 100644 --- a/modules/gltf/gltf_light.cpp +++ b/modules/gltf/gltf_light.cpp @@ -35,8 +35,8 @@ void GLTFLight::_bind_methods() { ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); ClassDB::bind_method(D_METHOD("get_intensity"), &GLTFLight::get_intensity); ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &GLTFLight::set_intensity); - ClassDB::bind_method(D_METHOD("get_type"), &GLTFLight::get_type); - ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFLight::set_type); + ClassDB::bind_method(D_METHOD("get_light_type"), &GLTFLight::get_light_type); + ClassDB::bind_method(D_METHOD("set_light_type", "light_type"), &GLTFLight::set_light_type); ClassDB::bind_method(D_METHOD("get_range"), &GLTFLight::get_range); ClassDB::bind_method(D_METHOD("set_range", "range"), &GLTFLight::set_range); ClassDB::bind_method(D_METHOD("get_inner_cone_angle"), &GLTFLight::get_inner_cone_angle); @@ -46,7 +46,7 @@ void GLTFLight::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity"), "set_intensity", "get_intensity"); // float - ADD_PROPERTY(PropertyInfo(Variant::STRING, "type"), "set_type", "get_type"); // String + ADD_PROPERTY(PropertyInfo(Variant::STRING, "light_type"), "set_light_type", "get_light_type"); // String ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range"), "set_range", "get_range"); // float ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_cone_angle"), "set_inner_cone_angle", "get_inner_cone_angle"); // float ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_cone_angle"), "set_outer_cone_angle", "get_outer_cone_angle"); // float @@ -68,12 +68,12 @@ void GLTFLight::set_intensity(float p_intensity) { intensity = p_intensity; } -String GLTFLight::get_type() { - return type; +String GLTFLight::get_light_type() { + return light_type; } -void GLTFLight::set_type(String p_type) { - type = p_type; +void GLTFLight::set_light_type(String p_light_type) { + light_type = p_light_type; } float GLTFLight::get_range() { diff --git a/modules/gltf/gltf_light.h b/modules/gltf/gltf_light.h index a859ca1833..079fb18151 100644 --- a/modules/gltf/gltf_light.h +++ b/modules/gltf/gltf_light.h @@ -44,7 +44,7 @@ protected: private: Color color; float intensity = 0.0f; - String type; + String light_type; float range = 0.0f; float inner_cone_angle = 0.0f; float outer_cone_angle = 0.0f; @@ -56,8 +56,8 @@ public: float get_intensity(); void set_intensity(float p_intensity); - String get_type(); - void set_type(String p_type); + String get_light_type(); + void set_light_type(String p_light_type); float get_range(); void set_range(float p_range); diff --git a/modules/gltf/gltf_node.cpp b/modules/gltf/gltf_node.cpp index 5db7ad66c3..9f925c7bbc 100644 --- a/modules/gltf/gltf_node.cpp +++ b/modules/gltf/gltf_node.cpp @@ -47,8 +47,8 @@ void GLTFNode::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeleton", "skeleton"), &GLTFNode::set_skeleton); ClassDB::bind_method(D_METHOD("get_joint"), &GLTFNode::get_joint); ClassDB::bind_method(D_METHOD("set_joint", "joint"), &GLTFNode::set_joint); - ClassDB::bind_method(D_METHOD("get_translation"), &GLTFNode::get_translation); - ClassDB::bind_method(D_METHOD("set_translation", "translation"), &GLTFNode::set_translation); + ClassDB::bind_method(D_METHOD("get_position"), &GLTFNode::get_position); + ClassDB::bind_method(D_METHOD("set_position", "position"), &GLTFNode::set_position); ClassDB::bind_method(D_METHOD("get_rotation"), &GLTFNode::get_rotation); ClassDB::bind_method(D_METHOD("set_rotation", "rotation"), &GLTFNode::set_rotation); ClassDB::bind_method(D_METHOD("get_scale"), &GLTFNode::get_scale); @@ -66,7 +66,7 @@ void GLTFNode::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "skin"), "set_skin", "get_skin"); // GLTFSkinIndex ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // GLTFSkeletonIndex ADD_PROPERTY(PropertyInfo(Variant::BOOL, "joint"), "set_joint", "get_joint"); // bool - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation"), "set_translation", "get_translation"); // Vector3 + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position"); // Vector3 ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "rotation"), "set_rotation", "get_rotation"); // Quaternion ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale"); // Vector3 ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "children"), "set_children", "get_children"); // Vector<int> @@ -137,12 +137,12 @@ void GLTFNode::set_joint(bool p_joint) { joint = p_joint; } -Vector3 GLTFNode::get_translation() { - return translation; +Vector3 GLTFNode::get_position() { + return position; } -void GLTFNode::set_translation(Vector3 p_translation) { - translation = p_translation; +void GLTFNode::set_position(Vector3 p_position) { + position = p_position; } Quaternion GLTFNode::get_rotation() { diff --git a/modules/gltf/gltf_node.h b/modules/gltf/gltf_node.h index eca3acb239..3b6e061449 100644 --- a/modules/gltf/gltf_node.h +++ b/modules/gltf/gltf_node.h @@ -48,7 +48,7 @@ private: GLTFSkinIndex skin = -1; GLTFSkeletonIndex skeleton = -1; bool joint = false; - Vector3 translation; + Vector3 position; Quaternion rotation; Vector3 scale = Vector3(1, 1, 1); Vector<int> children; @@ -82,8 +82,8 @@ public: bool get_joint(); void set_joint(bool p_joint); - Vector3 get_translation(); - void set_translation(Vector3 p_translation); + Vector3 get_position(); + void set_position(Vector3 p_position); Quaternion get_rotation(); void set_rotation(Quaternion p_rotation); diff --git a/platform/javascript/js/libs/audio.worklet.js b/platform/javascript/js/libs/audio.worklet.js index 866f845139..df475ba52d 100644 --- a/platform/javascript/js/libs/audio.worklet.js +++ b/platform/javascript/js/libs/audio.worklet.js @@ -66,17 +66,17 @@ class RingBuffer { const mw = this.buffer.length - this.wpos; if (mw >= to_write) { this.buffer.set(p_buffer, this.wpos); + this.wpos += to_write; + if (mw === to_write) { + this.wpos = 0; + } } else { - const high = p_buffer.subarray(0, to_write - mw); - const low = p_buffer.subarray(to_write - mw); + const high = p_buffer.subarray(0, mw); + const low = p_buffer.subarray(mw); this.buffer.set(high, this.wpos); this.buffer.set(low); + this.wpos = low.length; } - let diff = to_write; - if (this.wpos + diff >= this.buffer.length) { - diff -= this.buffer.length; - } - this.wpos += diff; Atomics.add(this.avail, 0, to_write); Atomics.notify(this.avail, 0); } diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index f535c9e7bd..8eb22c1c72 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -18,40 +18,42 @@ def can_build(): # Check the minimal dependencies x11_error = os.system("pkg-config --version > /dev/null") if x11_error: + print("Error: pkg-config not found. Aborting.") return False - x11_error = os.system("pkg-config x11 --modversion > /dev/null ") + x11_error = os.system("pkg-config x11 --modversion > /dev/null") if x11_error: + print("Error: X11 libraries not found. Aborting.") return False - x11_error = os.system("pkg-config xcursor --modversion > /dev/null ") + x11_error = os.system("pkg-config xcursor --modversion > /dev/null") if x11_error: - print("xcursor not found.. x11 disabled.") + print("Error: Xcursor library not found. Aborting.") return False - x11_error = os.system("pkg-config xinerama --modversion > /dev/null ") + x11_error = os.system("pkg-config xinerama --modversion > /dev/null") if x11_error: - print("xinerama not found.. x11 disabled.") + print("Error: Xinerama library not found. Aborting.") return False - x11_error = os.system("pkg-config xext --modversion > /dev/null ") + x11_error = os.system("pkg-config xext --modversion > /dev/null") if x11_error: - print("xext not found.. x11 disabled.") + print("Error: Xext library not found. Aborting.") return False - x11_error = os.system("pkg-config xrandr --modversion > /dev/null ") + x11_error = os.system("pkg-config xrandr --modversion > /dev/null") if x11_error: - print("xrandr not found.. x11 disabled.") + print("Error: XrandR library not found. Aborting.") return False - x11_error = os.system("pkg-config xrender --modversion > /dev/null ") + x11_error = os.system("pkg-config xrender --modversion > /dev/null") if x11_error: - print("xrender not found.. x11 disabled.") + print("Error: XRender library not found. Aborting.") return False - x11_error = os.system("pkg-config xi --modversion > /dev/null ") + x11_error = os.system("pkg-config xi --modversion > /dev/null") if x11_error: - print("xi not found.. Aborting.") + print("Error: Xi library not found. Aborting.") return False return True @@ -138,7 +140,7 @@ def configure(env): # A convenience so you don't need to write use_lto too when using SCons env["use_lto"] = True else: - print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.") + print("Using LLD with GCC is not supported yet. Try compiling with 'use_llvm=yes'.") sys.exit(255) if env["use_coverage"]: @@ -329,36 +331,32 @@ def configure(env): ## Flags if os.system("pkg-config --exists alsa") == 0: # 0 means found - print("Enabling ALSA") env["alsa"] = True env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"]) else: - print("ALSA libraries not found, disabling driver") + print("Warning: ALSA libraries not found. Disabling the ALSA audio driver.") if env["pulseaudio"]: if os.system("pkg-config --exists libpulse") == 0: # 0 means found - print("Enabling PulseAudio") env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"]) env.ParseConfig("pkg-config --cflags libpulse") else: - print("PulseAudio development libraries not found, disabling driver") + print("Warning: PulseAudio development libraries not found. Disabling the PulseAudio audio driver.") if env["dbus"]: if os.system("pkg-config --exists dbus-1") == 0: # 0 means found - print("Enabling D-Bus") env.Append(CPPDEFINES=["DBUS_ENABLED"]) env.ParseConfig("pkg-config --cflags --libs dbus-1") else: - print("D-Bus development libraries not found, disabling dependent features") + print("Warning: D-Bus development libraries not found. Disabling screensaver prevention.") if platform.system() == "Linux": env.Append(CPPDEFINES=["JOYDEV_ENABLED"]) if env["udev"]: if os.system("pkg-config --exists libudev") == 0: # 0 means found - print("Enabling udev support") env.Append(CPPDEFINES=["UDEV_ENABLED"]) else: - print("libudev development libraries not found, disabling udev support") + print("Warning: libudev development libraries not found. Disabling controller hotplugging support.") else: env["udev"] = False # Linux specific @@ -407,7 +405,7 @@ def configure(env): gnu_ld_version = re.search("^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE) if not gnu_ld_version: print( - "Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld" + "Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld, not gold or LLD." ) else: if float(gnu_ld_version.group(1)) >= 2.30: diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 1fe6a4a4b8..67e35cc7a3 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -100,6 +100,10 @@ void ParallaxLayer::_notification(int p_what) { _update_mirroring(); } break; case NOTIFICATION_EXIT_TREE: { + if (Engine::get_singleton()->is_editor_hint()) { + break; + } + set_position(orig_offset); set_scale(orig_scale); } break; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index f6091f224c..5825a35030 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -737,7 +737,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double if (anim->has_loop()) { at_anim_pos = Math::fposmod(p_time - pos, (double)anim->get_length()); //seek to loop } else { - at_anim_pos = MAX((double)anim->get_length(), p_time - pos); //seek to end + at_anim_pos = MIN((double)anim->get_length(), p_time - pos); //seek to end } if (player->is_playing() || p_seeked) { @@ -765,6 +765,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } } else { player->play(anim_name); + player->seek(0.0, true); nc->animation_playing = true; playing_caches.insert(nc); } |