Skip to content

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

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

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

Conversation

@xezon
Copy link

@xezon xezon commented Feb 25, 2026

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
Copy link

greptile-apps bot commented Feb 25, 2026

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

Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

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

Looks good

@xezon
Copy link
Author

xezon commented Feb 25, 2026

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
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