diff options
| author | Tokage <tokage.it.lab@gmail.com> | 2021-04-25 05:47:03 +0900 |
|---|---|---|
| committer | Silc 'Tokage' Renew <tokage.it.lab@gmail.com> | 2021-10-09 18:08:43 +0900 |
| commit | 372ba7666304805abe8641487c97899f9bdd97af (patch) | |
| tree | 3a5d56b1fd80db923c08fa25c7c3d407b992c496 /editor/plugins/animation_player_editor_plugin.cpp | |
| parent | e8c89b2b9158ce011ed5c1a913f55d38226c4a55 (diff) | |
| download | redot-engine-372ba7666304805abe8641487c97899f9bdd97af.tar.gz | |
implement ping-pong loop in animation
Co-authored-by: Chaosus <chaosus89@gmail.com>
Diffstat (limited to 'editor/plugins/animation_player_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/animation_player_editor_plugin.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index ea025dad3e..65238446f9 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -41,6 +41,7 @@ #include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning. #include "editor/plugins/node_3d_editor_plugin.h" // For onion skinning. #include "scene/main/window.h" +#include "scene/resources/animation.h" #include "servers/rendering_server.h" void AnimationPlayerEditor::_node_removed(Node *p_node) { @@ -72,7 +73,7 @@ void AnimationPlayerEditor::_notification(int p_what) { if (player->has_animation(animname)) { Ref<Animation> anim = player->get_animation(animname); if (!anim.is_null()) { - frame->set_max(anim->get_length()); + frame->set_max((double)anim->get_length()); } } } @@ -289,7 +290,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { track_editor->set_root(root); } } - frame->set_max(anim->get_length()); + frame->set_max((double)anim->get_length()); } else { track_editor->set_animation(Ref<Animation>()); @@ -1014,7 +1015,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool Ref<Animation> anim; anim = player->get_animation(current); - float pos = CLAMP(anim->get_length() * (p_value / frame->get_max()), 0, anim->get_length()); + float pos = CLAMP((double)anim->get_length() * (p_value / frame->get_max()), 0, (double)anim->get_length()); if (track_editor->is_snap_enabled()) { pos = Math::snapped(pos, _get_editor_step()); } @@ -1424,7 +1425,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { float pos = cpos + step_off * anim->get_step(); - bool valid = anim->has_loop() || (pos >= 0 && pos <= anim->get_length()); + bool valid = anim->get_loop_mode() != Animation::LoopMode::LOOP_NONE || (pos >= 0 && pos <= anim->get_length()); onion.captures_valid.write[cidx] = valid; if (valid) { player->seek(pos, true); |
