Skip to content

perf(view): Optimize and simplify camera transform update logic#2280

Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom
xezon:xezon/optimize-recalc-camera
Feb 10, 2026
Merged

perf(view): Optimize and simplify camera transform update logic#2280
xezon merged 2 commits intoTheSuperHackers:mainfrom
xezon:xezon/optimize-recalc-camera

Conversation

@xezon
Copy link

@xezon xezon commented Feb 9, 2026

This change optimizes and simplifies the camera transform update logic.

This ensures that the camera transform is only ever updated once a frame and not multiple times.

The performance saving is negligent.

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

greptile-apps bot commented Feb 9, 2026

Greptile Overview

Greptile Summary

This PR centralizes camera transform recomputation behind a new m_recalcCamera flag. Instead of calling setCameraTransform() immediately from multiple mutators (scroll/angle/pitch/zoom/etc.), those paths now mark the camera “dirty” and the transform is updated once at the end of W3DView::update() (or every frame when m_isCameraSlaved is enabled). It also defers the initial transform setup from init() by setting m_recalcCamera = true, ensuring the camera is initialized on the first update.

No additional merge-blocking issues were found in the changed logic beyond the already-addressed discussion about the drawable-lock path.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are localized to camera transform scheduling, preserve existing update conditions, and ensure the transform is recomputed when needed via a single end-of-update call guarded by a flag.
  • No files require special attention

Important Files Changed

Filename Overview
Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h Adds a member flag (m_recalcCamera) to track whether camera transform needs recomputation; no behavioral issues found.
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Consolidates camera transform updates behind m_recalcCamera to ensure setCameraTransform() is called at most once per update; constructor/init/reset behavior appears consistent; no regressions found in changed logic.

Sequence Diagram

sequenceDiagram
  participant Frame as Frame loop
  participant View as W3DView
  participant Cam as m_3DCamera

  Frame->>View: stepView()
  Note over View: Updates shake offsets only

  Frame->>View: update()
  View->>View: updateCameraLock/scroll/zoom/waypoints
  Note over View: Any camera-affecting change sets m_recalcCamera=true
  alt m_recalcCamera || m_isCameraSlaved
    View->>View: setCameraTransform()
    View->>Cam: Set_Transform(...)
    View->>View: m_recalcCamera=false
  else no camera change
    Note over View: No camera transform recompute this frame
  end

  Frame->>View: draw() / render passes
  View->>Cam: Apply() / used for rendering
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@xezon
Copy link
Author

xezon commented Feb 9, 2026

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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.

Ok

@xezon xezon merged commit c42b582 into TheSuperHackers:main Feb 10, 2026
24 checks passed
@xezon xezon deleted the xezon/optimize-recalc-camera branch February 10, 2026 18:19
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 Performance Is a performance concern 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