Skip to content

add orbit camera support to FRED2 and qtFRED#7310

Open
Goober5000 wants to merge 1 commit intoscp-fs2open:masterfrom
Goober5000:feature/orbit-camera
Open

add orbit camera support to FRED2 and qtFRED#7310
Goober5000 wants to merge 1 commit intoscp-fs2open:masterfrom
Goober5000:feature/orbit-camera

Conversation

@Goober5000
Copy link
Contributor

Implement a spherical-coordinate orbit camera for both the MFC (FRED2) and Qt (qtFRED) editors, providing intuitive 3D viewport navigation similar to other 3D editing tools.

Controls:

  • Middle mouse drag: orbit rotate around pivot point
  • Shift + middle mouse drag: pan the pivot point
  • Right mouse drag: orbit rotate (alternative to middle mouse)
  • Shift + right mouse drag: pan (alternative to shift + middle mouse)
  • Mouse wheel: zoom in/out
  • Right click without drag: context menu (preserving existing feature)

Camera pivot selection:

  • If an object is selected, orbit around that object
  • Otherwise, intersect the camera forward ray with the current grid plane to find a natural pivot point
  • Falls back to grid center if the camera is parallel to the grid

Grid-plane awareness:

  • Orbit axes are derived from The_grid->gmatrix using vm_vec_rotate and vm_vec_unrotate, so the camera orbits correctly on all three grid planes (XZ, XY, YZ), not just the default XZ plane
  • The look-at matrix uses the grid's up vector (uvec) rather than a hardcoded world-up direction

Robust zoom/pan scaling:

  • Zoom uses an exponential formula (powf) so the distance multiplier is always positive regardless of physics_speed setting (1-500)
  • Pan uses a clamped speed factor to avoid excessive movement at high physics_speed values

State management:

  • Keyboard camera movement (process_controls) invalidates orbit state, so the next mouse drag re-initializes from the current view
  • Orbit state is per-viewport in qtFRED (EditorViewport members) and global in FRED2 (matching existing conventions in each codebase)

Implementation:

  • FRED2: orbit math in fredrender.cpp, mouse handlers in fredview.cpp
  • qtFRED: orbit math in EditorViewport.cpp, mouse/wheel handlers in renderwidget.cpp; RenderWindow::event() updated to forward middle button and wheel events to RenderWidget

Implement a spherical-coordinate orbit camera for both the MFC (FRED2)
and Qt (qtFRED) editors, providing intuitive 3D viewport navigation
similar to other 3D editing tools.

Controls:
- Middle mouse drag: orbit rotate around pivot point
- Shift + middle mouse drag: pan the pivot point
- Right mouse drag: orbit rotate (alternative to middle mouse)
- Shift + right mouse drag: pan (alternative to shift + middle mouse)
- Mouse wheel: zoom in/out
- Right click without drag: context menu (preserving existing feature)

Camera pivot selection:
- If an object is selected, orbit around that object
- Otherwise, intersect the camera forward ray with the current grid
  plane to find a natural pivot point
- Falls back to grid center if the camera is parallel to the grid

Grid-plane awareness:
- Orbit axes are derived from The_grid->gmatrix using vm_vec_rotate
  and vm_vec_unrotate, so the camera orbits correctly on all three
  grid planes (XZ, XY, YZ), not just the default XZ plane
- The look-at matrix uses the grid's up vector (uvec) rather than a
  hardcoded world-up direction

Robust zoom/pan scaling:
- Zoom uses an exponential formula (powf) so the distance multiplier
  is always positive regardless of physics_speed setting (1-500)
- Pan uses a clamped speed factor to avoid excessive movement at high
  physics_speed values

State management:
- Keyboard camera movement (process_controls) invalidates orbit state,
  so the next mouse drag re-initializes from the current view
- Orbit state is per-viewport in qtFRED (EditorViewport members) and
  global in FRED2 (matching existing conventions in each codebase)

Implementation:
- FRED2: orbit math in fredrender.cpp, mouse handlers in fredview.cpp
- qtFRED: orbit math in EditorViewport.cpp, mouse/wheel handlers in
  renderwidget.cpp; RenderWindow::event() updated to forward middle
  button and wheel events to RenderWidget

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Goober5000 Goober5000 added qtfred A feature or issue related to qtFred. fred A feature or issue related to the FReespace EDitor (FRED) labels Mar 21, 2026
@github-project-automation github-project-automation bot moved this to Work In Progress (PRs) in qtFRED2 Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fred A feature or issue related to the FReespace EDitor (FRED) qtfred A feature or issue related to qtFred.

Projects

Status: Work In Progress (PRs)

Development

Successfully merging this pull request may close these issues.

1 participant