Skip to content

add orbit camera support to FRED2 and qtFRED#7310

Merged
BMagnu merged 1 commit into
scp-fs2open:masterfrom
Goober5000:feature/orbit-camera
Jun 4, 2026
Merged

add orbit camera support to FRED2 and qtFRED#7310
BMagnu merged 1 commit into
scp-fs2open:masterfrom
Goober5000:feature/orbit-camera

Conversation

@Goober5000
Copy link
Copy Markdown
Contributor

@Goober5000 Goober5000 commented Mar 21, 2026

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

Also fix an AND vs OR bug in FRED's process_controls().

@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
@Goober5000 Goober5000 force-pushed the feature/orbit-camera branch from 9399519 to 85ae3b1 Compare April 28, 2026 06:56
@MjnMixael MjnMixael mentioned this pull request Apr 28, 2026
Copy link
Copy Markdown
Contributor

@MjnMixael MjnMixael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not done a proper review of the code. I warned Goober that I was working on cleaning up the QtFRED camera code have asked him to wait with this PR until QtFRED is ready but I've mostly been ignored on that so I want to make sure I communicate clearly to the whole SCP team. The QtFRED part of this PR will need to wait until 7408 is merged which is designed to handle camera control upgrades such as the features added by this PR. Once 7408 is merged, this will need to be redone to move most of its code into the new camera class.

@github-project-automation github-project-automation Bot moved this from Work In Progress (PRs) to In Review (PRs) in qtFRED2 Apr 28, 2026
@Goober5000
Copy link
Copy Markdown
Contributor Author

None of that was clear previously. You indicated you were upset with this PR, but you refused to explain why.

Now that I know you want 7408 to go in first, I'm content to wait for that and treat it as a prerequisite.

@Goober5000 Goober5000 added this to the Release 26.0 milestone May 13, 2026
@Goober5000 Goober5000 force-pushed the feature/orbit-camera branch from 85ae3b1 to f5a6bbd Compare May 31, 2026 06:18
@Goober5000
Copy link
Copy Markdown
Contributor Author

Goober5000 commented May 31, 2026

Ok, this is finally rebased and updated. Tests work in both FRED and QtFRED.

@Goober5000 Goober5000 force-pushed the feature/orbit-camera branch from f5a6bbd to 2a5606a Compare May 31, 2026 06:56
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

Also fix an AND vs OR bug in FRED's process_controls().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Goober5000 Goober5000 force-pushed the feature/orbit-camera branch from 2a5606a to a2f9f9a Compare May 31, 2026 08:37
@BMagnu BMagnu dismissed MjnMixael’s stale review June 3, 2026 10:38

Camera Class support has been integrated

@BMagnu BMagnu merged commit 1240d2e into scp-fs2open:master Jun 4, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from In Review (PRs) to Done in qtFRED2 Jun 4, 2026
@Goober5000 Goober5000 deleted the feature/orbit-camera branch June 4, 2026 11:56
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: Done

Development

Successfully merging this pull request may close these issues.

3 participants