Skip to content

Commit 51811c2

Browse files
committed
fix(view): Adjust default camera height to compensate for screen aspect ratio
1 parent 45178ee commit 51811c2

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ Real W3DView::getCameraOffsetZ() const
674674
}
675675
#endif
676676

677-
return m_pos.z + TheGlobalData->m_maxCameraHeight;
677+
return m_pos.z + m_maxHeightAboveGround;
678678
}
679679

680680
//-------------------------------------------------------------------------------------------------
@@ -2233,10 +2233,24 @@ void W3DView::setPitchToDefault()
22332233
//-------------------------------------------------------------------------------------------------
22342234
void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)
22352235
{
2236+
// TheSuperHackers @fix Mauller 08/05/2026 Adjust the maximum camera height to compensate for screen aspect ratio
2237+
Real baseAspectRatio = (Real)DEFAULT_DISPLAY_WIDTH / (Real)DEFAULT_DISPLAY_HEIGHT;
2238+
Real currentAspectRatio = (Real)TheTacticalView->getWidth() / (Real)TheTacticalView->getHeight();
2239+
Real aspectRatioScale = 1.0f;
2240+
2241+
if (currentAspectRatio > baseAspectRatio)
2242+
{
2243+
aspectRatioScale = fabs((1.0f + (currentAspectRatio - baseAspectRatio)));
2244+
const float nerf = 1.0f - (currentAspectRatio - baseAspectRatio) / 12.0f;
2245+
2246+
aspectRatioScale *= nerf;
2247+
}
2248+
22362249
// MDC - we no longer want to rotate maps (design made all of them right to begin with)
22372250
// m_defaultAngle = angle * M_PI/180.0f;
22382251
setDefaultPitch(pitch);
2239-
m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight*maxHeight;
2252+
m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight * aspectRatioScale * maxHeight;
2253+
m_minHeightAboveGround = TheGlobalData->m_minCameraHeight * aspectRatioScale;
22402254
if (m_minHeightAboveGround > m_maxHeightAboveGround)
22412255
m_maxHeightAboveGround = m_minHeightAboveGround;
22422256
}
@@ -2278,7 +2292,6 @@ void W3DView::setZoomToDefault()
22782292
m_heightAboveGround = m_maxHeightAboveGround;
22792293
m_zoom = getMaxZoom(m_pos.x, m_pos.y);
22802294

2281-
stopDoingScriptedCamera();
22822295
m_CameraArrivedAtWaypointOnPathFlag = false;
22832296
m_cameraAreaConstraintsValid = false;
22842297
m_recalcCamera = true;

GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,11 @@ class GlobalData : public SubsystemInterface
190190
#if PRESERVE_RETAIL_SCRIPTED_CAMERA
191191
Real m_cameraHeight;
192192
#endif
193+
194+
// TheSuperHackers @info Max and Min camera height for the original 4:3 view, these are then scaled for other aspect ratios.
193195
Real m_maxCameraHeight;
194196
Real m_minCameraHeight;
197+
195198
Real m_terrainHeightAtEdgeOfMap;
196199
Real m_unitDamagedThresh;
197200
Real m_unitReallyDamagedThresh;

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,13 @@ static void saveOptions()
877877

878878
TheInGameUI->recreateControlBar();
879879
TheInGameUI->refreshCustomUiResources();
880+
881+
// TheSuperHackers @info Update the view so the shellmap looks correct when changing resolution
882+
TheTacticalView->setDefaultView(
883+
DEG_TO_RADF(TheGlobalData->m_cameraPitch),
884+
DEG_TO_RADF(TheGlobalData->m_cameraYaw),
885+
1.0f);
886+
TheTacticalView->setZoomToDefault();
880887
}
881888
}
882889
}

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,10 @@ void GameLogic::tryStartNewGame( Bool loadingSaveGame )
20812081
// update the loadscreen
20822082
updateLoadProgress(LOAD_PROGRESS_POST_PRELOAD_ASSETS);
20832083

2084+
TheTacticalView->setDefaultView(
2085+
DEG_TO_RADF(TheGlobalData->m_cameraPitch),
2086+
DEG_TO_RADF(TheGlobalData->m_cameraYaw),
2087+
1.0f);
20842088
TheTacticalView->setAngleToDefault();
20852089
TheTacticalView->setPitchToDefault();
20862090
TheTacticalView->setZoomToDefault();

0 commit comments

Comments
 (0)