diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/connections_dialog.cpp | 258 | ||||
-rw-r--r-- | editor/connections_dialog.h | 26 | ||||
-rw-r--r-- | editor/editor_asset_installer.cpp | 4 | ||||
-rw-r--r-- | editor/editor_export.cpp | 9 | ||||
-rw-r--r-- | editor/editor_export.h | 5 | ||||
-rw-r--r-- | editor/editor_resource_picker.cpp | 38 | ||||
-rw-r--r-- | editor/export_template_manager.cpp | 6 | ||||
-rw-r--r-- | editor/import/editor_import_collada.cpp | 4 | ||||
-rw-r--r-- | editor/import/editor_import_collada.h | 4 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.cpp | 4 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.h | 4 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 104 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 21 | ||||
-rw-r--r-- | editor/import_dock.cpp | 30 | ||||
-rw-r--r-- | editor/import_dock.h | 3 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 157 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 18 | ||||
-rw-r--r-- | editor/project_manager.cpp | 6 |
20 files changed, 361 insertions, 356 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 8f4b677929..0edbb182e1 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -340,7 +340,7 @@ bool ConnectDialog::get_oneshot() const { * Returns true if ConnectDialog is being used to edit an existing connection. */ bool ConnectDialog::is_editing() const { - return bEditMode; + return edit_mode; } /* @@ -348,35 +348,35 @@ bool ConnectDialog::is_editing() const { * If creating a connection from scratch, sensible defaults are used. * If editing an existing connection, previous data is retained. */ -void ConnectDialog::init(ConnectionData c, bool bEdit) { +void ConnectDialog::init(ConnectionData p_cd, bool p_edit) { set_hide_on_ok(false); - source = static_cast<Node *>(c.source); - signal = c.signal; + source = static_cast<Node *>(p_cd.source); + signal = p_cd.signal; tree->set_selected(nullptr); tree->set_marked(source, true); - if (c.target) { - set_dst_node(static_cast<Node *>(c.target)); - set_dst_method(c.method); + if (p_cd.target) { + set_dst_node(static_cast<Node *>(p_cd.target)); + set_dst_method(p_cd.method); } _update_ok_enabled(); - bool bDeferred = (c.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED; - bool bOneshot = (c.flags & CONNECT_ONESHOT) == CONNECT_ONESHOT; + bool b_deferred = (p_cd.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED; + bool b_oneshot = (p_cd.flags & CONNECT_ONESHOT) == CONNECT_ONESHOT; - deferred->set_pressed(bDeferred); - oneshot->set_pressed(bOneshot); - unbind_count->set_value(c.unbinds); - _unbind_count_changed(c.unbinds); + deferred->set_pressed(b_deferred); + oneshot->set_pressed(b_oneshot); + unbind_count->set_value(p_cd.unbinds); + _unbind_count_changed(p_cd.unbinds); cdbinds->params.clear(); - cdbinds->params = c.binds; + cdbinds->params = p_cd.binds; cdbinds->notify_changed(); - bEditMode = bEdit; + edit_mode = p_edit; } void ConnectDialog::popup_dialog(const String &p_for_signal) { @@ -546,7 +546,7 @@ 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->call_deferred(SNAME("set_text"), text); //hack so it uses proper theme once inside scene + help_bit->call_deferred(SNAME("set_text"), text); // Hack so it uses proper theme once inside scene. return help_bit; } @@ -569,32 +569,32 @@ void ConnectionsDock::_make_or_edit_connection() { ERR_FAIL_COND(!it); NodePath dst_path = connect_dialog->get_dst_path(); - Node *target = selectedNode->get_node(dst_path); + Node *target = selected_node->get_node(dst_path); ERR_FAIL_COND(!target); - ConnectDialog::ConnectionData connection; - connection.source = connect_dialog->get_source(); - connection.target = target; - connection.signal = connect_dialog->get_signal_name(); - connection.method = connect_dialog->get_dst_method_name(); - connection.unbinds = connect_dialog->get_unbinds(); - if (connection.unbinds == 0) { - connection.binds = connect_dialog->get_binds(); + ConnectDialog::ConnectionData cd; + cd.source = connect_dialog->get_source(); + cd.target = target; + cd.signal = connect_dialog->get_signal_name(); + cd.method = connect_dialog->get_dst_method_name(); + cd.unbinds = connect_dialog->get_unbinds(); + if (cd.unbinds == 0) { + cd.binds = connect_dialog->get_binds(); } - bool defer = connect_dialog->get_deferred(); - bool oshot = connect_dialog->get_oneshot(); - connection.flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0); + bool b_deferred = connect_dialog->get_deferred(); + bool b_oneshot = connect_dialog->get_oneshot(); + cd.flags = CONNECT_PERSIST | (b_deferred ? CONNECT_DEFERRED : 0) | (b_oneshot ? CONNECT_ONESHOT : 0); // Conditions to add function: must have a script and must not have the method already // (in the class, the script itself, or inherited). bool add_script_function = false; Ref<Script> script = target->get_script(); - if (!target->get_script().is_null() && !ClassDB::has_method(target->get_class(), connection.method)) { + if (!target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cd.method)) { // There is a chance that the method is inherited from another script. bool found_inherited_function = false; Ref<Script> inherited_script = script->get_base_script(); while (!inherited_script.is_null()) { - int line = inherited_script->get_language()->find_function(connection.method, inherited_script->get_source_code()); + int line = inherited_script->get_language()->find_function(cd.method, inherited_script->get_source_code()); if (line != -1) { found_inherited_function = true; break; @@ -609,23 +609,23 @@ void ConnectionsDock::_make_or_edit_connection() { if (add_script_function) { // Pick up args here before "it" is deleted by update_tree. script_function_args = it->get_metadata(0).operator Dictionary()["args"]; - for (int i = 0; i < connection.binds.size(); i++) { - script_function_args.push_back("extra_arg_" + itos(i) + ":" + Variant::get_type_name(connection.binds[i].get_type())); + for (int i = 0; i < cd.binds.size(); i++) { + script_function_args.push_back("extra_arg_" + itos(i) + ":" + Variant::get_type_name(cd.binds[i].get_type())); } } if (connect_dialog->is_editing()) { _disconnect(*it); - _connect(connection); + _connect(cd); } else { - _connect(connection); + _connect(cd); } // IMPORTANT NOTE: _disconnect and _connect cause an update_tree, which will delete the object "it" is pointing to. it = nullptr; if (add_script_function) { - editor->emit_signal(SNAME("script_add_function_request"), target, connection.method, script_function_args); + editor->emit_signal(SNAME("script_add_function_request"), target, cd.method, script_function_args); hide(); } @@ -635,21 +635,21 @@ void ConnectionsDock::_make_or_edit_connection() { /* * Creates single connection w/ undo-redo functionality. */ -void ConnectionsDock::_connect(ConnectDialog::ConnectionData p_connection) { - Node *source = Object::cast_to<Node>(p_connection.source); - Node *target = Object::cast_to<Node>(p_connection.target); +void ConnectionsDock::_connect(ConnectDialog::ConnectionData p_cd) { + Node *source = Object::cast_to<Node>(p_cd.source); + Node *target = Object::cast_to<Node>(p_cd.target); if (!source || !target) { return; } - Callable callable = p_connection.get_callable(); - undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), String(p_connection.signal), String(p_connection.method))); - undo_redo->add_do_method(source, "connect", p_connection.signal, callable, varray(), p_connection.flags); - undo_redo->add_undo_method(source, "disconnect", p_connection.signal, callable); + Callable callable = p_cd.get_callable(); + undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), String(p_cd.signal), String(p_cd.method))); + undo_redo->add_do_method(source, "connect", p_cd.signal, callable, varray(), p_cd.flags); + undo_redo->add_undo_method(source, "disconnect", p_cd.signal, callable); undo_redo->add_do_method(this, "update_tree"); undo_redo->add_undo_method(this, "update_tree"); - undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree + undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); // To force redraw of scene tree. undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); undo_redo->commit_action(); @@ -658,17 +658,17 @@ void ConnectionsDock::_connect(ConnectDialog::ConnectionData p_connection) { /* * Break single connection w/ undo-redo functionality. */ -void ConnectionsDock::_disconnect(TreeItem &item) { - Connection cd = item.get_metadata(0); - ConnectDialog::ConnectionData c = cd; +void ConnectionsDock::_disconnect(TreeItem &p_item) { + Connection connection = p_item.get_metadata(0); + ConnectDialog::ConnectionData cd = connection; - ERR_FAIL_COND(c.source != selectedNode); // Shouldn't happen but... Bugcheck. + ERR_FAIL_COND(cd.source != selected_node); // Shouldn't happen but... Bugcheck. - undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), c.signal, c.method)); + undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), cd.signal, cd.method)); - Callable callable = c.get_callable(); - undo_redo->add_do_method(selectedNode, "disconnect", c.signal, callable); - undo_redo->add_undo_method(selectedNode, "connect", c.signal, callable, c.binds, c.flags); + Callable callable = cd.get_callable(); + undo_redo->add_do_method(selected_node, "disconnect", cd.signal, callable); + undo_redo->add_undo_method(selected_node, "connect", cd.signal, callable, cd.binds, cd.flags); undo_redo->add_do_method(this, "update_tree"); undo_redo->add_undo_method(this, "update_tree"); undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); // To force redraw of scene tree. @@ -689,14 +689,14 @@ void ConnectionsDock::_disconnect_all() { } TreeItem *child = item->get_first_child(); - String signalName = item->get_metadata(0).operator Dictionary()["name"]; - undo_redo->create_action(vformat(TTR("Disconnect all from signal: '%s'"), signalName)); + String signal_name = item->get_metadata(0).operator Dictionary()["name"]; + undo_redo->create_action(vformat(TTR("Disconnect all from signal: '%s'"), signal_name)); while (child) { - Connection cd = child->get_metadata(0); - ConnectDialog::ConnectionData c = cd; - undo_redo->add_do_method(selectedNode, "disconnect", c.signal, c.get_callable()); - undo_redo->add_undo_method(selectedNode, "connect", c.signal, c.get_callable(), c.binds, c.flags); + Connection connection = child->get_metadata(0); + ConnectDialog::ConnectionData cd = connection; + undo_redo->add_do_method(selected_node, "disconnect", cd.signal, cd.get_callable()); + undo_redo->add_undo_method(selected_node, "connect", cd.signal, cd.get_callable(), cd.binds, cd.flags); child = child->get_next(); } @@ -737,100 +737,118 @@ void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click. } } -bool ConnectionsDock::_is_item_signal(TreeItem &item) { - return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root()); +bool ConnectionsDock::_is_item_signal(TreeItem &p_item) { + return (p_item.get_parent() == tree->get_root() || p_item.get_parent()->get_parent() == tree->get_root()); } /* * Open connection dialog with TreeItem data to CREATE a brand-new connection. */ -void ConnectionsDock::_open_connection_dialog(TreeItem &item) { - String signal = item.get_metadata(0).operator Dictionary()["name"]; - const String &signalname = signal; - String midname = selectedNode->get_name(); - for (int i = 0; i < midname.length(); i++) { //TODO: Regex filter may be cleaner. - char32_t c = midname[i]; +void ConnectionsDock::_open_connection_dialog(TreeItem &p_item) { + String signal_name = p_item.get_metadata(0).operator Dictionary()["name"]; + const String &signal_name_ref = signal_name; + String node_name = selected_node->get_name(); + for (int i = 0; i < node_name.length(); i++) { // TODO: Regex filter may be cleaner. + char32_t c = node_name[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { if (c == ' ') { // Replace spaces with underlines. c = '_'; } else { // Remove any other characters. - midname.remove_at(i); + node_name.remove_at(i); i--; continue; } } - midname[i] = c; + node_name[i] = c; } - Node *dst_node = selectedNode->get_owner() ? selectedNode->get_owner() : selectedNode; + Node *dst_node = selected_node->get_owner() ? selected_node->get_owner() : selected_node; if (!dst_node || dst_node->get_script().is_null()) { dst_node = _find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root()); } - StringName dst_method = "_on_" + midname + "_" + signal; + Dictionary subst; + + String s = node_name.capitalize().replace(" ", ""); + subst["NodeName"] = s; + if (!s.is_empty()) { + s[0] = s.to_lower()[0]; + } + subst["nodeName"] = s; + subst["node_name"] = node_name.capitalize().replace(" ", "_").to_lower(); - ConnectDialog::ConnectionData c; - c.source = selectedNode; - c.signal = StringName(signalname); - c.target = dst_node; - c.method = dst_method; - connect_dialog->popup_dialog(signalname); - connect_dialog->init(c); + s = signal_name.capitalize().replace(" ", ""); + subst["SignalName"] = s; + if (!s.is_empty()) { + s[0] = s.to_lower()[0]; + } + subst["signalName"] = s; + subst["signal_name"] = signal_name.capitalize().replace(" ", "_").to_lower(); + + String dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_name")).format(subst); + + ConnectDialog::ConnectionData cd; + cd.source = selected_node; + cd.signal = StringName(signal_name_ref); + cd.target = dst_node; + cd.method = StringName(dst_method); + connect_dialog->popup_dialog(signal_name_ref); + connect_dialog->init(cd); connect_dialog->set_title(TTR("Connect a Signal to a Method")); } /* * Open connection dialog with Connection data to EDIT an existing connection. */ -void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToEdit) { - Node *src = Object::cast_to<Node>(cToEdit.source); - Node *dst = Object::cast_to<Node>(cToEdit.target); +void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData p_cd) { + Node *src = Object::cast_to<Node>(p_cd.source); + Node *dst = Object::cast_to<Node>(p_cd.target); if (src && dst) { - const String &signalname = cToEdit.signal; - connect_dialog->set_title(TTR("Edit Connection:") + cToEdit.signal); - connect_dialog->popup_dialog(signalname); - connect_dialog->init(cToEdit, true); + const String &signal_name_ref = p_cd.signal; + connect_dialog->set_title(TTR("Edit Connection:") + p_cd.signal); + connect_dialog->popup_dialog(signal_name_ref); + connect_dialog->init(p_cd, true); } } /* * Open slot method location in script editor. */ -void ConnectionsDock::_go_to_script(TreeItem &item) { - if (_is_item_signal(item)) { +void ConnectionsDock::_go_to_script(TreeItem &p_item) { + if (_is_item_signal(p_item)) { return; } - Connection cd = item.get_metadata(0); - ConnectDialog::ConnectionData c = cd; - ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck + Connection connection = p_item.get_metadata(0); + ConnectDialog::ConnectionData cd = connection; + ERR_FAIL_COND(cd.source != selected_node); // Shouldn't happen but... bugcheck. - if (!c.target) { + if (!cd.target) { return; } - Ref<Script> script = c.target->get_script(); + Ref<Script> script = cd.target->get_script(); if (script.is_null()) { return; } - if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) { + if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, cd.method)) { editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); } } -void ConnectionsDock::_handle_signal_menu_option(int option) { +void ConnectionsDock::_handle_signal_menu_option(int p_option) { TreeItem *item = tree->get_selected(); if (!item) { return; } - switch (option) { + switch (p_option) { case CONNECT: { _open_connection_dialog(*item); } break; @@ -842,17 +860,17 @@ void ConnectionsDock::_handle_signal_menu_option(int option) { } } -void ConnectionsDock::_handle_slot_menu_option(int option) { +void ConnectionsDock::_handle_slot_menu_option(int p_option) { TreeItem *item = tree->get_selected(); if (!item) { return; } - switch (option) { + switch (p_option) { case EDIT: { - Connection c = item->get_metadata(0); - _open_connection_dialog(c); + Connection connection = item->get_metadata(0); + _open_connection_dialog(connection); } break; case GO_TO_SCRIPT: { _go_to_script(*item); @@ -864,14 +882,14 @@ void ConnectionsDock::_handle_slot_menu_option(int option) { } } -void ConnectionsDock::_rmb_pressed(Vector2 position) { +void ConnectionsDock::_rmb_pressed(Vector2 p_position) { TreeItem *item = tree->get_selected(); if (!item) { return; } - Vector2 screen_position = tree->get_screen_position() + position; + Vector2 screen_position = tree->get_screen_position() + p_position; if (_is_item_signal(*item)) { signal_menu->set_position(screen_position); @@ -914,14 +932,14 @@ void ConnectionsDock::_bind_methods() { } void ConnectionsDock::set_node(Node *p_node) { - selectedNode = p_node; + selected_node = p_node; update_tree(); } void ConnectionsDock::update_tree() { tree->clear(); - if (!selectedNode) { + if (!selected_node) { return; } @@ -929,10 +947,10 @@ void ConnectionsDock::update_tree() { List<MethodInfo> node_signals; - selectedNode->get_signal_list(&node_signals); + selected_node->get_signal_list(&node_signals); bool did_script = false; - StringName base = selectedNode->get_class(); + StringName base = selected_node->get_class(); while (base) { List<MethodInfo> node_signals2; @@ -941,7 +959,7 @@ void ConnectionsDock::update_tree() { if (!did_script) { // Get script signals (including signals from any base scripts). - Ref<Script> scr = selectedNode->get_script(); + Ref<Script> scr = selected_node->get_script(); if (scr.is_valid()) { scr->get_script_signal_list(&node_signals2); if (scr->get_path().is_resource_file()) { @@ -1054,45 +1072,45 @@ void ConnectionsDock::update_tree() { signal_item->set_tooltip(0, String(signal_name) + "::" + signaldesc + "::" + descr); } - // List existing connections + // List existing connections. List<Object::Connection> connections; - selectedNode->get_signal_connection_list(signal_name, &connections); + selected_node->get_signal_connection_list(signal_name, &connections); for (const Object::Connection &F : connections) { - Connection cn = F; - if (!(cn.flags & CONNECT_PERSIST)) { + Connection connection = F; + if (!(connection.flags & CONNECT_PERSIST)) { continue; } - ConnectDialog::ConnectionData c = cn; + ConnectDialog::ConnectionData cd = connection; - Node *target = Object::cast_to<Node>(c.target); + Node *target = Object::cast_to<Node>(cd.target); if (!target) { continue; } - String path = String(selectedNode->get_path_to(target)) + " :: " + c.method + "()"; - if (c.flags & CONNECT_DEFERRED) { + String path = String(selected_node->get_path_to(target)) + " :: " + cd.method + "()"; + if (cd.flags & CONNECT_DEFERRED) { path += " (deferred)"; } - if (c.flags & CONNECT_ONESHOT) { + if (cd.flags & CONNECT_ONESHOT) { path += " (oneshot)"; } - if (c.unbinds > 0) { - path += " unbinds(" + itos(c.unbinds) + ")"; - } else if (!c.binds.is_empty()) { + if (cd.unbinds > 0) { + path += " unbinds(" + itos(cd.unbinds) + ")"; + } else if (!cd.binds.is_empty()) { path += " binds("; - for (int i = 0; i < c.binds.size(); i++) { + for (int i = 0; i < cd.binds.size(); i++) { if (i > 0) { path += ", "; } - path += c.binds[i].operator String(); + path += cd.binds[i].operator String(); } path += ")"; } TreeItem *connection_item = tree->create_item(signal_item); connection_item->set_text(0, path); - connection_item->set_metadata(0, cn); + connection_item->set_metadata(0, connection); connection_item->set_icon(0, get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); } } @@ -1164,6 +1182,8 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { tree->connect("item_rmb_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed)); add_theme_constant_override("separation", 3 * EDSCALE); + + EDITOR_DEF("interface/editors/default_signal_callback_name", "_on_{node_name}_{signal_name}"); } ConnectionsDock::~ConnectionsDock() { diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 46f92cec2b..2759c6cfde 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -109,7 +109,7 @@ private: StringName signal; LineEdit *dst_method; ConnectDialogBinds *cdbinds; - bool bEditMode; + bool edit_mode; NodePath dst_path; VBoxContainer *vbc_right; @@ -128,7 +128,7 @@ private: void ok_pressed() override; void _cancel_pressed(); void _item_activated(); - void _text_submitted(const String &_text); + void _text_submitted(const String &p_text); void _tree_node_selected(); void _unbind_count_changed(double p_count); void _add_bind(); @@ -154,7 +154,7 @@ public: bool get_oneshot() const; bool is_editing() const; - void init(ConnectionData c, bool bEdit = false); + void init(ConnectionData p_cd, bool p_edit = false); void popup_dialog(const String &p_for_signal); ConnectDialog(); @@ -184,7 +184,7 @@ class ConnectionsDock : public VBoxContainer { DISCONNECT }; - Node *selectedNode; + Node *selected_node; ConnectionsDockTree *tree; EditorNode *editor; @@ -201,21 +201,21 @@ class ConnectionsDock : public VBoxContainer { void _filter_changed(const String &p_text); void _make_or_edit_connection(); - void _connect(ConnectDialog::ConnectionData p_connection); - void _disconnect(TreeItem &item); + void _connect(ConnectDialog::ConnectionData p_cd); + void _disconnect(TreeItem &p_item); void _disconnect_all(); void _tree_item_selected(); void _tree_item_activated(); - bool _is_item_signal(TreeItem &item); + bool _is_item_signal(TreeItem &p_item); - void _open_connection_dialog(TreeItem &item); - void _open_connection_dialog(ConnectDialog::ConnectionData cToEdit); - void _go_to_script(TreeItem &item); + void _open_connection_dialog(TreeItem &p_item); + void _open_connection_dialog(ConnectDialog::ConnectionData p_cd); + void _go_to_script(TreeItem &p_item); - void _handle_signal_menu_option(int option); - void _handle_slot_menu_option(int option); - void _rmb_pressed(Vector2 position); + void _handle_signal_menu_option(int p_option); + void _handle_slot_menu_option(int p_option); + void _rmb_pressed(Vector2 p_position); void _close(); protected: diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 4d6b2e2750..1de67149c6 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -124,7 +124,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String name = fname; + String name = String::utf8(fname); files_sorted.insert(name); ret = unzGoToNextFile(pkg); @@ -303,7 +303,7 @@ void EditorAssetInstaller::ok_pressed() { char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String name = fname; + String name = String::utf8(fname); if (status_map.has(name) && status_map[name]->is_checked(0)) { String path = status_map[name]->get_metadata(0); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index d681074bf5..014e27ae15 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -620,6 +620,14 @@ String EditorExportPlugin::get_ios_cpp_code() const { return ios_cpp_code; } +void EditorExportPlugin::add_osx_plugin_file(const String &p_path) { + osx_plugin_files.push_back(p_path); +} + +const Vector<String> &EditorExportPlugin::get_osx_plugin_files() const { + return osx_plugin_files; +} + void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) { ios_project_static_libs.push_back(p_path); } @@ -660,6 +668,7 @@ void EditorExportPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_ios_linker_flags", "flags"), &EditorExportPlugin::add_ios_linker_flags); ClassDB::bind_method(D_METHOD("add_ios_bundle_file", "path"), &EditorExportPlugin::add_ios_bundle_file); ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code); + ClassDB::bind_method(D_METHOD("add_osx_plugin_file", "path"), &EditorExportPlugin::add_osx_plugin_file); ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip); GDVIRTUAL_BIND(_export_file, "path", "type", "features"); diff --git a/editor/editor_export.h b/editor/editor_export.h index fd885ad313..3d46ae1996 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -308,6 +308,8 @@ class EditorExportPlugin : public RefCounted { Vector<String> ios_bundle_files; String ios_cpp_code; + Vector<String> osx_plugin_files; + _FORCE_INLINE_ void _clear() { shared_objects.clear(); extra_files.clear(); @@ -321,6 +323,7 @@ class EditorExportPlugin : public RefCounted { ios_plist_content = ""; ios_linker_flags = ""; ios_cpp_code = ""; + osx_plugin_files.clear(); } void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features); @@ -341,6 +344,7 @@ protected: void add_ios_linker_flags(const String &p_flags); void add_ios_bundle_file(const String &p_path); void add_ios_cpp_code(const String &p_code); + void add_osx_plugin_file(const String &p_path); void skip(); @@ -361,6 +365,7 @@ public: String get_ios_linker_flags() const; Vector<String> get_ios_bundle_files() const; String get_ios_cpp_code() const; + const Vector<String> &get_osx_plugin_files() const; EditorExportPlugin(); }; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index b20aee82e6..421d16313a 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -49,6 +49,7 @@ void EditorResourcePicker::_update_resource() { if (edited_resource == RES()) { assign_button->set_icon(Ref<Texture2D>()); assign_button->set_text(TTR("[empty]")); + assign_button->set_tooltip(""); } else { assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object")); @@ -56,14 +57,15 @@ void EditorResourcePicker::_update_resource() { assign_button->set_text(edited_resource->get_name()); } else if (edited_resource->get_path().is_resource_file()) { assign_button->set_text(edited_resource->get_path().get_file()); - assign_button->set_tooltip(edited_resource->get_path()); } else { assign_button->set_text(edited_resource->get_class()); } + String resource_path; if (edited_resource->get_path().is_resource_file()) { - assign_button->set_tooltip(edited_resource->get_path()); + resource_path = edited_resource->get_path() + "\n"; } + assign_button->set_tooltip(resource_path + TTR("Type:") + " " + edited_resource->get_class()); // Preview will override the above, so called at the end. EditorResourcePreview::get_singleton()->queue_edited_resource_preview(edited_resource, this, "_update_resource_preview", edited_resource->get_instance_id()); @@ -514,12 +516,14 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set<String> * } if (p_with_convert) { - if (base == "StandardMaterial3D") { + if (base == "BaseMaterial3D") { p_vector->insert("Texture2D"); } else if (base == "ShaderMaterial") { p_vector->insert("Shader"); } else if (base == "Font") { p_vector->insert("FontData"); + } else if (base == "Texture2D") { + p_vector->insert("Image"); } } } @@ -636,26 +640,46 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) { String at = E->get().strip_edges(); - if (at == "StandardMaterial3D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture2D")) { - Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + if (at == "BaseMaterial3D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture2D")) { + // Use existing resource if possible and only replace its data. + Ref<StandardMaterial3D> mat = edited_resource; + if (!mat.is_valid()) { + mat.instantiate(); + } mat->set_texture(StandardMaterial3D::TextureParam::TEXTURE_ALBEDO, dropped_resource); dropped_resource = mat; break; } if (at == "ShaderMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Shader")) { - Ref<ShaderMaterial> mat = memnew(ShaderMaterial); + Ref<ShaderMaterial> mat = edited_resource; + if (!mat.is_valid()) { + mat.instantiate(); + } mat->set_shader(dropped_resource); dropped_resource = mat; break; } if (at == "Font" && ClassDB::is_parent_class(dropped_resource->get_class(), "FontData")) { - Ref<Font> font = memnew(Font); + Ref<Font> font = edited_resource; + if (!font.is_valid()) { + font.instantiate(); + } font->add_data(dropped_resource); dropped_resource = font; break; } + + if (at == "Texture2D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Image")) { + Ref<ImageTexture> texture = edited_resource; + if (!texture.is_valid()) { + texture.instantiate(); + } + texture->create_from_image(dropped_resource); + dropped_resource = texture; + break; + } } } diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index f12a851388..8c34609e9c 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -396,7 +396,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file = fname; + String file = String::utf8(fname); if (file.ends_with("version.txt")) { Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -457,7 +457,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file_path(String(fname).simplify_path()); + String file_path(String::utf8(fname).simplify_path()); String file = file_path.get_file(); @@ -698,7 +698,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ char fpath[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, nullptr, 0, nullptr, 0); - String path = fpath; + String path = String::utf8(fpath); String base_dir = path.get_base_dir(); if (!path.ends_with("/")) { diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index da45c15573..22b2bd1ed4 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -1755,7 +1755,7 @@ void EditorSceneFormatImporterCollada::get_extensions(List<String> *r_extensions r_extensions->push_back("dae"); } -Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { if (r_err) { *r_err = OK; } @@ -1811,7 +1811,7 @@ Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint3 return state.scene; } -Ref<Animation> EditorSceneFormatImporterCollada::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { +Ref<Animation> EditorSceneFormatImporterCollada::import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) { ColladaImport state; state.use_mesh_builtin_materials = false; diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 90bfcbf4f3..c32d785d1c 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -39,8 +39,8 @@ class EditorSceneFormatImporterCollada : public EditorSceneFormatImporter { public: virtual uint32_t get_import_flags() const override; virtual void get_extensions(List<String> *r_extensions) const override; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) override; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override; + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override; EditorSceneFormatImporterCollada(); }; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index f3f7b7ebd2..96645665aa 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -424,7 +424,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ return OK; } -Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { List<Ref<Mesh>> meshes; Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, false, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps); @@ -459,7 +459,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in return scene; } -Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { +Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) { return Ref<Animation>(); } diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 6f1acc26fa..d7e3f0209d 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -39,8 +39,8 @@ class EditorOBJImporter : public EditorSceneFormatImporter { public: virtual uint32_t get_import_flags() const override; virtual void get_extensions(List<String> *r_extensions) const override; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) override; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override; EditorOBJImporter(); }; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 889c0fbad2..e801cd4553 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -30,9 +30,9 @@ #include "resource_importer_scene.h" +#include "core/error/error_macros.h" #include "core/io/resource_saver.h" #include "editor/editor_node.h" - #include "editor/import/scene_import_settings.h" #include "scene/3d/area_3d.h" #include "scene/3d/collision_shape_3d.h" @@ -73,18 +73,26 @@ void EditorSceneFormatImporter::get_extensions(List<String> *r_extensions) const ERR_FAIL(); } -Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - Object *ret; - if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, p_bake_fps, ret)) { +Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { + Dictionary options_dict; + for (const KeyValue<StringName, Variant> &elem : p_options) { + options_dict[elem.key] = elem.value; + } + Object *ret = nullptr; + if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, options_dict, p_bake_fps, ret)) { return Object::cast_to<Node>(ret); } ERR_FAIL_V(nullptr); } -Ref<Animation> EditorSceneFormatImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { +Ref<Animation> EditorSceneFormatImporter::import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) { + Dictionary options_dict; + for (const KeyValue<StringName, Variant> &elem : p_options) { + options_dict[elem.key] = elem.value; + } Ref<Animation> ret; - if (GDVIRTUAL_CALL(_import_animation, p_path, p_flags, p_bake_fps, ret)) { + if (GDVIRTUAL_CALL(_import_animation, p_path, p_flags, options_dict, p_bake_fps, ret)) { return ret; } @@ -101,25 +109,11 @@ Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, c return ret; } -//for documenters, these functions are useful when an importer calls an external conversion helper (like, fbx2gltf), -//and you want to load the resulting file - -Node *EditorSceneFormatImporter::import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) { - return ResourceImporterScene::get_singleton()->import_scene_from_other_importer(this, p_path, p_flags, p_bake_fps); -} - -Ref<Animation> EditorSceneFormatImporter::import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) { - return ResourceImporterScene::get_singleton()->import_animation_from_other_importer(this, p_path, p_flags, p_bake_fps); -} - void EditorSceneFormatImporter::_bind_methods() { - ClassDB::bind_method(D_METHOD("import_scene_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneFormatImporter::import_scene_from_other_importer); - ClassDB::bind_method(D_METHOD("import_animation_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneFormatImporter::import_animation_from_other_importer); - GDVIRTUAL_BIND(_get_import_flags); GDVIRTUAL_BIND(_get_extensions); - GDVIRTUAL_BIND(_import_scene, "path", "flags", "bake_fps"); - GDVIRTUAL_BIND(_import_animation, "path", "flags", "bake_fps"); + GDVIRTUAL_BIND(_import_scene, "path", "flags", "options", "bake_fps"); + GDVIRTUAL_BIND(_import_animation, "path", "flags", "options", "bake_fps"); GDVIRTUAL_BIND(_get_import_options, "path"); GDVIRTUAL_BIND(_get_option_visibility, "path", "option"); @@ -1473,64 +1467,6 @@ void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_ } } -Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) { - Ref<EditorSceneFormatImporter> importer; - String ext = p_path.get_extension().to_lower(); - - for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) { - if (E->get().ptr() == p_exception) { - continue; - } - List<String> extensions; - E->get()->get_extensions(&extensions); - - for (const String &F : extensions) { - if (F.to_lower() == ext) { - importer = E->get(); - break; - } - } - - if (importer.is_valid()) { - break; - } - } - - ERR_FAIL_COND_V(!importer.is_valid(), nullptr); - - List<String> missing; - Error err; - return importer->import_scene(p_path, p_flags, p_bake_fps, &missing, &err); -} - -Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) { - Ref<EditorSceneFormatImporter> importer; - String ext = p_path.get_extension().to_lower(); - - for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) { - if (E->get().ptr() == p_exception) { - continue; - } - List<String> extensions; - E->get()->get_extensions(&extensions); - - for (const String &F : extensions) { - if (F.to_lower() == ext) { - importer = E->get(); - break; - } - } - - if (importer.is_valid()) { - break; - } - } - - ERR_FAIL_COND_V(!importer.is_valid(), nullptr); - - return importer->import_animation(p_path, p_flags, p_bake_fps); -} - void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_mesh_data, bool p_generate_lods, bool p_create_shadow_meshes, LightBakeMode p_light_bake_mode, float p_lightmap_texel_size, const Vector<uint8_t> &p_src_lightmap_cache, Vector<Vector<uint8_t>> &r_lightmap_caches) { ImporterMeshInstance3D *src_mesh_node = Object::cast_to<ImporterMeshInstance3D>(p_node); if (src_mesh_node) { @@ -1886,7 +1822,7 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) { ERR_FAIL_COND_V(!importer.is_valid(), nullptr); Error err = OK; - Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, 15, nullptr, &err); + Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, Map<StringName, Variant>(), 15, nullptr, &err); if (!scene || err != OK) { return nullptr; } @@ -1944,7 +1880,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p Error err = OK; List<String> missing_deps; // for now, not much will be done with this - Node *scene = importer->import_scene(src_path, import_flags, fps, &missing_deps, &err); + Node *scene = importer->import_scene(src_path, import_flags, p_options, fps, &missing_deps, &err); if (!scene || err != OK) { return err; } @@ -2121,7 +2057,7 @@ void EditorSceneFormatImporterESCN::get_extensions(List<String> *r_extensions) c r_extensions->push_back("escn"); } -Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { Error error; Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'."); @@ -2132,6 +2068,6 @@ Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t return scene; } -Ref<Animation> EditorSceneFormatImporterESCN::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { +Ref<Animation> EditorSceneFormatImporterESCN::import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) { ERR_FAIL_V(Ref<Animation>()); } diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 17ae0e797b..00d095eac1 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -31,7 +31,9 @@ #ifndef RESOURCEIMPORTERSCENE_H #define RESOURCEIMPORTERSCENE_H +#include "core/error/error_macros.h" #include "core/io/resource_importer.h" +#include "core/variant/dictionary.h" #include "scene/3d/node_3d.h" #include "scene/resources/animation.h" #include "scene/resources/mesh.h" @@ -48,13 +50,13 @@ class EditorSceneFormatImporter : public RefCounted { protected: static void _bind_methods(); - Node *import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps); - Ref<Animation> import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps); + Node *import_scene_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options, int p_bake_fps); + Ref<Animation> import_animation_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options, int p_bake_fps); GDVIRTUAL0RC(int, _get_import_flags) GDVIRTUAL0RC(Vector<String>, _get_extensions) - GDVIRTUAL3R(Object *, _import_scene, String, uint32_t, uint32_t) - GDVIRTUAL3R(Ref<Animation>, _import_animation, String, uint32_t, uint32_t) + GDVIRTUAL4R(Object *, _import_scene, String, uint32_t, Dictionary, uint32_t) + GDVIRTUAL4R(Ref<Animation>, _import_animation, String, uint32_t, Dictionary, uint32_t) GDVIRTUAL1(_get_import_options, String) GDVIRTUAL2RC(Variant, _get_option_visibility, String, String) @@ -69,8 +71,8 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps); virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options); virtual Variant get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options); @@ -270,9 +272,6 @@ public: Node *pre_import(const String &p_source_file); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; - Node *import_scene_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps); - Ref<Animation> import_animation_from_other_importer(EditorSceneFormatImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps); - virtual bool has_advanced_options() const override; virtual void show_advanced_options(const String &p_path) override; @@ -293,8 +292,8 @@ class EditorSceneFormatImporterESCN : public EditorSceneFormatImporter { public: virtual uint32_t get_import_flags() const override; virtual void get_extensions(List<String> *r_extensions) const override; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) override; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override; }; #include "scene/resources/box_shape_3d.h" diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 09c02465a7..ab1be7f41b 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -31,6 +31,7 @@ #include "import_dock.h" #include "editor_node.h" #include "editor_resource_preview.h" +#include "editor_scale.h" class ImportDockParameters : public Object { GDCLASS(ImportDockParameters, Object); @@ -135,6 +136,8 @@ void ImportDock::set_edit_path(const String &p_path) { _set_dirty(false); import_as->set_disabled(false); preset->set_disabled(false); + content->show(); + select_a_resource->hide(); imported->set_text(p_path.get_file()); } @@ -423,6 +426,8 @@ void ImportDock::clear() { params->properties.clear(); params->update(); preset->get_popup()->clear(); + content->hide(); + select_a_resource->show(); } static bool _find_owners(EditorFileSystemDirectory *efsd, const String &p_path) { @@ -600,12 +605,18 @@ void ImportDock::initialize_import_options() const { ImportDock::ImportDock() { set_name("Import"); + + content = memnew(VBoxContainer); + content->set_v_size_flags(SIZE_EXPAND_FILL); + add_child(content); + content->hide(); + imported = memnew(Label); imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); imported->set_clip_text(true); - add_child(imported); + content->add_child(imported); HBoxContainer *hb = memnew(HBoxContainer); - add_margin_child(TTR("Import As:"), hb); + content->add_margin_child(TTR("Import As:"), hb); import_as = memnew(OptionButton); import_as->set_disabled(true); import_as->connect("item_selected", callable_mp(this, &ImportDock::_importer_selected)); @@ -618,13 +629,13 @@ ImportDock::ImportDock() { hb->add_child(preset); import_opts = memnew(EditorInspector); - add_child(import_opts); + content->add_child(import_opts); import_opts->set_v_size_flags(SIZE_EXPAND_FILL); import_opts->connect("property_edited", callable_mp(this, &ImportDock::_property_edited)); import_opts->connect("property_toggled", callable_mp(this, &ImportDock::_property_toggled)); hb = memnew(HBoxContainer); - add_child(hb); + content->add_child(hb); import = memnew(Button); import->set_text(TTR("Reimport")); import->set_disabled(true); @@ -652,7 +663,7 @@ ImportDock::ImportDock() { reimport_confirm = memnew(ConfirmationDialog); reimport_confirm->get_ok_button()->set_text(TTR("Save Scenes, Re-Import, and Restart")); - add_child(reimport_confirm); + content->add_child(reimport_confirm); reimport_confirm->connect("confirmed", callable_mp(this, &ImportDock::_reimport_and_restart)); VBoxContainer *vbc_confirm = memnew(VBoxContainer()); @@ -662,6 +673,15 @@ ImportDock::ImportDock() { reimport_confirm->add_child(vbc_confirm); params = memnew(ImportDockParameters); + + select_a_resource = memnew(Label); + select_a_resource->set_text(TTR("Select a resource file in the filesystem or in the inspector to adjust import settings.")); + select_a_resource->set_autowrap_mode(Label::AUTOWRAP_WORD); + select_a_resource->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); + select_a_resource->set_v_size_flags(SIZE_EXPAND_FILL); + select_a_resource->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + select_a_resource->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); + add_child(select_a_resource); } ImportDock::~ImportDock() { diff --git a/editor/import_dock.h b/editor/import_dock.h index d21f0d507d..33fc23f1b4 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -62,6 +62,9 @@ class ImportDock : public VBoxContainer { ImportDockParameters *params; + VBoxContainer *content; + Label *select_a_resource; + void _preset_selected(int p_idx); void _importer_selected(int i_idx); void _update_options(const String &p_path, const Ref<ConfigFile> &p_config = Ref<ConfigFile>()); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index d6fd153665..089c37d7a6 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2097,8 +2097,16 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (k.is_valid() && k->is_pressed() && (tool == TOOL_SELECT || tool == TOOL_MOVE) && (k->get_keycode() == Key::UP || k->get_keycode() == Key::DOWN || k->get_keycode() == Key::LEFT || k->get_keycode() == Key::RIGHT)) { if (!k->is_echo()) { - // Start moving the canvas items with the keyboard - drag_selection = _get_edited_canvas_items(); + // Start moving the canvas items with the keyboard, if they are movable + List<CanvasItem *> selection = _get_edited_canvas_items(); + + drag_selection.clear(); + for (CanvasItem *item : selection) { + if (_is_node_movable(item, true)) { + drag_selection.push_back(item); + } + } + drag_type = DRAG_KEY_MOVE; drag_from = Vector2(); drag_to = Vector2(); @@ -5852,7 +5860,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(path)); - editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene); + editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene, true); editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", editor->get_edited_scene()); editor_data->get_undo_redo().add_do_reference(instantiated_scene); editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instantiated_scene); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index c86f6c02cb..957d1483bc 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -954,7 +954,7 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b real_t col_d = 1e20; for (int i = 0; i < 3; i++) { - const Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gizmo_scale * (GIZMO_ARROW_OFFSET + (GIZMO_ARROW_SIZE * 0.5)); + const Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i).normalized() * gizmo_scale * (GIZMO_ARROW_OFFSET + (GIZMO_ARROW_SIZE * 0.5)); const real_t grabber_radius = gizmo_scale * GIZMO_ARROW_SIZE; Vector3 r; @@ -1058,7 +1058,7 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b float col_d = 1e20; for (int i = 0; i < 3; i++) { - const Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gizmo_scale * GIZMO_SCALE_OFFSET; + const Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i).normalized() * gizmo_scale * GIZMO_SCALE_OFFSET; const real_t grabber_radius = gizmo_scale * GIZMO_ARROW_SIZE; Vector3 r; @@ -1138,68 +1138,62 @@ void Node3DEditorViewport::_transform_gizmo_apply(Node3D *p_node, const Transfor } } -Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local) { +Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local, bool p_orthogonal) { switch (p_mode) { case TRANSFORM_SCALE: { + if (_edit.snap || spatial_editor->is_snap_enabled()) { + p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + Transform3D s; if (p_local) { - Basis g = p_original.basis.orthonormalized(); - Vector3 local_motion = g.inverse().xform(p_motion); - - if (_edit.snap || spatial_editor->is_snap_enabled()) { - local_motion.snap(Vector3(p_extra, p_extra, p_extra)); - } - - Transform3D local_t; - local_t.basis = p_original_local.basis.scaled_local(local_motion + Vector3(1, 1, 1)); - local_t.origin = p_original_local.origin; - return local_t; + s.basis = p_original_local.basis.scaled_local(p_motion + Vector3(1, 1, 1)); + s.origin = p_original_local.origin; } else { + s.basis.scale(p_motion + Vector3(1, 1, 1)); Transform3D base = Transform3D(Basis(), _edit.center); - if (_edit.snap || spatial_editor->is_snap_enabled()) { - p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + s = base * (s * (base.inverse() * p_original)); + + // Recalculate orthogonalized scale without moving origin. + if (p_orthogonal) { + s.basis = p_original_local.basis.scaled_orthogonal(p_motion + Vector3(1, 1, 1)); + // The scaled_orthogonal() does not require orthogonal Basis, + // but it may make a bit skew by precision problems. + s.basis.orthogonalize(); } - - Transform3D global_t; - global_t.basis.scale(p_motion + Vector3(1, 1, 1)); - return base * (global_t * (base.inverse() * p_original)); } + + return s; } case TRANSFORM_TRANSLATE: { - if (p_local) { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - Basis g = p_original.basis.orthonormalized(); - Vector3 local_motion = g.inverse().xform(p_motion); - local_motion.snap(Vector3(p_extra, p_extra, p_extra)); - - p_motion = g.xform(local_motion); - } + if (_edit.snap || spatial_editor->is_snap_enabled()) { + p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } - } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - p_motion.snap(Vector3(p_extra, p_extra, p_extra)); - } + if (p_local) { + p_motion = p_original.basis.xform(p_motion); } // Apply translation Transform3D t = p_original; t.origin += p_motion; + return t; } case TRANSFORM_ROTATE: { + Transform3D r; + if (p_local) { - Transform3D r; Vector3 axis = p_original_local.basis.xform(p_motion); r.basis = Basis(axis.normalized(), p_extra) * p_original_local.basis; r.origin = p_original_local.origin; - return r; } else { - Transform3D r; Basis local = p_original.basis * p_original_local.basis.inverse(); Vector3 axis = local.xform_inv(p_motion); r.basis = local * Basis(axis.normalized(), p_extra) * p_original_local.basis; r.origin = Basis(p_motion, p_extra).xform(p_original.origin - _edit.center) + _edit.center; - return r; } + + return r; } default: { ERR_FAIL_V_MSG(Transform3D(), "Invalid mode in '_compute_transform'"); @@ -1480,6 +1474,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.original_mouse_pos = b->get_position(); _edit.snap = spatial_editor->is_snap_enabled(); _edit.mode = TRANSFORM_NONE; + _edit.original = spatial_editor->get_gizmo_transform(); // To prevent to break when flipping with scale. bool can_select_gizmos = spatial_editor->get_single_selected_node(); @@ -1783,30 +1778,30 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { plane = Plane(_get_camera_normal(), _edit.center); break; case TRANSFORM_X_AXIS: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(); plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center); break; case TRANSFORM_Y_AXIS: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(); plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center); break; case TRANSFORM_Z_AXIS: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(); plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center); break; case TRANSFORM_YZ: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1); - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0), _edit.center); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center); plane_mv = true; break; case TRANSFORM_XZ: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0); - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1), _edit.center); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center); plane_mv = true; break; case TRANSFORM_XY: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1); - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2), _edit.center); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center); plane_mv = true; break; } @@ -1857,6 +1852,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { // This might not be necessary anymore after issue #288 is solved (in 4.0?). set_message(TTR("Scaling: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " + String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); + motion = _edit.original.basis.inverse().xform(motion); List<Node *> &selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { @@ -1877,14 +1873,14 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (se->gizmo.is_valid()) { for (KeyValue<int, Transform3D> &GE : se->subgizmos) { Transform3D xform = GE.value; - Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords); + Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo. if (!local_coords) { new_xform = se->original.affine_inverse() * new_xform; } se->gizmo->set_subgizmo_transform(GE.key, new_xform); } } else { - Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords); + Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS); _transform_gizmo_apply(se->sp, new_xform, local_coords); } } @@ -1904,27 +1900,27 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { plane = Plane(_get_camera_normal(), _edit.center); break; case TRANSFORM_X_AXIS: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(); plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center); break; case TRANSFORM_Y_AXIS: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(); plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center); break; case TRANSFORM_Z_AXIS: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2); + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(); plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center); break; case TRANSFORM_YZ: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0), _edit.center); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center); plane_mv = true; break; case TRANSFORM_XZ: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1), _edit.center); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center); plane_mv = true; break; case TRANSFORM_XY: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2), _edit.center); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center); plane_mv = true; break; } @@ -1956,6 +1952,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion_snapped.snap(Vector3(snap, snap, snap)); set_message(TTR("Translating: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " + String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); + motion = spatial_editor->get_gizmo_transform().basis.inverse().xform(motion); List<Node *> &selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { @@ -1976,12 +1973,12 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (se->gizmo.is_valid()) { for (KeyValue<int, Transform3D> &GE : se->subgizmos) { Transform3D xform = GE.value; - Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords); + Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo. new_xform = se->original.affine_inverse() * new_xform; se->gizmo->set_subgizmo_transform(GE.key, new_xform); } } else { - Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords); + Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS); _transform_gizmo_apply(se->sp, new_xform, false); } } @@ -2000,15 +1997,15 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { plane = Plane(_get_camera_normal(), _edit.center); break; case TRANSFORM_X_AXIS: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0), _edit.center); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center); axis = Vector3(1, 0, 0); break; case TRANSFORM_Y_AXIS: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1), _edit.center); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center); axis = Vector3(0, 1, 0); break; case TRANSFORM_Z_AXIS: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2), _edit.center); + plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center); axis = Vector3(0, 0, 1); break; case TRANSFORM_YZ: @@ -2063,14 +2060,14 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (KeyValue<int, Transform3D> &GE : se->subgizmos) { Transform3D xform = GE.value; - Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords); + Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords, true); // Force orthogonal with subgizmo. if (!local_coords) { new_xform = se->original.affine_inverse() * new_xform; } se->gizmo->set_subgizmo_transform(GE.key, new_xform); } } else { - Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords); + Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS); _transform_gizmo_apply(se->sp, new_xform, local_coords); } } @@ -3676,8 +3673,6 @@ void Node3DEditorViewport::update_transform_gizmo_view() { subviewport_container->get_stretch_shrink(); Vector3 scale = Vector3(1, 1, 1) * gizmo_scale; - xform.basis.scale(scale); - // if the determinant is zero, we should disable the gizmo from being rendered // this prevents supplying bad values to the renderer and then having to filter it out again if (xform.basis.determinant() == 0) { @@ -3694,18 +3689,26 @@ void Node3DEditorViewport::update_transform_gizmo_view() { } for (int i = 0; i < 3; i++) { - RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform); + Transform3D axis_angle = Transform3D(); + if (xform.basis.get_axis(i).normalized().dot(xform.basis.get_axis((i + 1) % 3).normalized()) < 1.0) { + axis_angle = axis_angle.looking_at(xform.basis.get_axis(i).normalized(), xform.basis.get_axis((i + 1) % 3).normalized()); + } + axis_angle.basis.scale(scale); + axis_angle.origin = xform.origin; + RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); - RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); - RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)); - RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); - RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], axis_angle); RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); } // Rotation white outline + xform.orthonormalize(); + xform.basis.scale(scale); RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[3], xform); RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)); } @@ -4127,7 +4130,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(path)); } - editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene); + editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene, true); editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", editor->get_edited_scene()); editor_data->get_undo_redo().add_do_reference(instantiated_scene); editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instantiated_scene); @@ -4915,7 +4918,6 @@ void Node3DEditor::update_transform_gizmo() { gizmo_center += xf.origin; if (count == 0 && local_gizmo_coords) { gizmo_basis = xf.basis; - gizmo_basis.orthonormalize(); } count++; } @@ -4940,7 +4942,6 @@ void Node3DEditor::update_transform_gizmo() { gizmo_center += xf.origin; if (count == 0 && local_gizmo_coords) { gizmo_basis = xf.basis; - gizmo_basis.orthonormalize(); } count++; } @@ -5815,6 +5816,12 @@ void fragment() { { //move gizmo + // Inverted zxy. + Vector3 ivec = Vector3(0, 0, -1); + Vector3 nivec = Vector3(-1, -1, 0); + Vector3 ivec2 = Vector3(-1, 0, 0); + Vector3 ivec3 = Vector3(0, -1, 0); + for (int i = 0; i < 3; i++) { Color col; switch (i) { @@ -5852,16 +5859,6 @@ void fragment() { mat_hl->set_albedo(albedo); gizmo_color_hl[i] = mat_hl; - Vector3 ivec; - ivec[i] = 1; - Vector3 nivec; - nivec[(i + 1) % 3] = 1; - nivec[(i + 2) % 3] = 1; - Vector3 ivec2; - ivec2[(i + 1) % 3] = 1; - Vector3 ivec3; - ivec3[(i + 2) % 3] = 1; - //translate { Ref<SurfaceTool> surftool = memnew(SurfaceTool); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index eba3989f9d..8d42e88b53 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -399,7 +399,7 @@ private: void _project_settings_changed(); - Transform3D _compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local); + Transform3D _compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local, bool p_orthogonal); protected: void _notification(int p_what); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index ab5c9a0ef1..97a882c383 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -238,10 +238,6 @@ void ScriptTextEditor::_show_warnings_panel(bool p_show) { void ScriptTextEditor::_warning_clicked(Variant p_line) { if (p_line.get_type() == Variant::INT) { goto_line_centered(p_line.operator int64_t()); - } else if (p_line.get_type() == Variant::DICTIONARY) { - Dictionary meta = p_line.operator Dictionary(); - code_editor->get_text_editor()->insert_line_at(meta["line"].operator int64_t() - 1, "# warning-ignore:" + meta["code"].operator String()); - _validate_script(); } } @@ -468,20 +464,8 @@ void ScriptTextEditor::_validate_script() { } // Add script warnings. - warnings_panel->push_table(3); + warnings_panel->push_table(2); for (const ScriptLanguage::Warning &w : warnings) { - Dictionary ignore_meta; - ignore_meta["line"] = w.start_line; - ignore_meta["code"] = w.string_code.to_lower(); - warnings_panel->push_cell(); - warnings_panel->push_meta(ignore_meta); - warnings_panel->push_color( - warnings_panel->get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(warnings_panel->get_theme_color(SNAME("mono_color"), SNAME("Editor")), 0.5)); - warnings_panel->add_text(TTR("[Ignore]")); - warnings_panel->pop(); // Color. - warnings_panel->pop(); // Meta ignore. - warnings_panel->pop(); // Cell. - warnings_panel->push_cell(); warnings_panel->push_meta(w.start_line - 1); warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 4b7380c83f..08e0f7ae30 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -204,7 +204,7 @@ private: char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - if (String(fname).ends_with("project.godot")) { + if (String::utf8(fname).ends_with("project.godot")) { break; } @@ -524,7 +524,7 @@ private: char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String name = fname; + String name = String::utf8(fname); if (name.ends_with("project.godot")) { zip_root = name.substr(0, name.rfind("project.godot")); break; @@ -544,7 +544,7 @@ private: char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String path = fname; + String path = String::utf8(fname); if (path.is_empty() || path == zip_root || !zip_root.is_subsequence_of(path)) { // |