Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AnimationPlayer in real-time when keyframe properties change #91599

Conversation

dnllowe
Copy link
Contributor

@dnllowe dnllowe commented May 5, 2024

Implementation for proposal: godotengine/godot-proposals#9686

  • Reflect changes to keyframed properties in AnimationPlayer in realtime
  • Move AnimationPlayer position to key frame when key frame is selected

Bugsquad edit:

@Calinou
Copy link
Member

Calinou commented May 6, 2024

Move AnimationPlayer position to key frame when key frame is selected

Won't this cause issues when selecting multiple keyframes, particularly across different tracks?

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it mostly works as expected.

Testing project: test_pr_91599.zip

I noticed 2 issues though:

  • Changing a key's easing in the inspector does not update what you see in the editor in real-time. It only updates when you scrub the timeline again:
simplescreenrecorder-2024-05-06_22.15.57.mp4
  • Using undo after modifying a key's value in the inspector does not reflect in real-time until you scrub the timeline:
simplescreenrecorder-2024-05-06_22.16.43.mp4

@dnllowe
Copy link
Contributor Author

dnllowe commented May 6, 2024

Tested locally, it mostly works as expected.

I noticed 2 issues though:

  • Changing a key's easing in the inspector does not update what you see in the editor in real-time. It only updates when you scrub the timeline again:

  • Using undo after modifying a key's value in the inspector does not reflect in real-time until you scrub the timeline:

Thanks for your review -- I'll iron these issues out

Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a code standpoint, it looks that the specified arguments of the AnimationPlayer methods are fine. I will wait for the fixes to some of the behaviors pointed out above.

@dnllowe
Copy link
Contributor Author

dnllowe commented May 7, 2024

Good suggestions / catches. Both issues should be resolved now:

Changing easing, then performing undo/redo a couple of times

undo-redo-and-easing.mp4

editor/animation_track_editor.cpp Outdated Show resolved Hide resolved
Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing out two things from the test:

fb.mp4
  • Selecting a keyframe causes a seek due to the KeyEdit updating on the inspector, which does not exist previously and probably was not the intended change and needs to be fixed
  • Inconsistencies occur when key times are moved by the inspector

@dnllowe
Copy link
Contributor Author

dnllowe commented May 11, 2024

I fixed it so that changing time will update the animation.

The issue in the video where editing the easing is the expected behavior, as the last frame's easing is being edited, which won't have an effect on the animation. The first keyframe would need to be selected and its easing changed for a change to occur.

I'm unsure what this really refers to:

Selecting a keyframe causes a seek due to the KeyEdit updating on the inspector, which does not exist previously and probably was not the intended change and needs to be fixed

I do intend to update the behavior so that selecting a keyframe seeks to it and updates the animation, but I'm not sure if that's the issue you're referring to.

@patwork
Copy link
Contributor

patwork commented May 28, 2024

Hello, does this fix also take into account the need to refresh the scene when moving a keyframe in the timeline?

Animation

@TokageItLab
Copy link
Member

TokageItLab commented May 29, 2024

I do intend to update the behavior so that selecting a keyframe seeks to it and updates the animation, but I'm not sure if that's the issue you're referring to.

The problem is that the "current time" in the editor is changed by selecting the key.

That behavior does not exist in other animation software, such as AfterEffects, Blender or etc., and is wrong as an affordance so must be reverted. The user just wants to edit the value of the key, not intend to seek the animation, so the current time must be retained.

In summary, it is good to change the preview when the ease is changed, but it is not acceptable to just click on a key and the current time will be moved to that key.

@dnllowe
Copy link
Contributor Author

dnllowe commented Jun 4, 2024

I do intend to update the behavior so that selecting a keyframe seeks to it and updates the animation, but I'm not sure if that's the issue you're referring to.

The problem is that the "current time" in the editor is changed by selecting the key.

That behavior does not exist in other animation software, such as AfterEffects, Blender or etc., and is wrong as an affordance so must be reverted. The user just wants to edit the value of the key, not intend to seek the animation, so the current time must be retained.

In summary, it is good to change the preview when the ease is changed, but it is not acceptable to just click on a key and the current time will be moved to that key.

Alright, I can revert this. For reference, Unreal's animation timeline does update the position when selecting keyframes. But I double checked with Unity and my own video editor of choice (Da Vinci Resolve) and neither of them update the timeline position when selecting keyframes. Having immediate feedback makes more sense to me, but I'm not really an animator by trade, so perhaps I'm an edge case.

@dnllowe
Copy link
Contributor Author

dnllowe commented Jun 4, 2024

Hello, does this fix also take into account the need to refresh the scene when moving a keyframe in the timeline?

Good suggestion / find. I'm updating the branch to reflect updating the animation after changing the keyframe position

@dnllowe
Copy link
Contributor Author

dnllowe commented Jun 4, 2024

Here's what the latest behavior looks like. Update the animation when...

  • Keyframe properties change
  • Easing is changed
  • Keyframe position is changed
  • Undo / Redo will update the animation accordingly
  • (Edit) When changing keyframe times from the inspector (not shown in the video, but works the same as dragging a keyframe)
godot-animation-timeline-changes.mp4

