godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add viewport orbit snapping to orthographic views while holding ALT #8503

Open passivestar opened 9 months ago

passivestar commented 9 months ago

Describe the project you are working on

Any 3D game

Describe the problem or limitation you are having in your project

Switching to orthographic (left, front, top, etc) views is inefficient

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Allow holding ALT while orbiting to snap to 90-degree angles like in Blender:

https://github.com/godotengine/godot-proposals/assets/60579014/b4a5254e-4827-47fe-8dad-f74818c3ed24

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Technically speaking Blender has 2 ways of snapping with ALT:

I believe the second clever gesture option is not necessary as it's blender-specific (blender already has those gestures implemented), so just adding basic angle snapping that snaps to the closest angle as you orbit (like rotating objects with Ctrl in Godot) should do the trick

If this enhancement will not be used often, can it be worked around with a few lines of script?

The alternatives are to either click the viewport navigation widget on top right, or press the numpad keys. Neither of those are as fast. At the very least this would be a nice QOL addition since right now holding ALT doesn't do anything when you orbit

Is there a reason why this should be core and not an add-on in the asset library?

Basic 3D editor functionality

Calinou commented 9 months ago

Note that most Linux window managers intercept Alt + mouse buttons by default, so this shortcut needs some kind of alternative as not all users are willing to change their default window manager manipulation key (or even know how to change it). Blender encounters similar issues on Linux.

Blender can also snap to 45-degree increments when holding Alt, but the 45-degree slanted variants use perspective camera instead of orthographic.

https://github.com/godotengine/godot-proposals/assets/180032/508b5f38-1720-49c2-998f-8e7e06147cd5

YuriSizov commented 9 months ago

Note that most Linux window managers intercept Alt + mouse buttons by default, so this shortcut needs some kind of alternative

Can we check what Blender does for this on Linux?

Calinou commented 9 months ago

Can we check what Blender does for this on Linux?

Blender 3.6 doesn't appear to have any fallback if your window manager manipulation modifier is Alt. A reasonable fallback would likely be to bind any shortcut that uses Alt + Mouse to work with Meta + Mouse as well when on Linux. This way, regardless of which modifier used by your window manager, you will always have at least one of these shortcuts working.

On KDE, the window manager manipulation modifier can be changed here:

image

It appears Meta is actually the default in recent KDE versions (this is on Fedora 39). If only GNOME and other desktop environments did the same :slightly_smiling_face: