fix(view): integrate PR1711 camera defaults and backport to Generals#47
fix(view): integrate PR1711 camera defaults and backport to Generals#47
Conversation
There was a problem hiding this comment.
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 updatesm_zoom/m_heightAboveGround(it only stops scripted camera / invalidates constraints). Existing call sites that expect this to recompute the default/max zoom (e.g., afterinitHeightForMap()changesm_cameraOffset) will now leave the camera at an incorrect zoom. Consider makingsetZoomToDefault()call the newsetZoomToMax()(then perform the scripted-camera reset), or update all call sites that need the recomputation to callsetZoomToMax()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;
}
| 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); |
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
Typo in parameter name: heighScale should be heightScale to keep the scripting API readable and consistent with W3DView::setCameraHeightAboveGroundLimitsToDefault(Real heightScale).
| 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); |
| { | ||
| // 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(); |
There was a problem hiding this comment.
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.
| 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; | |
| } |
| void View::setZoomToMax() | ||
| { | ||
| setHeightAboveGround(getHeightAboveGround() + m_maxHeightAboveGround); |
There was a problem hiding this comment.
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.
| 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); |
| void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heighScale) | ||
| { | ||
| TheTacticalView->setDefaultView(pitch, angle, maxHeight); | ||
| TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(heighScale); | ||
| TheTacticalView->setPitch(pitch); | ||
| TheTacticalView->setAngle(angle); |
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
Typo in parameter name: heighScale should be heightScale to keep the scripting API readable and consistent with W3DView::setCameraHeightAboveGroundLimitsToDefault(Real heightScale).
| 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); |
Summary
camera-fix.GeneralsMDto base gameGeneralspaths.What Was Integrated
f0dc49b56(fix(view): Adjust default camera height based on aspect ratio)Backport Scope (Generals)
InGameUI: replace hardcodedsetDefaultView(0.0f, 0.0f, 1.0f)usage withsetCameraHeightAboveGroundLimitsToDefault()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 applysetZoomToMax()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
Notes