diff options
author | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2020-01-10 08:02:16 -0800 |
---|---|---|
committer | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2020-01-10 08:02:16 -0800 |
commit | 0172a7f932084839473a6961a8c40409ae067420 (patch) | |
tree | e3cf7c976d7eff3d4b59743263d40e1133422725 /editor/import | |
parent | 140a31728f7e90c9bd1769fe9b35e14bcad6b4d3 (diff) |
Use cycle and loop hint flags in glTF2.
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 10 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index f5128103f3..7de6db7add 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2329,7 +2329,11 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { Array samplers = d["samplers"]; if (d.has("name")) { - animation.name = _sanitize_scene_name(d["name"]); + String name = d["name"]; + if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) { + animation.loop = true; + } + animation.name = _sanitize_scene_name(name); } for (int j = 0; j < channels.size(); j++) { @@ -2735,6 +2739,10 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye animation.instance(); animation->set_name(name); + if (anim.loop) { + animation->set_loop(true); + } + float length = 0; for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) { diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 4a91b99aa7..78d7106b0d 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -262,6 +262,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFAnimation { + bool loop = false; enum Interpolation { INTERP_LINEAR, |