Skip to content

fix(view): integrate PR1711 camera defaults and backport to Generals#47

Merged
fbraz3 merged 2 commits intomainfrom
camera-fix
Mar 24, 2026
Merged

fix(view): integrate PR1711 camera defaults and backport to Generals#47
fbraz3 merged 2 commits intomainfrom
camera-fix

Conversation

@fbraz3
Copy link
Copy Markdown
Owner

@fbraz3 fbraz3 commented Mar 24, 2026

Summary

What Was Integrated

  • Cherry-picked upstream commit:
    • f0dc49b56 (fix(view): Adjust default camera height based on aspect ratio)

Backport Scope (Generals)

  • InGameUI: replace hardcoded setDefaultView(0.0f, 0.0f, 1.0f) usage with setCameraHeightAboveGroundLimitsToDefault() in init/reset.
  • ScriptActions: change camera default action flow to aspect-ratio-aware limits plus explicit pitch/angle updates.
  • GameLogic::startNewGame: initialize camera height limits and apply setZoomToMax() after default zoom setup.
  • OptionsMenu::saveOptions: refresh shell-map camera limits and zoom after display mode changes.
  • GlobalData: document 4:3 baseline semantics for max/min camera heights.

Validation

  • Checked staged scope is limited to camera-fix integration + Generals backport + dev diary update.
  • Verified there are no accidental escaped newlines in modified source files.
  • Language-service diagnostics report no syntax errors in changed files.

Notes

  • This PR intentionally focuses on camera default behavior parity between ZH and Generals.
  • Build/test execution is left for manual validation in local workflow.

Copilot AI review requested due to automatic review settings March 24, 2026 02:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Integrates TheSuperHackers PR1711 camera default-height fix (aspect-ratio-aware camera height limits) and backports equivalent camera-default behavior to the base Generals code paths to keep camera initialization and post-resolution-change behavior consistent across both games.

Changes:

  • Add aspect-ratio-aware camera height limit initialization (setCameraHeightAboveGroundLimitsToDefault) and use it during UI init/reset and game start.
  • Introduce setZoomToMax() and call it where the camera needs to be recomputed after resolution/aspect changes without disrupting scripted cameras.
  • Backport ZH camera-default script action flow and camera-default documentation notes to the base game.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
docs/DEV_BLOG/2026-03-DIARY.md Dev diary entry documenting the backport session and validation notes.
GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp Initializes camera height limits and applies zoom-to-max during new game startup.
GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp Updates scripted “camera set default” to apply aspect-aware limits + pitch/angle.
GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp Uses aspect-aware camera limit defaults during tactical view creation/reset.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp Refreshes camera limits + zoom-to-max after display mode changes (shell map).
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h Updates scripted camera default signature to match implementation.
GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h Documents camera min/max height as 4:3 baseline values scaled by aspect ratio.
Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp Backports camera height limit init + zoom-to-max during new game startup.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp Backports scripted camera default behavior to match ZH.
Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp Backports aspect-aware camera limit defaults during tactical view creation/reset.
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp Backports shell-map camera limits + zoom-to-max refresh after display changes.
Generals/Code/GameEngine/Include/GameLogic/ScriptActions.h Backports scripted camera default signature change.
Generals/Code/GameEngine/Include/Common/GlobalData.h Backports 4:3 baseline camera limit note.
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Implements aspect-aware camera height limit defaults; splits zoom-to-max from “default zoom reset”.
Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h Exposes setCameraHeightAboveGroundLimitsToDefault() and setZoomToMax() in W3DView.
Core/GameEngine/Source/GameClient/View.cpp Adds a base View::setZoomToMax() implementation.
Core/GameEngine/Include/GameClient/View.h Adds base virtual setCameraHeightAboveGroundLimitsToDefault() and setZoomToMax() to the View interface.
Comments suppressed due to low confidence (1)

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp:1993

  • setZoomToDefault() no longer updates m_zoom/m_heightAboveGround (it only stops scripted camera / invalidates constraints). Existing call sites that expect this to recompute the default/max zoom (e.g., after initHeightForMap() changes m_cameraOffset) will now leave the camera at an incorrect zoom. Consider making setZoomToDefault() call the new setZoomToMax() (then perform the scripted-camera reset), or update all call sites that need the recomputation to call setZoomToMax() explicitly.
void W3DView::setZoomToDefault()
{
	// default zoom has to be max, otherwise players will just zoom to max always
	stopDoingScriptedCamera();
	m_CameraArrivedAtWaypointOnPathFlag = false;
	m_cameraAreaConstraintsValid = false;
	m_recalcCamera = true;
}

Comment on lines +4273 to +4278
void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heighScale)
{
TheTacticalView->setDefaultView(pitch, angle, maxHeight);
// GeneralsX @tweak Copilot 23/03/2026 Mirror ZH scripted camera defaults for aspect-ratio-aware limits.
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(heighScale);
TheTacticalView->setPitch(pitch);
TheTacticalView->setAngle(angle);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Typo in parameter name: heighScale should be heightScale (and consistently renamed in declaration/definition and uses) to avoid propagating a misspelled identifier into the public scripting API.

Copilot uses AI. Check for mistakes.
void doCameraTetherNamed(const AsciiString& unit, Bool snapToUnit, Real play);
void doCameraStopTetherNamed();
void doCameraSetDefault(Real pitch, Real angle, Real maxHeight);
void doCameraSetDefault(Real pitch, Real angle, Real heighScale);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Typo in parameter name: heighScale should be heightScale to keep the scripting API readable and consistent with W3DView::setCameraHeightAboveGroundLimitsToDefault(Real heightScale).

Suggested change
void doCameraSetDefault(Real pitch, Real angle, Real heighScale);
// GeneralsX @bugfix assistant 24/03/2026 Fix typo in parameter name to use heightScale for consistency with W3DView API.
void doCameraSetDefault(Real pitch, Real angle, Real heightScale);

Copilot uses AI. Check for mistakes.
{
// TheSuperHackers @fix Mauller Adjust the camera height to compensate for the screen aspect ratio
Real baseAspectRatio = (Real)DEFAULT_DISPLAY_WIDTH / (Real)DEFAULT_DISPLAY_HEIGHT;
Real currentAspectRatio = (Real)TheTacticalView->getWidth() / (Real)TheTacticalView->getHeight();
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

setCameraHeightAboveGroundLimitsToDefault() computes the current aspect ratio via TheTacticalView->getWidth()/getHeight(). Since this is already a W3DView instance method, using getWidth()/getHeight() (or m_width/m_height) would avoid dependence on the global singleton and reduce the risk of a null/0-height divide if this is ever called before TheTacticalView is fully initialized.

Suggested change
Real currentAspectRatio = (Real)TheTacticalView->getWidth() / (Real)TheTacticalView->getHeight();
// GeneralsX @bugfix copilot 24/03/2026 Use this view's dimensions and guard against zero height.
Real currentAspectRatio;
if (getHeight() > 0) {
currentAspectRatio = (Real)getWidth() / (Real)getHeight();
} else {
currentAspectRatio = baseAspectRatio;
}

Copilot uses AI. Check for mistakes.
Comment on lines +132 to +134
void View::setZoomToMax()
{
setHeightAboveGround(getHeightAboveGround() + m_maxHeightAboveGround);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

View::setZoomToMax() currently adds m_maxHeightAboveGround to the current height. If m_zoomLimited is false (no clamping), this can overshoot the intended max. Setting the height directly to m_maxHeightAboveGround would better match the method name/intent and be consistent with W3DView::setZoomToMax() semantics.

Suggested change
void View::setZoomToMax()
{
setHeightAboveGround(getHeightAboveGround() + m_maxHeightAboveGround);
// GeneralsX @bugfix ChatGPT 24/03/2026 Make setZoomToMax set absolute max height instead of adding to current height.
void View::setZoomToMax()
{
setHeightAboveGround(m_maxHeightAboveGround);

Copilot uses AI. Check for mistakes.
Comment on lines +4604 to +4608
void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heighScale)
{
TheTacticalView->setDefaultView(pitch, angle, maxHeight);
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(heighScale);
TheTacticalView->setPitch(pitch);
TheTacticalView->setAngle(angle);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Typo in parameter name: heighScale should be heightScale (and consistently renamed in declaration/definition and uses) to avoid propagating a misspelled identifier into the public scripting API.

Copilot uses AI. Check for mistakes.
void doCameraTetherNamed(const AsciiString& unit, Bool snapToUnit, Real play);
void doCameraStopTetherNamed();
void doCameraSetDefault(Real pitch, Real angle, Real maxHeight);
void doCameraSetDefault(Real pitch, Real angle, Real heighScale);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Typo in parameter name: heighScale should be heightScale to keep the scripting API readable and consistent with W3DView::setCameraHeightAboveGroundLimitsToDefault(Real heightScale).

Suggested change
void doCameraSetDefault(Real pitch, Real angle, Real heighScale);
// GeneralsX @bugfix Copilot 24/03/2026 Fix typo in camera default height scale parameter name for scripting API clarity
void doCameraSetDefault(Real pitch, Real angle, Real heightScale);

Copilot uses AI. Check for mistakes.
@fbraz3 fbraz3 merged commit af6db61 into main Mar 24, 2026
11 checks passed
@fbraz3 fbraz3 deleted the camera-fix branch March 24, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants