summaryrefslogtreecommitdiff
path: root/modules/gltf
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-15 09:53:22 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-15 09:53:22 +0100
commit1f6a5426e2a473e978ab24e6fdd38b84b82f2018 (patch)
treecaa706afd61d5b5d0dc0d3f5229a13ade9574f29 /modules/gltf
parent47a8ee8814fedaa89816612137f4469fb2318d93 (diff)
parent4970c27ff5fa7e4b8ab4e51bdcd53f6a63bc76df (diff)
Merge pull request #73345 from TokageItLab/gltfimport
Fix gltf import generate_scene() option
Diffstat (limited to 'modules/gltf')
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.cpp7
-rw-r--r--modules/gltf/editor/editor_scene_importer_fbx.cpp7
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp24
3 files changed, 21 insertions, 17 deletions
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp
index 520f33261a..7dcdc8e7cf 100644
--- a/modules/gltf/editor/editor_scene_importer_blend.cpp
+++ b/modules/gltf/editor/editor_scene_importer_blend.cpp
@@ -214,7 +214,14 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
}
return nullptr;
}
+
+#ifndef DISABLE_DEPRECATED
+ bool trimming = p_options.has("animation/trimming") ? (bool)p_options["animation/trimming"] : false;
+ bool remove_immutable = p_options.has("animation/remove_immutable_tracks") ? (bool)p_options["animation/remove_immutable_tracks"] : true;
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], trimming, remove_immutable);
+#else
return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
+#endif
}
Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option,
diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp
index d829630032..f8f458fcc7 100644
--- a/modules/gltf/editor/editor_scene_importer_fbx.cpp
+++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp
@@ -100,7 +100,14 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t
}
return nullptr;
}
+
+#ifndef DISABLE_DEPRECATED
+ bool trimming = p_options.has("animation/trimming") ? (bool)p_options["animation/trimming"] : false;
+ bool remove_immutable = p_options.has("animation/remove_immutable_tracks") ? (bool)p_options["animation/remove_immutable_tracks"] : true;
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], trimming, remove_immutable);
+#else
return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
+#endif
}
Variant EditorSceneFormatImporterFBX::get_option_visibility(const String &p_path, bool p_for_animation,
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index 012a144d52..5339275439 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -47,15 +47,15 @@ void EditorSceneFormatImporterGLTF::get_extensions(List<String> *r_extensions) c
Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t p_flags,
const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err) {
- Ref<GLTFDocument> doc;
- doc.instantiate();
+ Ref<GLTFDocument> gltf;
+ gltf.instantiate();
Ref<GLTFState> state;
state.instantiate();
if (p_options.has("gltf/embedded_image_handling")) {
int32_t enum_option = p_options["gltf/embedded_image_handling"];
state->set_handle_binary_image(enum_option);
}
- Error err = doc->append_from_file(p_path, state, p_flags);
+ Error err = gltf->append_from_file(p_path, state, p_flags);
if (err != OK) {
if (r_err) {
*r_err = err;
@@ -67,21 +67,11 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
}
#ifndef DISABLE_DEPRECATED
- if (p_options.has("animation/trimming")) {
- if (p_options.has("animation/remove_immutable_tracks")) {
- return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
- } else {
- return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], true);
- }
- } else {
- if (p_options.has("animation/remove_immutable_tracks")) {
- return doc->generate_scene(state, (float)p_options["animation/fps"], false, (bool)p_options["animation/remove_immutable_tracks"]);
- } else {
- return doc->generate_scene(state, (float)p_options["animation/fps"], false, true);
- }
- }
+ bool trimming = p_options.has("animation/trimming") ? (bool)p_options["animation/trimming"] : false;
+ bool remove_immutable = p_options.has("animation/remove_immutable_tracks") ? (bool)p_options["animation/remove_immutable_tracks"] : true;
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], trimming, remove_immutable);
#else
- return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
#endif
}