@dnllowe
Copy link
Contributor Author

dnllowe commented Jun 25, 2024

@TokageItLab , @Calinou Just a friendly ping to see if this is still on your radar

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally (rebased on top of master 374807f), it mostly works as expected.

There are 2 more remaining issues I noticed:

  • Changing playback mode or interpolation mode with these icons doesn't update the animation preview until you scrub the timeline:

image

  • If you drag a keyframe, it only updates the animation preview once the mouse cursor is released. I think it should update in real-time, without requiring you to release the mouse cursor. This is how it works already if you edit a property by dragging in the inspector.

@mihe
Copy link
Contributor

mihe commented Aug 20, 2024

@dnllowe Just a friendly ping to see if you've had a chance to look at the issues mentioned in the change request above. I can try to look into them otherwise, to help move things along here.

@TokageItLab
Copy link
Member

Has the rebase failed? It seems that most PR fixes are not working.

@dnllowe
Copy link
Contributor Author

dnllowe commented Aug 21, 2024

@mihe Thanks for the friendly reminder -- this did drop off my radar. I'll take a look today
@TokageItLab I think the rebase went ok

@dnllowe
Copy link
Contributor Author

dnllowe commented Aug 21, 2024

@mihe & @TokageItLab Unfortunately, my changes no longer seem to work when applied to the latest master branch. I don't think I'll have the time or the context to re-apply this functionality without potentially breaking something that was fixed between then and now. This weekend I'll take a closer look at what was changed in the meantime and see what the solution might be, but it might be drifting away from my grasp of the engine.

@TokageItLab
Copy link
Member

TokageItLab commented Aug 22, 2024

Perhaps this PR is affected by my fix #95405 disallowing seek to the same time in the editor.

You should create a new method that uses advance(0) for safer updates, or add an argument to _seek_value_changed() to allow same-time seek.

However, the former is much preferred if possible. Because if you use seek instead of advance, it will probably cause a bug that unintentionally snaps current position to the grid if current position is not on the grid and you update the key immediate after toggling the snap.

@dnllowe
Copy link
Contributor Author

dnllowe commented Aug 22, 2024

Perhaps this PR is affected by my fix #95405 disallowing seek to the same time in the editor.

You should create a new method that uses advance(0) for safer updates, or add an argument to _seek_value_changed() to allow same-time seek.

However, the former is much preferred if possible. Because if you use seek instead of advance, it will probably cause a bug that unintentionally snaps to the current position cursor if you update the key immediate after toggling the snap.

Thanks for the tip! I'll give this a try

@dnllowe
Copy link
Contributor Author

dnllowe commented Aug 22, 2024

@mihe, @TokageItLab I've updated the branch to work with the latest from master (using advance(0) did the trick).

@Calinou I was able to update the track when the animation modes change, but dragging a keyframe is a bit trickier. The keyframe position isn't updated until the mouse button is released, and logic about where the mouse drag started and stopped (seems) to be tied to clicking and releasing. So it becomes tough to try and A) Get the correct mouse drag distance in real-time and B) Update the animation keyframe in real-time (without inundating the undo history with every mouse movement). And even if done, the results are extremely erratic (at least for me, because I couldn't get a good method for the mouse drag distance in real-time). But perhaps it's possible somehow from gui_input.

Given that users were making do with none of these real-time updates / feedback before, I think this is as far as I can push these changes for now.

@dnllowe dnllowe requested a review from Calinou August 23, 2024 11:58
Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to squash.

The AnimationPlaybackTrack is not updated in real time, but since the AnimationPlaybackTrack is special case, so I judge that it is fine for now. I think we can follow up as needed, but probably refactoring godotengine/godot-proposals#8783 first.

@TokageItLab
Copy link
Member

@dnllowe To squash commits into one, please refer to https://docs.godotengine.org/en/stable/contributing/workflow/pr_workflow.html#the-interactive-rebase.

@dnllowe dnllowe force-pushed the realtime-animation-player-property-updates branch from 3999cf0 to 67a5932 Compare August 26, 2024 11:22
@dnllowe
Copy link
Contributor Author

dnllowe commented Aug 26, 2024

Need to squash.

The AnimationPlaybackTrack is not updated in real time, but since the AnimationPlaybackTrack is special case, so I judge that it is fine for now. I think we can follow up as needed, but probably refactoring godotengine/godot-proposals#8783 first.

@TokageItLab Thanks for that link!

Yes, a follow-up proposal with anything missing or more edge cases and polish would be a good way to go I think. Once godotengine/godot-proposals#8783 is done, feel free to ping me and I could probably have a look at updating the AnimationPlaybackTrack in real time (unless someone else is already further along with it)

Thanks for all the help and suggestions with the PR TokageItLab, Calinou, mihe, and patwork

@TokageItLab TokageItLab modified the milestones: 4.x, 4.4 Aug 26, 2024
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now. Great work!

@akien-mga akien-mga merged commit 7753900 into godotengine:master Aug 30, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@dnllowe
Copy link
Contributor Author

dnllowe commented Aug 31, 2024

Thanks! And congrats for your first merged Godot contribution 🎉

Thanks! My first real open source contribution in general really. It was fun :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants