diff options
author | reduz <reduzio@gmail.com> | 2022-04-12 16:07:09 +0200 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-04-13 15:06:56 +0200 |
commit | 66009318e0827f01a584aca14c6e9ec0079354d3 (patch) | |
tree | 181c70173bdbf55dac3d7eeb38fb6423bcf3a436 /modules | |
parent | 43f94c95aa88d5fc0180bb4ee5c8ce44d27dbc0f (diff) |
Import scenes as AnimationLibrary
Added the ability to import scenes as AnimationLibrary
* Completes implementation of https://github.com/godotengine/godot-proposals/issues/4296
* Helps if you want to export animations to a separate file (say a GLTF) to avoid re-importing/exporting them every time the model changes.
* Helps if you simply want to have animations using a dummy model, which can be shared across multiple models.
Creates a secondary scene importer used only for animations.
**NOTE**: A new flag for scene importer: EditorSceneFormatImporter.IMPORT_DISCARD_MESHES_AND_MATERIALS has been added, to hint importers that they should skip meshes and animations (and hence make importing faster). It is not implemented in any importer yet, this should be done in a separate PR.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_blend.cpp | 14 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_blend.h | 4 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_fbx.cpp | 7 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_fbx.h | 4 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_gltf.cpp | 5 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_gltf.h | 2 | ||||
-rw-r--r-- | modules/gltf/register_types.cpp | 6 |
7 files changed, 14 insertions, 28 deletions
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index ae05c1b68d..173d5131cf 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -238,13 +238,12 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ return gltf->generate_scene(state, p_bake_fps); } -Ref<Animation> EditorSceneFormatImporterBlend::import_animation(const String &p_path, uint32_t p_flags, - const Map<StringName, Variant> &p_options, int p_bake_fps) { - return Ref<Animation>(); -} - -Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, const String &p_option, +Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) { + if (p_path.get_extension().to_lower() != "blend") { + return true; + } + if (p_option.begins_with("animation/")) { if (p_option != "animation/import" && !bool(p_options["animation/import"])) { return false; @@ -254,6 +253,9 @@ 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") { + return; + } #define ADD_OPTION_BOOL(PATH, VALUE) \ r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, SNAME(PATH)), VALUE)); #define ADD_OPTION_ENUM(PATH, ENUM_HINT, VALUE) \ diff --git a/modules/gltf/editor/editor_scene_importer_blend.h b/modules/gltf/editor/editor_scene_importer_blend.h index 9a1b5f5803..0925333a28 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.h +++ b/modules/gltf/editor/editor_scene_importer_blend.h @@ -68,11 +68,9 @@ public: virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, - const Map<StringName, Variant> &p_options, int p_bake_fps) override; virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options) override; - virtual Variant get_option_visibility(const String &p_path, const String &p_option, + virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) override; }; diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp index 24564f55be..893d2efcec 100644 --- a/modules/gltf/editor/editor_scene_importer_fbx.cpp +++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp @@ -105,12 +105,7 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t return gltf->generate_scene(state, p_bake_fps); } -Ref<Animation> EditorSceneFormatImporterFBX::import_animation(const String &p_path, - uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) { - return Ref<Animation>(); -} - -Variant EditorSceneFormatImporterFBX::get_option_visibility(const String &p_path, +Variant EditorSceneFormatImporterFBX::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) { return true; } diff --git a/modules/gltf/editor/editor_scene_importer_fbx.h b/modules/gltf/editor/editor_scene_importer_fbx.h index bb69cfaa30..84de7fd1cc 100644 --- a/modules/gltf/editor/editor_scene_importer_fbx.h +++ b/modules/gltf/editor/editor_scene_importer_fbx.h @@ -47,11 +47,9 @@ public: virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, - const Map<StringName, Variant> &p_options, int p_bake_fps) override; virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options) override; - virtual Variant get_option_visibility(const String &p_path, const String &p_option, + virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const Map<StringName, Variant> &p_options) override; }; diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp index 1d6a82e58a..5e7811ad2b 100644 --- a/modules/gltf/editor/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp @@ -64,9 +64,4 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t return doc->generate_scene(state, p_bake_fps); } -Ref<Animation> EditorSceneFormatImporterGLTF::import_animation(const String &p_path, - uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) { - return Ref<Animation>(); -} - #endif // TOOLS_ENABLED diff --git a/modules/gltf/editor/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h index 1f62ca9537..b714ada124 100644 --- a/modules/gltf/editor/editor_scene_importer_gltf.h +++ b/modules/gltf/editor/editor_scene_importer_gltf.h @@ -47,8 +47,6 @@ public: virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, - const Map<StringName, Variant> &p_options, int p_bake_fps) override; }; #endif // TOOLS_ENABLED diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index e09c76f052..b656788a10 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -60,7 +60,7 @@ static void _editor_init() { Ref<EditorSceneFormatImporterGLTF> import_gltf; import_gltf.instantiate(); - ResourceImporterScene::get_singleton()->add_importer(import_gltf); + ResourceImporterScene::add_importer(import_gltf); // Blend to glTF importer. @@ -72,7 +72,7 @@ static void _editor_init() { if (blend_enabled) { Ref<EditorSceneFormatImporterBlend> importer; importer.instantiate(); - ResourceImporterScene::get_singleton()->add_importer(importer); + ResourceImporterScene::add_importer(importer); Ref<EditorFileSystemImportFormatSupportQueryBlend> blend_import_query; blend_import_query.instantiate(); @@ -95,7 +95,7 @@ static void _editor_init() { } else { Ref<EditorSceneFormatImporterFBX> importer; importer.instantiate(); - ResourceImporterScene::get_singleton()->add_importer(importer); + ResourceImporterScene::add_importer(importer); } } } |