Skip to content

refactor(lookat): Simplify pitch, fov, zoom logic in LookAtTranslator#2351

Merged
xezon merged 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/refactor-lookatxlat
Feb 26, 2026
Merged

refactor(lookat): Simplify pitch, fov, zoom logic in LookAtTranslator#2351
xezon merged 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/refactor-lookatxlat

Conversation

@xezon

@xezon xezon commented Feb 25, 2026

Copy link
Copy Markdown

This change simplifies the pitch, fov and zoom logic in LookAtTranslator for ease of read.

TODO

  • Replicate in Generals

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Feb 25, 2026
@greptile-apps

greptile-apps Bot commented Feb 25, 2026

Copy link
Copy Markdown

Greptile Summary

This PR refactors camera control logic in LookAtTranslator to improve code clarity and eliminate unnecessary loops. The changes include: (1) renaming FACTOR to Scale with constexpr const qualifier for pitch and FOV calculations, (2) replacing loop-based mouse wheel zoom with direct multiplication (mathematically equivalent since View::zoom() is additive), and (3) improving control flow by consolidating else if and moving comments inside code blocks. All changes are behavior-preserving refactorings that reduce line count from 52 to 28 lines while maintaining identical functionality.

Confidence Score: 5/5

  • This PR is safe to merge with no risk - pure refactoring with verified logic equivalence
  • All changes are straightforward code simplifications with mathematically equivalent logic. The zoom calculation was verified to be equivalent (multiple additive calls = single sum call), variable declarations are improved with const/constexpr, and formatting changes enhance readability without altering behavior.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp Refactored pitch/FOV scaling, simplified mouse wheel zoom from loops to direct multiplication, improved comment placement and control flow formatting
GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp Identical refactoring to Generals version: improved scaling constants, simplified zoom calculation, and better control flow structure

Last reviewed commit: 7323417

@Skyaero42 Skyaero42 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good

@xezon

xezon commented Feb 25, 2026

Copy link
Copy Markdown
Author

Replicated in Generals without conflicts.

@xezon xezon merged commit ba85aae into TheSuperHackers:main Feb 26, 2026
25 checks passed
@xezon xezon deleted the xezon/refactor-lookatxlat branch February 26, 2026 18:22
@xezon xezon added this to the Camera Rework milestone Feb 26, 2026
Okladnoj pushed a commit to Okladnoj/GeneralsGameCode that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants