Merge pull request #87787 from aaronfranke/scene-import-type

ResourceImporterScene: Replace animation bool with an import type string enum
This commit is contained in:
Rémi Verschelde 2024-08-28 00:10:27 +02:00
commit cf2782911f
No known key found for this signature in database
GPG key ID: C3336907360768E1
16 changed files with 84 additions and 63 deletions

View file

@ -6888,10 +6888,10 @@ EditorNode::EditorNode() {
import_shader_file.instantiate(); import_shader_file.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(import_shader_file); ResourceFormatImporter::get_singleton()->add_importer(import_shader_file);
Ref<ResourceImporterScene> import_scene = memnew(ResourceImporterScene(false, true)); Ref<ResourceImporterScene> import_scene = memnew(ResourceImporterScene("PackedScene", true));
ResourceFormatImporter::get_singleton()->add_importer(import_scene); ResourceFormatImporter::get_singleton()->add_importer(import_scene);
Ref<ResourceImporterScene> import_animation = memnew(ResourceImporterScene(true, true)); Ref<ResourceImporterScene> import_animation = memnew(ResourceImporterScene("AnimationLibrary", true));
ResourceFormatImporter::get_singleton()->add_importer(import_animation); ResourceFormatImporter::get_singleton()->add_importer(import_animation);
{ {

View file

@ -1216,7 +1216,7 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
} }
if (is_imported) { if (is_imported) {
SceneImportSettingsDialog::get_singleton()->open_settings(p_path, resource_type == "AnimationLibrary"); SceneImportSettingsDialog::get_singleton()->open_settings(p_path, resource_type);
} else if (resource_type == "PackedScene") { } else if (resource_type == "PackedScene") {
EditorNode::get_singleton()->open_request(fpath); EditorNode::get_singleton()->open_request(fpath);
} else { } else {

View file

@ -54,7 +54,7 @@ void PostImportPluginSkeletonRestFixer::get_internal_import_options(InternalImpo
} }
} }
Variant PostImportPluginSkeletonRestFixer::get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const { Variant PostImportPluginSkeletonRestFixer::get_internal_option_visibility(InternalImportCategory p_category, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (p_category == INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE) { if (p_category == INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE) {
if (p_option.begins_with("retarget/rest_fixer/fix_silhouette/")) { if (p_option.begins_with("retarget/rest_fixer/fix_silhouette/")) {
if (!bool(p_options["retarget/rest_fixer/fix_silhouette/enable"])) { if (!bool(p_options["retarget/rest_fixer/fix_silhouette/enable"])) {

View file

@ -38,7 +38,7 @@ class PostImportPluginSkeletonRestFixer : public EditorScenePostImportPlugin {
public: public:
virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options) override; virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options) override;
virtual Variant get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const override; virtual Variant get_internal_option_visibility(InternalImportCategory p_category, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options) override; virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options) override;
PostImportPluginSkeletonRestFixer(); PostImportPluginSkeletonRestFixer();

View file

@ -96,9 +96,10 @@ void EditorSceneFormatImporter::get_import_options(const String &p_path, List<Re
GDVIRTUAL_CALL(_get_import_options, p_path); GDVIRTUAL_CALL(_get_import_options, p_path);
} }
Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) { Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) {
Variant ret; Variant ret;
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_for_animation, p_option, ret); // For compatibility with the old API, pass the import type as a boolean.
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_scene_import_type == "AnimationLibrary", p_option, ret);
return ret; return ret;
} }
@ -172,13 +173,16 @@ void EditorScenePostImportPlugin::get_internal_import_options(InternalImportCate
GDVIRTUAL_CALL(_get_internal_import_options, p_category); GDVIRTUAL_CALL(_get_internal_import_options, p_category);
current_option_list = nullptr; current_option_list = nullptr;
} }
Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
Variant EditorScenePostImportPlugin::get_internal_option_visibility(InternalImportCategory p_category, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
current_options = &p_options; current_options = &p_options;
Variant ret; Variant ret;
GDVIRTUAL_CALL(_get_internal_option_visibility, p_category, p_for_animation, p_option, ret); // For compatibility with the old API, pass the import type as a boolean.
GDVIRTUAL_CALL(_get_internal_option_visibility, p_category, p_scene_import_type == "AnimationLibrary", p_option, ret);
current_options = nullptr; current_options = nullptr;
return ret; return ret;
} }
Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const { Variant EditorScenePostImportPlugin::get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
current_options = &p_options; current_options = &p_options;
Variant ret; Variant ret;
@ -198,10 +202,10 @@ void EditorScenePostImportPlugin::get_import_options(const String &p_path, List<
GDVIRTUAL_CALL(_get_import_options, p_path); GDVIRTUAL_CALL(_get_import_options, p_path);
current_option_list = nullptr; current_option_list = nullptr;
} }
Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const { Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
current_options = &p_options; current_options = &p_options;
Variant ret; Variant ret;
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_for_animation, p_option, ret); GDVIRTUAL_CALL(_get_option_visibility, p_path, p_scene_import_type == "AnimationLibrary", p_option, ret);
current_options = nullptr; current_options = nullptr;
return ret; return ret;
} }
@ -245,11 +249,22 @@ void EditorScenePostImportPlugin::_bind_methods() {
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
String ResourceImporterScene::get_importer_name() const { String ResourceImporterScene::get_importer_name() const {
return animation_importer ? "animation_library" : "scene"; // For compatibility with 4.2 and earlier we need to keep the "scene" and "animation_library" names.
// However this is arbitrary so for new import types we can use any string.
if (_scene_import_type == "PackedScene") {
return "scene";
} else if (_scene_import_type == "AnimationLibrary") {
return "animation_library";
}
return _scene_import_type;
} }
String ResourceImporterScene::get_visible_name() const { String ResourceImporterScene::get_visible_name() const {
return animation_importer ? "Animation Library" : "Scene"; // This is displayed on the UI. Friendly names here are nice but not vital, so fall back to the type.
if (_scene_import_type == "PackedScene") {
return "Scene";
}
return _scene_import_type.capitalize();
} }
void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const { void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const {
@ -257,11 +272,14 @@ void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions
} }
String ResourceImporterScene::get_save_extension() const { String ResourceImporterScene::get_save_extension() const {
return animation_importer ? "res" : "scn"; if (_scene_import_type == "PackedScene") {
return "scn";
}
return "res";
} }
String ResourceImporterScene::get_resource_type() const { String ResourceImporterScene::get_resource_type() const {
return animation_importer ? "AnimationLibrary" : "PackedScene"; return _scene_import_type;
} }
int ResourceImporterScene::get_format_version() const { int ResourceImporterScene::get_format_version() const {
@ -269,27 +287,28 @@ int ResourceImporterScene::get_format_version() const {
} }
bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
if (animation_importer) { if (_scene_import_type == "PackedScene") {
if (p_option.begins_with("animation/")) {
if (p_option != "animation/import" && !bool(p_options["animation/import"])) {
return false;
}
}
} else if (_scene_import_type == "AnimationLibrary") {
if (p_option == "animation/import") { // Option ignored, animation always imported. if (p_option == "animation/import") { // Option ignored, animation always imported.
return false; return false;
} }
} else if (p_option.begins_with("animation/")) { if (p_option == "nodes/root_type" || p_option == "nodes/root_name" || p_option.begins_with("meshes/") || p_option.begins_with("skins/")) {
if (p_option != "animation/import" && !bool(p_options["animation/import"])) { return false; // Nothing to do here for animations.
return false;
} }
} }
if (animation_importer && (p_option == "nodes/root_type" || p_option == "nodes/root_name" || p_option.begins_with("meshes/") || p_option.begins_with("skins/"))) {
return false; // Nothing to do here for animations.
}
if (p_option == "meshes/lightmap_texel_size" && int(p_options["meshes/light_baking"]) != 2) { if (p_option == "meshes/lightmap_texel_size" && int(p_options["meshes/light_baking"]) != 2) {
// Only display the lightmap texel size import option when using the Static Lightmaps light baking mode. // Only display the lightmap texel size import option when using the Static Lightmaps light baking mode.
return false; return false;
} }
for (int i = 0; i < post_importer_plugins.size(); i++) { 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); Variant ret = post_importer_plugins.write[i]->get_option_visibility(p_path, _scene_import_type, p_option, p_options);
if (ret.get_type() == Variant::BOOL) { if (ret.get_type() == Variant::BOOL) {
if (!ret) { if (!ret) {
return false; return false;
@ -298,7 +317,7 @@ bool ResourceImporterScene::get_option_visibility(const String &p_path, const St
} }
for (Ref<EditorSceneFormatImporter> importer : scene_importers) { for (Ref<EditorSceneFormatImporter> importer : scene_importers) {
Variant ret = importer->get_option_visibility(p_path, animation_importer, p_option, p_options); Variant ret = importer->get_option_visibility(p_path, _scene_import_type, p_option, p_options);
if (ret.get_type() == Variant::BOOL) { if (ret.get_type() == Variant::BOOL) {
if (!ret) { if (!ret) {
return false; return false;
@ -2283,7 +2302,7 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
} }
for (int i = 0; i < post_importer_plugins.size(); i++) { for (int i = 0; i < post_importer_plugins.size(); i++) {
Variant ret = post_importer_plugins.write[i]->get_internal_option_visibility(EditorScenePostImportPlugin::InternalImportCategory(p_category), animation_importer, p_option, p_options); Variant ret = post_importer_plugins.write[i]->get_internal_option_visibility(EditorScenePostImportPlugin::InternalImportCategory(p_category), _scene_import_type, p_option, p_options);
if (ret.get_type() == Variant::BOOL) { if (ret.get_type() == Variant::BOOL) {
return ret; return ret;
} }
@ -2877,13 +2896,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
int import_flags = 0; int import_flags = 0;
if (animation_importer) { if (_scene_import_type == "AnimationLibrary") {
import_flags |= EditorSceneFormatImporter::IMPORT_ANIMATION; import_flags |= EditorSceneFormatImporter::IMPORT_ANIMATION;
import_flags |= EditorSceneFormatImporter::IMPORT_DISCARD_MESHES_AND_MATERIALS; import_flags |= EditorSceneFormatImporter::IMPORT_DISCARD_MESHES_AND_MATERIALS;
} else { } else if (bool(p_options["animation/import"])) {
if (bool(p_options["animation/import"])) { import_flags |= EditorSceneFormatImporter::IMPORT_ANIMATION;
import_flags |= EditorSceneFormatImporter::IMPORT_ANIMATION;
}
} }
if (bool(p_options["skins/use_named_skins"])) { if (bool(p_options["skins/use_named_skins"])) {
@ -3101,7 +3118,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
flags |= ResourceSaver::FLAG_COMPRESS; flags |= ResourceSaver::FLAG_COMPRESS;
} }
if (animation_importer) { if (_scene_import_type == "AnimationLibrary") {
Ref<AnimationLibrary> library; Ref<AnimationLibrary> library;
for (int i = 0; i < scene->get_child_count(); i++) { for (int i = 0; i < scene->get_child_count(); i++) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(scene->get_child(i)); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(scene->get_child(i));
@ -3122,13 +3139,14 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
print_verbose("Saving animation to: " + p_save_path + ".res"); print_verbose("Saving animation to: " + p_save_path + ".res");
err = ResourceSaver::save(library, p_save_path + ".res", flags); //do not take over, let the changed files reload themselves err = ResourceSaver::save(library, p_save_path + ".res", flags); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save animation to file '" + p_save_path + ".res'."); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save animation to file '" + p_save_path + ".res'.");
} else if (_scene_import_type == "PackedScene") {
} else {
Ref<PackedScene> packer = memnew(PackedScene); Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(scene); packer->pack(scene);
print_verbose("Saving scene to: " + p_save_path + ".scn"); print_verbose("Saving scene to: " + p_save_path + ".scn");
err = ResourceSaver::save(packer, p_save_path + ".scn", flags); //do not take over, let the changed files reload themselves err = ResourceSaver::save(packer, p_save_path + ".scn", flags); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + p_save_path + ".scn'."); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + p_save_path + ".scn'.");
} else {
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown scene import type: " + _scene_import_type);
} }
memdelete(scene); memdelete(scene);
@ -3150,20 +3168,20 @@ bool ResourceImporterScene::has_advanced_options() const {
} }
void ResourceImporterScene::show_advanced_options(const String &p_path) { void ResourceImporterScene::show_advanced_options(const String &p_path) {
SceneImportSettingsDialog::get_singleton()->open_settings(p_path, animation_importer); SceneImportSettingsDialog::get_singleton()->open_settings(p_path, _scene_import_type);
} }
ResourceImporterScene::ResourceImporterScene(bool p_animation_import, bool p_singleton) { ResourceImporterScene::ResourceImporterScene(const String &p_scene_import_type, bool p_singleton) {
// This should only be set through the EditorNode. // This should only be set through the EditorNode.
if (p_singleton) { if (p_singleton) {
if (p_animation_import) { if (p_scene_import_type == "AnimationLibrary") {
animation_singleton = this; animation_singleton = this;
} else { } else if (p_scene_import_type == "PackedScene") {
scene_singleton = this; scene_singleton = this;
} }
} }
animation_importer = p_animation_import; _scene_import_type = p_scene_import_type;
} }
ResourceImporterScene::~ResourceImporterScene() { ResourceImporterScene::~ResourceImporterScene() {

View file

@ -44,10 +44,10 @@
#include "scene/resources/animation.h" #include "scene/resources/animation.h"
#include "scene/resources/mesh.h" #include "scene/resources/mesh.h"
class Material;
class AnimationPlayer; class AnimationPlayer;
class ImporterMesh; class ImporterMesh;
class Material;
class EditorSceneFormatImporter : public RefCounted { class EditorSceneFormatImporter : public RefCounted {
GDCLASS(EditorSceneFormatImporter, RefCounted); GDCLASS(EditorSceneFormatImporter, RefCounted);
@ -78,7 +78,7 @@ public:
virtual void get_extensions(List<String> *r_extensions) const; virtual void get_extensions(List<String> *r_extensions) const;
virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr);
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options); virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options); virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options);
virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const {} virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const {}
EditorSceneFormatImporter() {} EditorSceneFormatImporter() {}
@ -140,13 +140,13 @@ public:
void add_import_option_advanced(Variant::Type p_type, const String &p_name, const Variant &p_default_value, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = String(), int p_usage_flags = PROPERTY_USAGE_DEFAULT); void add_import_option_advanced(Variant::Type p_type, const String &p_name, const Variant &p_default_value, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = String(), int p_usage_flags = PROPERTY_USAGE_DEFAULT);
virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options); virtual void get_internal_import_options(InternalImportCategory p_category, List<ResourceImporter::ImportOption> *r_options);
virtual Variant get_internal_option_visibility(InternalImportCategory p_category, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const; virtual Variant get_internal_option_visibility(InternalImportCategory p_category, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const; virtual Variant get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options); virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, Ref<Resource> p_resource, const Dictionary &p_options);
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options); virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options) const; virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option, const HashMap<StringName, Variant> &p_options) const;
virtual void pre_process(Node *p_scene, const HashMap<StringName, Variant> &p_options); virtual void pre_process(Node *p_scene, const HashMap<StringName, Variant> &p_options);
virtual void post_process(Node *p_scene, const HashMap<StringName, Variant> &p_options); virtual void post_process(Node *p_scene, const HashMap<StringName, Variant> &p_options);
@ -237,7 +237,7 @@ class ResourceImporterScene : public ResourceImporter {
void _optimize_track_usage(AnimationPlayer *p_player, AnimationImportTracks *p_track_actions); void _optimize_track_usage(AnimationPlayer *p_player, AnimationImportTracks *p_track_actions);
bool animation_importer = false; String _scene_import_type = "PackedScene";
public: public:
static ResourceImporterScene *get_scene_singleton() { return scene_singleton; } static ResourceImporterScene *get_scene_singleton() { return scene_singleton; }
@ -253,6 +253,9 @@ public:
static void clean_up_importer_plugins(); static void clean_up_importer_plugins();
String get_scene_import_type() const { return _scene_import_type; }
void set_scene_import_type(const String &p_type) { _scene_import_type = p_type; }
virtual String get_importer_name() const override; virtual String get_importer_name() const override;
virtual String get_visible_name() const override; virtual String get_visible_name() const override;
virtual void get_recognized_extensions(List<String> *p_extensions) const override; virtual void get_recognized_extensions(List<String> *p_extensions) const override;
@ -303,7 +306,7 @@ public:
virtual bool can_import_threaded() const override { return false; } virtual bool can_import_threaded() const override { return false; }
ResourceImporterScene(bool p_animation_import = false, bool p_singleton = false); ResourceImporterScene(const String &p_scene_import_type = "PackedScene", bool p_singleton = false);
~ResourceImporterScene(); ~ResourceImporterScene();
template <typename M> template <typename M>

View file

@ -678,26 +678,26 @@ void SceneImportSettingsDialog::update_view() {
update_view_timer->start(); update_view_timer->start();
} }
void SceneImportSettingsDialog::open_settings(const String &p_path, bool p_for_animation) { void SceneImportSettingsDialog::open_settings(const String &p_path, const String &p_scene_import_type) {
if (scene) { if (scene) {
_cleanup(); _cleanup();
memdelete(scene); memdelete(scene);
scene = nullptr; scene = nullptr;
} }
editing_animation = p_for_animation; editing_animation = p_scene_import_type == "AnimationLibrary";
scene_import_settings_data->settings = nullptr; scene_import_settings_data->settings = nullptr;
scene_import_settings_data->path = p_path; scene_import_settings_data->path = p_path;
// Visibility. // Visibility.
data_mode->set_tab_hidden(1, p_for_animation); data_mode->set_tab_hidden(1, editing_animation);
data_mode->set_tab_hidden(2, p_for_animation); data_mode->set_tab_hidden(2, editing_animation);
if (p_for_animation) { if (editing_animation) {
data_mode->set_current_tab(0); data_mode->set_current_tab(0);
} }
action_menu->get_popup()->set_item_disabled(action_menu->get_popup()->get_item_id(ACTION_EXTRACT_MATERIALS), p_for_animation); action_menu->get_popup()->set_item_disabled(action_menu->get_popup()->get_item_id(ACTION_EXTRACT_MATERIALS), editing_animation);
action_menu->get_popup()->set_item_disabled(action_menu->get_popup()->get_item_id(ACTION_CHOOSE_MESH_SAVE_PATHS), p_for_animation); action_menu->get_popup()->set_item_disabled(action_menu->get_popup()->get_item_id(ACTION_CHOOSE_MESH_SAVE_PATHS), editing_animation);
base_path = p_path; base_path = p_path;
@ -771,7 +771,7 @@ void SceneImportSettingsDialog::open_settings(const String &p_path, bool p_for_a
// Start with the root item (Scene) selected. // Start with the root item (Scene) selected.
scene_tree->get_root()->select(0); scene_tree->get_root()->select(0);
if (p_for_animation) { if (editing_animation) {
set_title(vformat(TTR("Advanced Import Settings for AnimationLibrary '%s'"), base_path.get_file())); set_title(vformat(TTR("Advanced Import Settings for AnimationLibrary '%s'"), base_path.get_file()));
} else { } else {
set_title(vformat(TTR("Advanced Import Settings for Scene '%s'"), base_path.get_file())); set_title(vformat(TTR("Advanced Import Settings for Scene '%s'"), base_path.get_file()));

View file

@ -243,7 +243,7 @@ public:
bool is_editing_animation() const { return editing_animation; } bool is_editing_animation() const { return editing_animation; }
void request_generate_collider(); void request_generate_collider();
void update_view(); void update_view();
void open_settings(const String &p_path, bool p_for_animation = false); void open_settings(const String &p_path, const String &p_scene_import_type = "PackedScene");
static SceneImportSettingsDialog *get_singleton(); static SceneImportSettingsDialog *get_singleton();
Node *get_selected_node(); Node *get_selected_node();
SceneImportSettingsDialog(); SceneImportSettingsDialog();

View file

@ -124,7 +124,7 @@ Node *EditorSceneFormatImporterFBX2GLTF::import_scene(const String &p_path, uint
#endif #endif
} }
Variant EditorSceneFormatImporterFBX2GLTF::get_option_visibility(const String &p_path, bool p_for_animation, Variant EditorSceneFormatImporterFBX2GLTF::get_option_visibility(const String &p_path, const String &p_scene_import_type,
const String &p_option, const HashMap<StringName, Variant> &p_options) { const String &p_option, const HashMap<StringName, Variant> &p_options) {
// Remove all the FBX options except for 'fbx/importer' if the importer is fbx2gltf. // Remove all the FBX options except for 'fbx/importer' if the importer is fbx2gltf.
// These options are available only for ufbx. // These options are available only for ufbx.

View file

@ -49,7 +49,7 @@ public:
List<String> *r_missing_deps, Error *r_err = nullptr) override; List<String> *r_missing_deps, Error *r_err = nullptr) override;
virtual void get_import_options(const String &p_path, virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override; List<ResourceImporter::ImportOption> *r_options) override;
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option,
const HashMap<StringName, Variant> &p_options) override; const HashMap<StringName, Variant> &p_options) override;
virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override; virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override;
}; };

View file

@ -88,7 +88,7 @@ Node *EditorSceneFormatImporterUFBX::import_scene(const String &p_path, uint32_t
return fbx->generate_scene(state, state->get_bake_fps(), (bool)p_options["animation/trimming"], false); return fbx->generate_scene(state, state->get_bake_fps(), (bool)p_options["animation/trimming"], false);
} }
Variant EditorSceneFormatImporterUFBX::get_option_visibility(const String &p_path, bool p_for_animation, Variant EditorSceneFormatImporterUFBX::get_option_visibility(const String &p_path, const String &p_scene_import_type,
const String &p_option, const HashMap<StringName, Variant> &p_options) { const String &p_option, const HashMap<StringName, Variant> &p_options) {
return true; return true;
} }

View file

@ -53,7 +53,7 @@ public:
List<String> *r_missing_deps, Error *r_err = nullptr) override; List<String> *r_missing_deps, Error *r_err = nullptr) override;
virtual void get_import_options(const String &p_path, virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override; List<ResourceImporter::ImportOption> *r_options) override;
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option,
const HashMap<StringName, Variant> &p_options) override; const HashMap<StringName, Variant> &p_options) override;
virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override; virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override;
}; };

