1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Merge pull request #73345 from TokageItLab/gltfimport

Fix gltf import generate_scene() option
This commit is contained in:
Rémi Verschelde
2023-02-15 09:53:22 +01:00
3 changed files with 21 additions and 17 deletions

View File

@@ -214,7 +214,14 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
} }
return nullptr; 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"]); 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, Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option,

View File

@@ -100,7 +100,14 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t
} }
return nullptr; 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"]); 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, Variant EditorSceneFormatImporterFBX::get_option_visibility(const String &p_path, bool p_for_animation,

View File

@@ -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, Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t p_flags,
const HashMap<StringName, Variant> &p_options, const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err) { List<String> *r_missing_deps, Error *r_err) {
Ref<GLTFDocument> doc; Ref<GLTFDocument> gltf;
doc.instantiate(); gltf.instantiate();
Ref<GLTFState> state; Ref<GLTFState> state;
state.instantiate(); state.instantiate();
if (p_options.has("gltf/embedded_image_handling")) { if (p_options.has("gltf/embedded_image_handling")) {
int32_t enum_option = p_options["gltf/embedded_image_handling"]; int32_t enum_option = p_options["gltf/embedded_image_handling"];
state->set_handle_binary_image(enum_option); 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 (err != OK) {
if (r_err) { if (r_err) {
*r_err = err; *r_err = err;
@@ -67,21 +67,11 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
} }
#ifndef DISABLE_DEPRECATED #ifndef DISABLE_DEPRECATED
if (p_options.has("animation/trimming")) { bool trimming = p_options.has("animation/trimming") ? (bool)p_options["animation/trimming"] : false;
if (p_options.has("animation/remove_immutable_tracks")) { bool remove_immutable = p_options.has("animation/remove_immutable_tracks") ? (bool)p_options["animation/remove_immutable_tracks"] : true;
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"], trimming, remove_immutable);
} 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);
}
}
#else #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 #endif
} }