aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro J. Estébanez2018-03-19 00:24:00 +0100
committerHein-Pieter van Braam2018-03-29 00:04:15 +0200
commit2e9c9f7d74aedd01561045af0dd50ef5ae1920ff (patch)
treeff0600defd6e2ec3ba2862dc783b4d1b77d69bdc
parent6063e74e068ec10c93a1f39bb18683e4556fb4ee (diff)
downloadgodot-2e9c9f7d74aedd01561045af0dd50ef5ae1920ff.tar.gz
godot-2e9c9f7d74aedd01561045af0dd50ef5ae1920ff.tar.zst
godot-2e9c9f7d74aedd01561045af0dd50ef5ae1920ff.zip
Fix animation length from glTF not correctly set
(cherry picked from commit 1f26da0ad11e3b68f4ceecb2e39dc6b3302082ee)
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 9db1032e3..321d29f2f 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1883,6 +1883,8 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
animation.instance();
animation->set_name(name);
+ float length = 0;
+
for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) {
const GLTFAnimation::Track &track = E->get();
@@ -1901,8 +1903,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
node_path = ap->get_parent()->get_path_to(node->godot_nodes[i]);
}
- float length = 0;
-
for (int i = 0; i < track.rotation_track.times.size(); i++) {
length = MAX(length, track.rotation_track.times[i]);
}
@@ -1919,8 +1919,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
}
}
- animation->set_length(length);
-
if (track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) {
//make transform track
int track_idx = animation->get_track_count();
@@ -2038,6 +2036,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
}
}
}
+ animation->set_length(length);
ap->add_animation(name, animation);
}