Merge pull request #92197 from lyuma/better_fbx_defaults

FBX: Change trimming default and use FBX2glTF for compatibility
This commit is contained in:
Rémi Verschelde 2024-05-21 23:18:59 +02:00
commit 03aa82849d
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 15 additions and 4 deletions

View File

@ -2329,6 +2329,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import
}
script_ext_hint += "*." + E;
}
bool trimming_defaults_on = p_path.get_extension().to_lower() == "fbx";
r_options->push_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, List<Import
r_options->push_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), ""));

View File

@ -188,10 +188,20 @@ void ImportDock::_update_options(const String &p_path, const Ref<ConfigFile> &p_
params->checked.clear();
params->base_options_path = p_path;
HashMap<StringName, Variant> import_options;
List<String> section_keys;
p_config->get_section_keys("params", &section_keys);
for (const String &section_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;
}

View File

@ -111,7 +111,7 @@ void EditorSceneFormatImporterUFBX::get_import_options(const String &p_path,
void EditorSceneFormatImporterUFBX::handle_compatibility_options(HashMap<StringName, Variant> &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;
}
}