Merge pull request #94058 from Hilderin/fix-scene-project-importation-settings
Fix missing options in Project Import Defaults
This commit is contained in:
commit
2380ed5e1b
|
@ -291,14 +291,18 @@ bool ResourceImporterScene::get_option_visibility(const String &p_path, const St
|
|||
for (int i = 0; i < post_importer_plugins.size(); i++) {
|
||||
Variant ret = post_importer_plugins.write[i]->get_option_visibility(p_path, animation_importer, p_option, p_options);
|
||||
if (ret.get_type() == Variant::BOOL) {
|
||||
return ret;
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Ref<EditorSceneFormatImporter> importer : scene_importers) {
|
||||
Variant ret = importer->get_option_visibility(p_path, animation_importer, p_option, p_options);
|
||||
if (ret.get_type() == Variant::BOOL) {
|
||||
return ret;
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,31 +431,39 @@ void ImportDock::_importer_selected(int i_idx) {
|
|||
|
||||
void ImportDock::_preset_selected(int p_idx) {
|
||||
int item_id = preset->get_popup()->get_item_id(p_idx);
|
||||
String setting_name = "importer_defaults/" + params->importer->get_importer_name();
|
||||
|
||||
switch (item_id) {
|
||||
case ITEM_SET_AS_DEFAULT: {
|
||||
Dictionary d;
|
||||
|
||||
for (const PropertyInfo &E : params->properties) {
|
||||
d[E.name] = params->values[E.name];
|
||||
Dictionary import_settings;
|
||||
// When import settings already exist, we will update these settings
|
||||
// to ensure that the dictionary retains settings that are not displayed in the
|
||||
// editor. For Scene, the dictionary is the same for FBX, GLTF, and Blender, but each
|
||||
// file type has some different settings.
|
||||
if (ProjectSettings::get_singleton()->has_setting(setting_name)) {
|
||||
import_settings = GLOBAL_GET(setting_name);
|
||||
}
|
||||
|
||||
ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), d);
|
||||
for (const PropertyInfo &E : params->properties) {
|
||||
import_settings[E.name] = params->values[E.name];
|
||||
}
|
||||
|
||||
ProjectSettings::get_singleton()->set(setting_name, import_settings);
|
||||
ProjectSettings::get_singleton()->save();
|
||||
_update_preset_menu();
|
||||
} break;
|
||||
case ITEM_LOAD_DEFAULT: {
|
||||
ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name()));
|
||||
ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting(setting_name));
|
||||
|
||||
Dictionary d = GLOBAL_GET("importer_defaults/" + params->importer->get_importer_name());
|
||||
List<Variant> v;
|
||||
d.get_key_list(&v);
|
||||
Dictionary import_settings = GLOBAL_GET(setting_name);
|
||||
List<Variant> keys;
|
||||
import_settings.get_key_list(&keys);
|
||||
|
||||
if (params->checking) {
|
||||
params->checked.clear();
|
||||
}
|
||||
for (const Variant &E : v) {
|
||||
params->values[E] = d[E];
|
||||
for (const Variant &E : keys) {
|
||||
params->values[E] = import_settings[E];
|
||||
if (params->checking) {
|
||||
params->checked.insert(E);
|
||||
}
|
||||
|
@ -463,7 +471,7 @@ void ImportDock::_preset_selected(int p_idx) {
|
|||
params->update();
|
||||
} break;
|
||||
case ITEM_CLEAR_DEFAULT: {
|
||||
ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), Variant());
|
||||
ProjectSettings::get_singleton()->set(setting_name, Variant());
|
||||
ProjectSettings::get_singleton()->save();
|
||||
_update_preset_menu();
|
||||
} break;
|
||||
|
|
|
@ -126,10 +126,9 @@ Node *EditorSceneFormatImporterFBX2GLTF::import_scene(const String &p_path, uint
|
|||
|
||||
Variant EditorSceneFormatImporterFBX2GLTF::get_option_visibility(const String &p_path, bool p_for_animation,
|
||||
const String &p_option, const HashMap<StringName, Variant> &p_options) {
|
||||
if (p_option == "fbx/embedded_image_handling") {
|
||||
return false;
|
||||
}
|
||||
if (p_options.has("fbx/importer") && int(p_options["fbx/importer"]) == EditorSceneFormatImporterUFBX::FBX_IMPORTER_FBX2GLTF && p_option == "fbx/embedded_image_handling") {
|
||||
// Remove all the FBX options except for 'fbx/importer' if the importer is fbx2gltf.
|
||||
// These options are available only for ufbx.
|
||||
if (p_option.begins_with("fbx/") && p_option != "fbx/importer" && p_options.has("fbx/importer") && int(p_options["fbx/importer"]) == EditorSceneFormatImporterUFBX::FBX_IMPORTER_FBX2GLTF) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -76,9 +76,6 @@ Node *EditorSceneFormatImporterUFBX::import_scene(const String &p_path, uint32_t
|
|||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
p_flags |= EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
|
||||
state->set_bake_fps(p_options["animation/fps"]);
|
||||
Error err = fbx->append_from_file(path, state, p_flags, p_path.get_base_dir());
|
||||
|
@ -93,21 +90,17 @@ Node *EditorSceneFormatImporterUFBX::import_scene(const String &p_path, uint32_t
|
|||
|
||||
Variant EditorSceneFormatImporterUFBX::get_option_visibility(const String &p_path, bool p_for_animation,
|
||||
const String &p_option, const HashMap<StringName, Variant> &p_options) {
|
||||
String file_extension = p_path.get_extension().to_lower();
|
||||
if (file_extension != "fbx" && p_option.begins_with("fbx/")) {
|
||||
return false;
|
||||
}
|
||||
if ((file_extension != "gltf" && file_extension != "glb") && p_option.begins_with("gltf/")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditorSceneFormatImporterUFBX::get_import_options(const String &p_path,
|
||||
List<ResourceImporter::ImportOption> *r_options) {
|
||||
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));
|
||||
// Returns all the options when path is empty because that means it's for the Project Settings.
|
||||
if (p_path.is_empty() || p_path.get_extension().to_lower() == "fbx") {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
void EditorSceneFormatImporterUFBX::handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const {
|
||||
|
|
|
@ -332,7 +332,8 @@ Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_pa
|
|||
}
|
||||
|
||||
void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options) {
|
||||
if (p_path.get_extension().to_lower() != "blend") {
|
||||
// Returns all the options when path is empty because that means it's for the Project Settings.
|
||||
if (!p_path.is_empty() && p_path.get_extension().to_lower() != "blend") {
|
||||
return;
|
||||
}
|
||||
#define ADD_OPTION_BOOL(PATH, VALUE) \
|
||||
|
|
|
@ -84,8 +84,12 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
|
|||
|
||||
void EditorSceneFormatImporterGLTF::get_import_options(const String &p_path,
|
||||
List<ResourceImporter::ImportOption> *r_options) {
|
||||
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "gltf/naming_version", PROPERTY_HINT_ENUM, "Godot 4.1 or 4.0,Godot 4.2 or later"), 1));
|
||||
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "gltf/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), GLTFState::HANDLE_BINARY_EXTRACT_TEXTURES));
|
||||
String file_extension = p_path.get_extension().to_lower();
|
||||
// Returns all the options when path is empty because that means it's for the Project Settings.
|
||||
if (p_path.is_empty() || file_extension == "gltf" || file_extension == "glb") {
|
||||
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "gltf/naming_version", PROPERTY_HINT_ENUM, "Godot 4.1 or 4.0,Godot 4.2 or later"), 1));
|
||||
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "gltf/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), GLTFState::HANDLE_BINARY_EXTRACT_TEXTURES));
|
||||
}
|
||||
}
|
||||
|
||||
void EditorSceneFormatImporterGLTF::handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const {
|
||||
|
@ -98,10 +102,6 @@ void EditorSceneFormatImporterGLTF::handle_compatibility_options(HashMap<StringN
|
|||
|
||||
Variant EditorSceneFormatImporterGLTF::get_option_visibility(const String &p_path, bool p_for_animation,
|
||||
const String &p_option, const HashMap<StringName, Variant> &p_options) {
|
||||
String file_extension = p_path.get_extension().to_lower();
|
||||
if ((file_extension != "gltf" && file_extension != "glb") && p_option.begins_with("gltf/")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue