From c433754d3483515aab7a4201f12f83fcbd1050b3 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Mon, 20 May 2024 02:56:57 -0700 Subject: [PATCH] fbx: change import option defaults ufbx has special logic to handle animation/trimming, and most users expect trimming to be on. For existing projects, we should upgrade files0 to FBX2glTF to preserve node compatibility. --- editor/import/3d/resource_importer_scene.cpp | 3 ++- editor/import_dock.cpp | 14 ++++++++++++-- modules/fbx/editor/editor_scene_importer_ufbx.cpp | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 070c44419a62..23c22a80493c 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -2329,6 +2329,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, Listpush_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/apply_root_scale"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); @@ -2342,7 +2343,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, Listpush_back(ImportOption(PropertyInfo(Variant::BOOL, "skins/use_named_skins"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 30)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/trimming"), false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/trimming"), trimming_defaults_on)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/remove_immutable_tracks"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import_rest_as_RESET"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "import_script/path", PROPERTY_HINT_FILE, script_ext_hint), "")); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index fbe76e1d5c72..2d87e6592fca 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -188,10 +188,20 @@ void ImportDock::_update_options(const String &p_path, const Ref &p_ params->checked.clear(); params->base_options_path = p_path; + HashMap import_options; + List section_keys; + p_config->get_section_keys("params", §ion_keys); + for (const String §ion_key : section_keys) { + import_options[section_key] = p_config->get_value("params", section_key); + } + if (params->importer.is_valid()) { + params->importer->handle_compatibility_options(import_options); + } + for (const ResourceImporter::ImportOption &E : options) { params->properties.push_back(E.option); - if (p_config.is_valid() && p_config->has_section_key("params", E.option.name)) { - params->values[E.option.name] = p_config->get_value("params", E.option.name); + if (p_config.is_valid() && import_options.has(E.option.name)) { + params->values[E.option.name] = import_options[E.option.name]; } else { params->values[E.option.name] = E.default_value; } diff --git a/modules/fbx/editor/editor_scene_importer_ufbx.cpp b/modules/fbx/editor/editor_scene_importer_ufbx.cpp index 3cc919fae2ca..e0f60fe998a4 100644 --- a/modules/fbx/editor/editor_scene_importer_ufbx.cpp +++ b/modules/fbx/editor/editor_scene_importer_ufbx.cpp @@ -111,7 +111,7 @@ void EditorSceneFormatImporterUFBX::get_import_options(const String &p_path, void EditorSceneFormatImporterUFBX::handle_compatibility_options(HashMap &p_import_params) const { if (!p_import_params.has("fbx/importer")) { - p_import_params["fbx/importer"] = EditorSceneFormatImporterUFBX::FBX_IMPORTER_UFBX; + p_import_params["fbx/importer"] = EditorSceneFormatImporterUFBX::FBX_IMPORTER_FBX2GLTF; } }