summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRindbee <idleman@yeah.net>2022-07-01 20:03:40 +0800
committerRindbee <idleman@yeah.net>2022-07-02 13:10:29 +0800
commitd9709e151bfc3e0a41e8535307d80e0c8a3fbc62 (patch)
tree40fef6d414acc7c7381108739c3ac9feb44ede2c
parenta2459c7d35eeaeea8b1d4fa9ce6c9cbe74f11643 (diff)
Make import preview of blend files visible
Unlike other scene imports, the import of blend files requires options. Otherwise, the preview may not be visible.
-rw-r--r--editor/import/resource_importer_scene.cpp9
-rw-r--r--editor/import/resource_importer_scene.h2
-rw-r--r--editor/import/scene_import_settings.cpp12
3 files changed, 14 insertions, 9 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index a9c43e573f..8f6db09c63 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1972,7 +1972,7 @@ void ResourceImporterScene::_optimize_track_usage(AnimationPlayer *p_player, Ani
}
}
-Node *ResourceImporterScene::pre_import(const String &p_source_file) {
+Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashMap<StringName, Variant> &p_options) {
Ref<EditorSceneFormatImporter> importer;
String ext = p_source_file.get_extension().to_lower();
@@ -1997,8 +1997,13 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) {
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
+ int bake_fps = 30;
+ if (p_options.has(SNAME("animation/fps"))) {
+ bake_fps = p_options[SNAME("animation/fps")];
+ }
+
Error err = OK;
- Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, HashMap<StringName, Variant>(), 15, nullptr, &err);
+ Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_options, bake_fps, nullptr, &err);
if (!scene || err != OK) {
return nullptr;
}
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index c143e86bd4..b77c1dccb4 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -281,7 +281,7 @@ public:
void _optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle);
void _compress_animations(AnimationPlayer *anim, int p_page_size_kb);
- Node *pre_import(const String &p_source_file);
+ Node *pre_import(const String &p_source_file, const HashMap<StringName, Variant> &p_options);
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
virtual bool has_advanced_options() const override;
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index af145c22b4..8f6463140b 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -538,12 +538,6 @@ void SceneImportSettings::open_settings(const String &p_path, bool p_for_animati
scene_import_settings_data->settings = nullptr;
scene_import_settings_data->path = p_path;
- scene = ResourceImporterScene::get_scene_singleton()->pre_import(p_path); // Use the scene singleton here because we want to see the full thing.
- if (scene == nullptr) {
- EditorNode::get_singleton()->show_warning(TTR("Error opening scene"));
- return;
- }
-
// Visibility
data_mode->set_tab_hidden(1, p_for_animation);
data_mode->set_tab_hidden(2, p_for_animation);
@@ -589,6 +583,12 @@ void SceneImportSettings::open_settings(const String &p_path, bool p_for_animati
}
}
+ scene = ResourceImporterScene::get_scene_singleton()->pre_import(p_path, defaults); // Use the scene singleton here because we want to see the full thing.
+ if (scene == nullptr) {
+ EditorNode::get_singleton()->show_warning(TTR("Error opening scene"));
+ return;
+ }
+
first_aabb = true;
_update_scene();