Add a Scaling Modifier to scale animation Keys and Markers#105151
Add a Scaling Modifier to scale animation Keys and Markers#105151PhairZ wants to merge 1 commit intogodotengine:masterfrom
Conversation
ca31a04 to
50c4948
Compare
This comment was marked as outdated.
This comment was marked as outdated.
fed81ae to
c144513
Compare
|
I'll find some time to test it though I'm sick right now. |
|
Scaling in the curve editor has already been handled in PR #100470 |
|
I find this somewhat difficult to use. For example I'd want to stretch 1s animation to 2s: godot.windows.editor.dev.x86_64_ngZ2NWWCyQ.mp4Dragging the keys to the right always shrinks them, so I have to overshoot the animation, then move them back. Also it involves guess work on how much I need to scale, there is no way to scale in fixed increments (steps). I think scaling should be opposite, i.e. dragging to the right should expand. Or at least there should be modifier to reverse the direction. |
|
I tried to match how blender behaves when scaling, because its the animation software most users would be familiar with (and it was mentioned in the proposal). It scaled the animation relative to the cursor (The timeline current time). 2025-06-12.18-28-30.mp4I hope you can see the similarities. Edit: Similar to blender, holding CTRL while dragging snaps too. Updated the PR description. |
|
Ok I completely missed that it scales from cursor. Makes sense. However I noticed there is some weird line appearing when you Alt+drag: godot.windows.editor.dev.x86_64_gOZO0160jv.mp4Is this intended? |
No, this is not. |
|
When you try to scale 2 markers, with cursor being at the same position as one of them, the marker might move uncontrollably. jSknDyBM1R.mp4Notice how it ended up outside timeline, after minimal mouse movement. |
|
Maybe that can be resolved by making scalings that are from really close to the cursor use a different scaling factor? |
ecd93c3 to
20dba46
Compare
|
@KoBeWi Addressed the issue by making it so that whenever the mouse cursor is too close to pivot, we add a small constant value to increase the difference of the cursors. This seems to work fine, I would be pleased to hear your feedback. |
KoBeWi
left a comment
There was a problem hiding this comment.
Functionality-wise looks fine now.
Code still needs review from animation team.
|
This honestly feels kinda unpolished. The scaling of bezier keys follows on Unity's footsteps by showing handles for scaling, and I think scaling for basic keys should do the same. |
|
I kinda do agree, but scaling like this is usually faster and matches with blender, and works well with the already existent Keyframe/Marker move action. I'd like to hear more of your thoughts on this. |
|
Handles work better because they are more intuitive. Instead of being in a shortcut that the user will not be aware of from the get-go unless they already have experience with it on things like Blender, handles are tangible things they can be interacted with and be can be understood immediately. Besides, handles and shortcuts aren't mutually exclusive, they can co-exist. But I think handles should be the ones implemented first. |
|
Feedback from animation meeting. We agree the feature of being able to scale animation keyframes is important, but we some UX fixes. Here are some of the notes of what people brought up in the meeting:
|
I think this should be added too, currently there's no real feedback to transforming.
Can I have a reason for why is that? I think being able to scale relative to the timeline head, because it allows for more freedom. Maybe we can have those as an option in the animation settings tho.
YeldhamDev did say so and I am convinced. When I get to working on updating this PR this will definitely be the first thing to be added.
The current implementation does allow for this by crossing the origin of scaling with the mouse cursor (If starting from the right side of the anchor, negative scaling would occur when moving the mouse cursor to the left side of the anchor). |
|
This only implements the handles and is still unfinished but I decided to push it for feedback from the animation team and to discuss some bits of the code implementation. |
PhairZ
left a comment
There was a problem hiding this comment.
I hacked away this and pushed it mostly for feedback. This implements the scaling handles. I still didn't settle on the Implementation so that is still to be discussed.
It's still rough around the edges here and there but the idea itself works, but I just want feedback on the behavior and the code.
| int track_last = -1; | ||
| if (editor->is_selection_active()) { | ||
| for (int i = 0; i < animation->get_track_count(); i++) { | ||
| for (int j = 0; j < animation->track_get_key_count(i); j++) { |
There was a problem hiding this comment.
I think this bit should be wrapped up in it's own function because it's quite big and used a couple of times around the code.
Though, I find needing a nested for loop to find the leftmost and rightmost keys inside the entire animation quite demanding, and this can get quite heavy with animations with tens of tracks and hundreds of keys. I did this for now just to get the idea rolling but I don't know if we can just leave this thing living here. :/
| scaling_selection = false; | ||
| emit_signal(SNAME("scale_selection_cancel")); | ||
| moving_selection = false; | ||
| emit_signal(SNAME("move_selection_cancel")); |
There was a problem hiding this comment.
Someone said this before, maybe this bit should be wrapped in a function. I personally think that "Yeah, less repetition = better", but this line is kinda repeated only once or twice with other copies having a slight change, so either we make a function with more complex logic (maybe something like set_transform_state(TransformState p_state)), or just leave every variation be.
There was a problem hiding this comment.
Personally I only make a function if I reuse the code three times..
|
Tried out this PR as I had been working on the same thing without realising you were working on it. The scaling with the mouse works well, I don't know if the plan was to add both that and the handle scaling. It appears you haven't done much work on the handle scaling yet and I have that mostly done in my PR. Not sure what the best way to proceed is. Link to my PR. #112488 |
That's really cool! May I proceed with the rest? I'm not that used to Github yet so I'd like you to tell me if there's a way to get you as an author on this PR too, or give you some credit since you've done basically a lot of the work. I'm also totally fine by closing this PR as superseded if a request for scaling with Alt key modifier isn't really favored by the animation team. |
I think the best thing is just to get one of them merged and then rebase the other after to add the missing features. I think mine is quite ready to merge at this point, so when that's point I could look at rebasing this or making a new PR that adds the mouse shortcut scaling as well using your code and set us as co-authors. For now I'd just leave this open until we see if mine get's merged :). |


Closes godotengine/godot-proposals#3532
Uses ALT Modifier when moving selected to scale selected instead. Pressing CTRL flips snapping (aka if snapping is on it behaves as it were off and vice versa) matching how moving keyframes works.
2025-04-13.02-06-34.mp4