-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix snapping multiple keys in Animation #88498
Fix snapping multiple keys in Animation #88498
Conversation
89ae481
to
51672ec
Compare
If you are testing this, in order to test the Bezier editor with multiple selected keyframes need to merge #88459 first (or wait for that one to be merged, then I'll rebase this one). |
51672ec
to
049550c
Compare
rebased on top of 25a52c6 |
This is ready for review btw, so somebody could give it a look, that'd be great :) |
There's a weird glitch in the last gif where the top keyframe moves left before moving right. Is there a reason it appears to act differently depending on where the mouse is dragged? I would think that snap would move the selected keyframes in units of one snap length. Though I've found snap tends to corrupt keyframes even when selecting them so I shy away from the feature in general. |
@lyuma This is entirely normal and intended. When you select a keyframe and begin dragging the mouse, it snaps the key to the closest snapping point. Say you select it at t=0.6 and snapping is 0.5. Even though you move the mouse in the positive time direction, it would first snap at 0.5, hence the opposite direction of the mouse movement. Only when you move the mouse past t=0.75 it will snap the key to 1.0. This is what you observe in the gif. Snapping always snaps to the absolute time points, not relatively. The fact that the snapping is corrupt is precisely what this PR tries to solve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem with keys teleporting to the mouse cursor position when dragging a key with a length. That must be fixed.
snap.mp4
In the preview video in description there is also a rapid movement at the start of the drag, which seems to be a problem as pointed out by lyuma. Even if that is the behavior you are assuming, it would appear to be a bug to the general user (looks buggy than the old behavior), so until that is resolved this change should not be approvable.
Perhaps the preferred behavior would be to use only the first key for snapping (then most old behaviors need not be changed), propagating the relative movement of the first key to the other keys.
Anyway, snapping based on the mouse position is definitely a strange behavior, so it must be based on one of the keys.
In the case of clicking on a blank space in a multiple selection, it is better to snap based on the first key, since it is a rough use case to click on an empty space after multiple selections. It would be uncomfortable not knowing which key will be snapped in priority when dragging just middle of the space between two keys. So using the first key rather than any of them as the basis for snapping is desirable here because it is clearly consistent. As a compromise, it is recommended to separate the operations according to whether or not you are actually clicking on the key. If you are actually pointing down/dragging a specific key in multiple selections, it is fine to snap based on that key. This means that it only needs to determine whether the key is actually pressed, rather than searching for the shortest key. |
There is effectively no use case for "clicking on a blank space in a multiple selection" here. You can only drag keys if you explicitly click on one, which makes perfect sense. Clicking on blank space just deselects everything. |
I think it doesn't make sense to snap it back to its original position. If you are trying to implement it as a hack to prevent unintended fast key shaking at the start of a drag, you need to address the root cause of that shaking instead of doing so. Perhaps the cause may be that keys are copied and deleted individually in sequence, so changing the process so that multiple keys are deleted at the same time and added at the same time may fix the problem. |
I don't think we have a clear mutual understanding of what is meant by the "shaking". I understood that you meant that the keys are snapped at positions that the user would not intend to e.g. when he moves the key in the positive time direction, but the nearest snapping point is in the negative direction. It does look weird in the GIFs I posted, but simply because I am always grabbing a keyframe that is sort of "on the edge" of two snap points, being zoomed out quite a lot. If you try the feature yourself slowly, you might notice what this issue stems from. However, there are no issues in the way keyframes are deleted or inserted, the issue that this PR fixes is simply that the insertion positions are calculated in a wrong way. However, at this point I am unsure what behavior you actually want me to implement. Maybe you want to take a look at the PR again, and reorder your thoughts. |
So never mind that I was misunderstood about this.
Shaking means that the key is shaken in an unintended direction for a moment at the start of the drag in the first video as lyuma and I said. I don't know the details of what causes that, but you must fix that behavior anyway.
If you are thinking of using two snap points for the entire range, I think it is not a good behavior in Godot which basically has discrete keys; You need to refer to the use case of editing keyframes in AfterEffects or Blender, not DAW. The snap points should only refer the one key that is actually clicked down, and the other keys should only follow relative to it. |
I confirmed this with the old behavior, but I think it was less noticeable in the old behavior because it snapped individually when multiple selections were made. This PR makes it appear that all keys move in the wrong direction at the same time, so it should be fixed. To prevent unintended movement, I think it would be better to add a special case at the first movement of the drag (the moment the abs of mouse movement value exceeds CMP_EPSILON), snap to right if it is positive, snap to left if it is negative. |
049550c
to
b2422ae
Compare
I implemented a fix for both the audio track issue, and the issue of keyframes snapping against the direction of mouse movement. Feel free to test it, and let me know if this behavior was what you had in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay LGTM! Thanks for adjusting the behavior.
my pleasure! :) |
I discovered there is still a small issue with reselection of the keys. Going to fix now. |
b2422ae
to
d88df64
Compare
…ltiple Fix snapping multiple keys in Animation
06abc86
Thanks! |
Fixes an old bug, that snapped all moved keyframes in the Animation Player and Bezier editor to the same position, hence reducing a selection of keyframes to a single keyframe.
Before:
After: