Add "Use Local Space" option to the 2D editor#107264
Conversation
f732d33 to
03acb70
Compare
|
I think I've found another decent way to handle scale. There are 2 main options: option_1.mp4Option 2: option_2.mp4Option 1 was my initial approach. It scales along the given axis while attempting to preserve the the length of the object along the other axis. It only scales along the desired axis which is good, but it also distorts the object a lot. I like both, but I think option 2 will be a little more intuitive for most users. I definitely would appreciate input on this though. |
|
@DevPoodle The correct behavior is for the 2D scale gizmo to behave just like the 3D scale gizmo. So it's neither your Option 1 or Option 2. I can understand why other modes would be desired, like uniform scale, but that's not what the user expects when clicking on one scale handle. In the future, we could implement a Keep Mode dropdown like in Godot 4D which would allow the user to choose what level of "undistorted" they want the transform to be, but for now we don't have that, so the level of distorted should be keep orthogonal, just what can be decomposed into TRS, like in 3D. |
|
Alright, I think it works the same as the 3D editor now. I based the math off of Basis::scaled_orthogonal. I wasn't able to find an equivalent function for 2D, so I redid some of it. |
add0053 to
207d317
Compare
|
Tested, it doesn't work correctly. If I drag the global 2D scale handles, it just explodes to a huge size. scale_2d_doesnt_work.mp4 |
207d317 to
d3194d9
Compare
|
I forgot to take into account scaling at places other than the origin, should be fixed now🤞 |
|
@DevPoodle Thanks for working on this! It does seem to match 3D now. However, and I did not realize this before... the behavior in 3D is actually not correct either. In master, when you scale a global axis in 3D, it will expand or collapse depending on which direction the other axes are pointing. This doesn't really make any sense, and isn't good behavior. This PR currently does the same in 2D. I've recorded a video demonstrating this (whenever I shake the mouse side to side that's wrong). Also, I included an example of my 4D module (with "Keep Orthogonal" enabled), which behaves correctly: no matter which way the other axes are pointing, doing a global scale does not collapse the object. global_scale_not_correct.mp4 |
|
The main thing I'm unsure about is whether global scale should also rotate/skew the object. If we don't allow it to rotate or skew, then the "Option 2" I was previously using is the best option, because it scales the object as much as possible in the given direction without ever collapsing it. If we do allow rotation or skewing, then we would get a more mathematically accurate global scale like the one you demonstrated in your video. I honestly could go either way on this. I had assumed I shouldn't mess with rotation or skew because I personally wouldn't want the scale tool to affect those, but if it makes it significantly more intuitive for most users then its probably the right option. |
af160ef to
4371588
Compare
|
Alright, I just updated it so that global space scale affects skew and rotation. It should now match the behavior in the video you posted. After using it for a bit, it very clearly is better than the methods I was using before and made the code a little simpler as well. |
aaronfranke
left a comment
There was a problem hiding this comment.
Tested, this works correctly.
|
Thanks! |
Closes godotengine/godot-proposals#6799.
This adds in a "Use Local Space" button to the 2D editor like the 3D editor currently has. By default, Godot uses local space in the 2D editor anyway, so the actual functionality of this PR comes from turning it off, which allows you to do global space transformations. For global translations, this works exactly as you'd expect. For global scale, I made it so that when you scale along the x-axis, it attempts to preserve the height of the object, and when you scale along the y-axis, it attempts to preserve the width of the object. I personally find it intuitive, but there might be a more obvious way that I'm missing, so I'd really appreciate feedback on this.
Keep in mind that by default, "Use Local Space" is on, so there shouldn't be any immediate difference.