Add camera fly mode + zoom towards cursor#437
Add camera fly mode + zoom towards cursor#437tatelax wants to merge 5 commits intoguillaumechereau:masterfrom
Conversation
- Remove contaminated snap_offsets[3], snap_units[3], use_brush_size fields from goxel.h - Remove contaminated initialization code from goxel.c - Restore goxel_unproject() function to original signature and implementation - Fix all function calls to use gest3d->snap_offset instead of goxel.snap_offsets - Keep only pure FPS camera functionality (fly mode, WASD, mouse look, camera_fov) - Project compiles successfully without errors
- Space bar now moves camera up in world space - Left Ctrl now moves camera down in world space - Maintains existing WASD horizontal movement - Works with existing speed boost (Shift) and mouse look - Same functionality as added to dev branch Complete fly mode controls: - Right-click + WASD: Enter fly mode with movement - Space: Move up - Left Ctrl: Move down - Shift: Double movement speed - Mouse: Look around (yaw/pitch) - Mouse wheel: Zoom in/out
|
VS Code automatically reformatted everything without me realizing so you will need to pull the changes and reformat it to your preference before merging. |
|
Thanks, I just tried but it seems to be broken at the moment no? On my linux when I start goxel the camera is at the wrong position and normal movements are not working anymore. |
Hi, can you try again? Confirmed working on macOS. Haven't tested any other platforms. |
|
Yes this is the expected behavior. This is because I've modified the zoom function to move the camera itself forward, instead of adjusting FOV of the camera. By default I set the FOV to 80 which is quite high and made it configurable in the settings menu. The reason for this change is that zooming with FOV becomes very cumbersome when working on intricate objects. Such as the interior of a building. By moving the camera itself, the user can position the camera easier. Similar to how a game engine camera works. Use right click + WASD/Shift/Spacebar to move the camera. I know this is a large change so if you don't want to merge it that's fine but for me without all of these PR's Goxel has become very difficult to use as my game environment data becomes more complex. |
|
Note: I have a fix for zooming to the cursor if there is no voxel present. If you want this PR merged I can migrate the fix from my fork. |
|
I'll have to check a bit more, I don't have much time today. As far as I remember the camera is already having a fixed FOV, and 'zooming' just moves it toward the target. Or maybe I miss something? This was written a long time ago maybe I don't remember correctly. |
|
Hi @guillaumechereau, @tatelax, I'd love for this PR to be merged if possible/desired. It implements a FOV slider and fly mode, which I feel are missing from Goxel for me. Bildschirmaufzeichnung.vom.2025-09-14.21-51-08.webmThe terminal prints: glfw error 65548 (Wayland: The platform does not support setting the cursor position)This is because the current code in the PR tries to reset the cursor to the center of the window and fails on GNOME (Wayland).
I was able to fix the erratic behavior by changing line 1237 in - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
+ glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);This should make setting the cursor position in lines 1387 to 1414 redundant, as GLFW should handle it internally.
This could be restored to how it was before by changing these lines back to the previous values: In src/goxel.c L564, set FOV to 20°: // Initialize camera settings
- goxel.camera_fov = 80.0f; // Default FOV to 80 degrees
+ goxel.camera_fov = 20.0f; // Default FOV to 20 degrees
goxel.zoom_speed = 1.0f; // Default zoom speedIn src/camera.c L28, increase distance to 128: - cam->dist = 48;
+ cam->dist = 128;This results in the same view as before without distortion due to the higher FOV:
Also, the FOV preference in the settings doesn't seem to be loaded correctly right now, because the values are overwritten after the call to I hope this helps and thank you for your time. |
|
@FelisDiligens If you can open a PR on my fork, I can merge it there: https://github.com/tatelax/goxelplusplus On my fork I have several other QOL improvements. Not all of which I have opened PRs for in the original repo because it became too cumbersome as changes are interdependent upon each other. |
|
I'd like to merge something like that, but currently the branch doesn't work at all for me (on ubuntu). It breaks the normal camera controls, and the WASD control don't work either. It also deformed the perspective projection. |
|
@tatelax Would it be okay if I use some of your code and my proposed fixes to open a new PR here? @guillaumechereau I'd love to fix the issues and get the WASD control, and FOV setting to work. |
|
Sure no problem.
…On Tue, Sep 16, 2025 at 18:29 FelisDiligens ***@***.***> wrote:
*FelisDiligens* left a comment (guillaumechereau/goxel#437)
<#437 (comment)>
@tatelax <https://github.com/tatelax> Would it be okay if I use some of
your code and my proposed fixes to open a new PR here?
@guillaumechereau <https://github.com/guillaumechereau> I'd love to fix
the issues and get the WASD control, and FOV setting to work.
—
Reply to this email directly, view it on GitHub
<#437 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA2JHZETBWGGPOAO25QH233S7RB5AVCNFSM6AAAAACA7SKHAWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEOJXGU2DKMRTGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
This feature is now implemented as part of Goxel++ |


This PR adds a completely new way of controlling the camera while maintaining existing camera controls.
If WASD is pressed while holding right-click, the camera enters 'fly mode' where the user is free to fly around the scene. Holding shift doubles the movement speed.
This also refactors zooming to move the camera forward in space instead of adjusting FOV. FOV can now be adjusted in Settings.
This change makes it significantly easier to position the camera in tight spaces, such as the interior of buildings.
Also, this PR adjusts zooming logic to zoom the location of the mouse cursor.
Default Controls
W = Forward
A = Left
S = Backward
D = Right
Space = Up
Left Ctrl = Down
cameracontrols.mp4