Implement naming version system for FBX and Blend importers like glTF

This commit is contained in:
Aaron Franke 2025-06-10 00:41:33 -07:00
parent db57f282fa
commit a56b3a93d3
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
7 changed files with 55 additions and 2 deletions

View file

@ -98,6 +98,10 @@ Node *EditorSceneFormatImporterFBX2GLTF::import_scene(const String &p_path, uint
gltf.instantiate();
Ref<GLTFState> state;
state.instantiate();
if (p_options.has("fbx/naming_version")) {
int naming_version = p_options["fbx/naming_version"];
gltf->set_naming_version(naming_version);
}
if (p_options.has(SNAME("nodes/import_as_skeleton_bones")) ? (bool)p_options[SNAME("nodes/import_as_skeleton_bones")] : false) {
state->set_import_as_skeleton_bones(true);
}
@ -133,10 +137,17 @@ Variant EditorSceneFormatImporterFBX2GLTF::get_option_visibility(const String &p
void EditorSceneFormatImporterFBX2GLTF::get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) {
// This function must be empty to avoid both FBX2glTF and UFBX adding the same options to FBX files.
}
void EditorSceneFormatImporterFBX2GLTF::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;
}
if (!p_import_params.has("fbx/naming_version")) {
// If a .fbx's existing import file is missing the FBX
// naming compatibility version, we need to use version 1.
// Version 1 is the behavior before this option was added.
p_import_params["fbx/naming_version"] = 1;
}
}

View file

@ -59,6 +59,10 @@ Node *EditorSceneFormatImporterUFBX::import_scene(const String &p_path, uint32_t
state.instantiate();
print_verbose(vformat("FBX path: %s", p_path));
String path = ProjectSettings::get_singleton()->globalize_path(p_path);
if (p_options.has("fbx/naming_version")) {
int naming_version = p_options["fbx/naming_version"];
fbx->set_naming_version(naming_version);
}
bool allow_geometry_helper_nodes = p_options.has("fbx/allow_geometry_helper_nodes") ? (bool)p_options["fbx/allow_geometry_helper_nodes"] : false;
if (allow_geometry_helper_nodes) {
state->set_allow_geometry_helper_nodes(allow_geometry_helper_nodes);
@ -94,6 +98,7 @@ void EditorSceneFormatImporterUFBX::get_import_options(const String &p_path,
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "fbx/importer", PROPERTY_HINT_ENUM, "ufbx,FBX2glTF"), FBX_IMPORTER_UFBX));
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::BOOL, "fbx/allow_geometry_helper_nodes"), false));
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "fbx/embedded_image_handling", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed as Basis Universal,Embed as Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), FBXState::HANDLE_BINARY_EXTRACT_TEXTURES));
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "fbx/naming_version", PROPERTY_HINT_ENUM, "Godot 4.0 or 4.1,Godot 4.2 to 4.4,Godot 4.5 or later"), 2));
}
}
@ -101,4 +106,10 @@ void EditorSceneFormatImporterUFBX::handle_compatibility_options(HashMap<StringN
if (!p_import_params.has("fbx/importer")) {
p_import_params["fbx/importer"] = EditorSceneFormatImporterUFBX::FBX_IMPORTER_FBX2GLTF;
}
if (!p_import_params.has("fbx/naming_version")) {
// If a .fbx's existing import file is missing the FBX
// naming compatibility version, we need to use version 1.
// Version 1 is the behavior before this option was added.
p_import_params["fbx/naming_version"] = 1;
}
}