summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorImpishOaths <Sophia@impishoaths.dev>2024-07-07 23:40:34 -0700
committerImpishOaths <Sophia@impishoaths.dev>2024-07-08 09:05:07 -0700
commit0f7c4d8375e5066500ad9a44402adbb197d1c1a2 (patch)
treeb5b192de1e04af2c0d0e51e4225bb67717cf36a7
parentb97110cd307e4d78e20bfafe5de6c082194b2cd6 (diff)
downloadredot-engine-0f7c4d8375e5066500ad9a44402adbb197d1c1a2.tar.gz
Don't lose in/out handles when bezier keyframe inserted on top of existing keyframe
Apply suggestions from code review Co-authored-by: Silc Lizard (Tokage) Renew <tokage.it.lab@gmail.com>
-rw-r--r--editor/animation_track_editor.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 6810b802a1..e84ef53f2b 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -4464,7 +4464,14 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
} break;
case Animation::TYPE_BEZIER: {
- value = animation->make_default_bezier_key(p_id.value);
+ int existing = animation->track_find_key(p_id.track_idx, time, Animation::FIND_MODE_APPROX);
+ if (existing != -1) {
+ Array arr = animation->track_get_key_value(p_id.track_idx, existing);
+ arr[0] = p_id.value;
+ value = arr;
+ } else {
+ value = animation->make_default_bezier_key(p_id.value);
+ }
bezier_edit_icon->set_disabled(false);
} break;
default: {