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

"Use snap (Y)" behavior is inconsistent #90320

Open
ultrasuperpingu opened this issue Apr 6, 2024 · 3 comments · May be fixed by #91587
Open

"Use snap (Y)" behavior is inconsistent #90320

ultrasuperpingu opened this issue Apr 6, 2024 · 3 comments · May be fixed by #91587

Comments

@ultrasuperpingu
Copy link

Tested versions

4.3-dev5

System information

Windows 11 - Godot 4.3-dev5 Vulkan

Issue description

The "Use Snap (Y)" function does not work well in my project. I sometimes have to enable it for the translation gizmo to behave without snapping and sometimes, it work as expected (ie, to button state is not always corresponding to the real snapping mode).

I'm facing this annoying problem since weeks but I'm not able to find a scenario to reproduce it consistently...

Steps to reproduce

That's the problem, I can not find any reproductible scenario. What I can say is that my project have a custom EditorNode3DGizmoPlugin and a EditorNode3DGizmo but I'm not sure it is the source of the problem since I faced this problem while moving objects around using the translation gizmo... I think a faced this problem also in the "GodotXR Tools Demo" but I'm not sure.

Minimal reproduction project (MRP)

Sorry, I'm not able to provide this :(

@GustJc
Copy link

GustJc commented May 1, 2024

I was just about to create this issue.
It's been there for a while. I have this problem at least for 4.1+.

Here's what is happening as far as I figure out.
When you create a node with the shortcut "Control + A", the snap will stay flipped. It'll think you are still holding control.

But if you press "Control" or "Shift" once anywhere (while not dragging the node).
It'll fix itself and go back to normal behavior. That's why it feels inconsistent.
The Create Node shortcut probably forgot to update the control key status.
snap_shortcut_probelm
Here's a minimal example. Create a node with Control+A and try to move it.
At the end, I press and release the "Shift" key, and try to move it again. And it works normally.

@ultrasuperpingu
Copy link
Author

@GustJc It's great you figured out the problem. I can confirm the minimal example reproduce the problem.
Thanks :)

@ze2j
Copy link
Contributor

ze2j commented May 5, 2024

The issue comes from Node3DEditor::snap_key_enabled member which is not always updated. This member variable caches the state of the CTRL key as @GustJc guessed.

When using shortcuts like CTRL+S or CTRL+A, the current implementation leave snap_key_enabled at true which makes bool is_snap_enabled() const { return snap_enabled ^ snap_key_enabled; } return a flipped value because of the XOR.

@ze2j ze2j linked a pull request May 5, 2024 that will close this issue
@AThousandShips AThousandShips added this to the 4.3 milestone May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants