From 97a3a662205d598dad195fa72d2dcb2f19c21088 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 19 Mar 2021 09:57:52 -0300 Subject: Improved 3D Scene Importer * Added option for importers to show an Advanced settings dialog * Created advanced settings dialog for Scene Importer * Cleaned up importers (remove many old/unused options) * Added the ability to customize every node, material, mesh and animation individually * Saving to animations and meshes to files is now a manual process, making it more predictable * Added the ability for materials to be replaced by external files (or to be made external, up to you). * When doubleclicking an impoted scene in the filesystem dock, it automatically shows the import settings instead of asking to open it. WARNING: Lightmap UV unwrap is not working, it needs to be re-made. --- editor/editor_file_system.cpp | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'editor/editor_file_system.cpp') diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index dce022e86e..dbbd762b5e 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1668,7 +1668,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector return err; } -void EditorFileSystem::_reimport_file(const String &p_file) { +void EditorFileSystem::_reimport_file(const String &p_file, const Map *p_custom_options, const String &p_custom_importer) { EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(p_file, &fs, cpos); @@ -1677,23 +1677,32 @@ void EditorFileSystem::_reimport_file(const String &p_file) { //try to obtain existing params Map params; - String importer_name; + String importer_name; //empty by default though + + if (p_custom_importer != String()) { + importer_name = p_custom_importer; + } + if (p_custom_options != nullptr) { + params = *p_custom_options; + } if (FileAccess::exists(p_file + ".import")) { //use existing - Ref cf; - cf.instance(); - Error err = cf->load(p_file + ".import"); - if (err == OK) { - if (cf->has_section("params")) { - List sk; - cf->get_section_keys("params", &sk); - for (List::Element *E = sk.front(); E; E = E->next()) { - params[E->get()] = cf->get_value("params", E->get()); + if (p_custom_options == nullptr) { + Ref cf; + cf.instance(); + Error err = cf->load(p_file + ".import"); + if (err == OK) { + if (cf->has_section("params")) { + List sk; + cf->get_section_keys("params", &sk); + for (List::Element *E = sk.front(); E; E = E->next()) { + params[E->get()] = cf->get_value("params", E->get()); + } + } + if (p_custom_importer != String() && cf->has_section("remap")) { + importer_name = cf->get_value("remap", "importer"); } - } - if (cf->has_section("remap")) { - importer_name = cf->get_value("remap", "importer"); } } @@ -1887,6 +1896,10 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map &p_custom_params) { + _reimport_file(p_file, &p_custom_params, p_importer); +} + void EditorFileSystem::reimport_files(const Vector &p_files) { { // Ensure that ProjectSettings::IMPORTED_FILES_PATH exists. -- cgit v1.2.3