View file

@ -336,7 +336,7 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
#endif #endif
} }
Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option,
const HashMap<StringName, Variant> &p_options) { const HashMap<StringName, Variant> &p_options) {
if (p_path.get_extension().to_lower() != "blend") { if (p_path.get_extension().to_lower() != "blend") {
return true; return true;

View file

@ -74,7 +74,7 @@ public:
List<String> *r_missing_deps, Error *r_err = nullptr) override; List<String> *r_missing_deps, Error *r_err = nullptr) override;
virtual void get_import_options(const String &p_path, virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override; List<ResourceImporter::ImportOption> *r_options) override;
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option,
const HashMap<StringName, Variant> &p_options) override; const HashMap<StringName, Variant> &p_options) override;
}; };

View file

@ -100,7 +100,7 @@ void EditorSceneFormatImporterGLTF::handle_compatibility_options(HashMap<StringN
} }
} }
Variant EditorSceneFormatImporterGLTF::get_option_visibility(const String &p_path, bool p_for_animation, Variant EditorSceneFormatImporterGLTF::get_option_visibility(const String &p_path, const String &p_scene_import_type,
const String &p_option, const HashMap<StringName, Variant> &p_options) { const String &p_option, const HashMap<StringName, Variant> &p_options) {
return true; return true;
} }

View file

@ -50,7 +50,7 @@ public:
virtual void get_import_options(const String &p_path, virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override; List<ResourceImporter::ImportOption> *r_options) override;
virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override; virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override;
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type,
const String &p_option, const HashMap<StringName, Variant> &p_options) override; const String &p_option, const HashMap<StringName, Variant> &p_options) override;
}; };