godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.54k stars 21.08k forks source link

Setting Node Scale to 0 unlocks component ratio lock (even if it still shows as locked) #82758

Open DoctorBLK opened 1 year ago

DoctorBLK commented 1 year ago

Godot version

v4.1.stable.mono.official [970459615]

System information

Windows 10 - v4.1.stable.mono.official [970459615]

Issue description

When setting a node's scale to 0, even if the Component Ratio lock is enabled, the scale axis edited next will update as if the Component Ratio is unlocked. During this, the component ratio icon does not update to show Unlocked. Even if set to 0, I would expect changing the scale to remain with a locked Component Ratio and update all axes equally.

Steps to reproduce

Place any node with Transform > Scale property into scene. Set scale to 0. Update any single axis to a new scale. Works by dragging or typing.

Minimal reproduction project

N/A

jackwilsdon commented 1 year ago

What would be the expected behavior here? Currently it appears to be intentional that a field's ratio is set to 0 when its value is set to 0:

https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/editor_properties_vector.cpp#L106-L110

And the value for components with a ratio of 0 is never updated:

https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/editor_properties_vector.cpp#L61-L63

We can't really use the previous ratio (from before the field was set to zero), as this is not persisted anywhere and is lost when switching the inspected node.

DoctorBLK commented 1 year ago

I think if the ratio is not expected to remain locked once a value of 0 is set, the expectation is simple: set the ratio explicitly to Unlocked.

If the locked icon shows as locked, regardless of the value, I would anticipate that changing the x scale will equally change the y scale. I would still expect the values to update equally even if it's set to 0, unless the icon updates to show that the ratio is now unlocked.

jackwilsdon commented 1 year ago

I would anticipate that changing the x scale will equally change the y scale. This isn't how the locked behavior currently works - it's based on the ratio between values at time of locking.

For example, if you have:

image

And you increase the X scale to 2, the other scales are updated using their ratios to the value you changed:

image

That's why when a value is 0, it doesn't really have a "ratio" to the value you changed.

DoctorBLK commented 1 year ago

Understood. I guess it's not so much of a bug. However, in the cases shown above with varying axes values, the ratio must be unlocked, and then locked again. In the case of setting the scale to 0 (for all), each axis value becomes independent of the remaining values, despite the ratio shown as locked.

I can see that it makes sense for the relative values from 0 to update relative to 0. But it's unintuitive, at the very least!

jackwilsdon commented 1 year ago

They don't really become independent, there's just no way to know what ratio to use for incrementing the values. A default raito of 1 might work for fields with a value of 0, but that may only make sense for scale (this also applies to transform and any other vector input).

Pheubel commented 1 year ago

Perhaps a tooltip or warning informing the user can be useful. Since it's no longer able to persist the original ratio, the editor has to make an assumption. But the user might not be aware that this happens. it could help explain why the user is getting a different result from what they might expect.

Calinou commented 1 year ago

I suggest using a ratio of 1:1 if the start value is 0. This is what I generally expect personally. While not perfect, it's arguably better behavior than acting as if the ratio was unlocked even if the icon displays as locked.

tetrapod00 commented 11 months ago

A 1:1 ratio would match expected behavior in what I assume is the most common case: scaling a transform, which by default comes with a locked 1:1 scale ratio. (Anecdotally, that case is also where I encountered this bug.)