Skip to content

Commit 1a78051

Browse files
authored
bugfix(view): Fix camera terrain height adjustment during camera playback in Replay playback (#1598)
1 parent 8078a22 commit 1a78051

File tree

8 files changed

+20
-34
lines changed

8 files changed

+20
-34
lines changed

Generals/Code/GameEngine/Include/GameClient/View.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,11 @@ class View : public Snapshot
180180
virtual const Coord3D& get3DCameraPosition() const = 0; ///< Returns the actual camera position
181181

182182
virtual Real getZoom() { return m_zoom; }
183-
virtual void setZoom(Real z) { }
183+
virtual void setZoom(Real z) { m_zoom = z; }
184184
virtual Real getHeightAboveGround() { return m_heightAboveGround; }
185185
virtual void setHeightAboveGround(Real z);
186186
virtual void zoom( Real height ); ///< Zoom in/out, closer to the ground, limit to min, or farther away from the ground, limit to max
187187
virtual void setZoomToDefault( void ) { m_zoom = 1.0f; } ///< Set zoom to default value
188-
virtual Real getMaxZoom( void ) { return m_maxZoom; } ///< return max zoom value
189188
virtual void setOkToAdjustHeight( Bool val ) { m_okToAdjustHeight = val; } ///< Set this to adjust camera height
190189

191190
// for debugging
@@ -263,8 +262,6 @@ class View : public Snapshot
263262
Real m_angle; ///< Angle at which view has been rotated about the Z axis
264263
Real m_pitchAngle; ///< Rotation of view direction around horizontal (X) axis
265264

266-
Real m_maxZoom; ///< Largest zoom value (minimum actual zoom)
267-
Real m_minZoom; ///< Smallest zoom value (maximum actual zoom)
268265
Real m_maxHeightAboveGround; ///< Highest camera above ground value
269266
Real m_minHeightAboveGround; ///< Lowest camera above ground value
270267
Real m_zoom; ///< Current zoom value

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5345,7 +5345,9 @@ void InGameUI::updateAndDrawWorldAnimations( void )
53455345
UnsignedInt height = wad->m_anim->getCurrentFrameHeight();
53465346

53475347
// scale the width and height given the camera zoom level
5348-
Real zoomScale = TheTacticalView->getMaxZoom() / TheTacticalView->getZoom();
5348+
// TheSuperHackers @todo Rework this with sane values. scaler=1.3 originally came from TheTacticalView::getMaxZoom()
5349+
constexpr Real scaler = 1.3f;
5350+
Real zoomScale = scaler / TheTacticalView->getZoom();
53495351
width *= zoomScale;
53505352
height *= zoomScale;
53515353

Generals/Code/GameEngine/Source/GameClient/View.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ View::View( void )
4949
m_heightAboveGround = 0.0f;
5050
m_lockDist = 0.0f;
5151
m_maxHeightAboveGround = 0.0f;
52-
m_maxZoom = 0.0f;
5352
m_minHeightAboveGround = 0.0f;
54-
m_minZoom = 0.0f;
5553
m_next = NULL;
5654
m_okToAdjustHeight = TRUE;
5755
m_originX = 0;
@@ -99,9 +97,7 @@ void View::init( void )
9997
m_cameraLockDrawable = NULL;
10098
m_zoomLimited = TRUE;
10199

102-
m_maxZoom = 1.3f;
103-
m_minZoom = 0.2f;
104-
m_zoom = m_maxZoom;
100+
m_zoom = 1.0f;
105101
m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight;
106102
m_minHeightAboveGround = TheGlobalData->m_minCameraHeight;
107103
m_okToAdjustHeight = FALSE;

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,15 +1781,13 @@ void W3DView::setHeightAboveGround(Real z)
17811781

17821782
//-------------------------------------------------------------------------------------------------
17831783
//-------------------------------------------------------------------------------------------------
1784+
// TheSuperHackers @bugfix xezon 18/09/2025 setZoom is no longer clamped by a min and max zoom.
1785+
// Instead the min and max camera height will be clamped elsewhere. Clamping the zoom would cause
1786+
// issues with camera playback in replay playback where changes in terrain elevation would not raise
1787+
// the camera height.
17841788
void W3DView::setZoom(Real z)
17851789
{
1786-
m_zoom = z;
1787-
1788-
if (m_zoom < m_minZoom)
1789-
m_zoom = m_minZoom;
1790-
1791-
if (m_zoom > m_maxZoom)
1792-
m_zoom = m_maxZoom;
1790+
View::setZoom(z);
17931791

17941792
m_doingMoveCameraOnWaypointPath = false;
17951793
m_doingRotateCamera = false;

GeneralsMD/Code/GameEngine/Include/GameClient/View.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,11 @@ class View : public Snapshot
184184
virtual const Coord3D& get3DCameraPosition() const = 0; ///< Returns the actual camera position
185185

186186
virtual Real getZoom() { return m_zoom; }
187-
virtual void setZoom(Real z) { }
187+
virtual void setZoom(Real z) { m_zoom = z; }
188188
virtual Real getHeightAboveGround() { return m_heightAboveGround; }
189189
virtual void setHeightAboveGround(Real z);
190190
virtual void zoom( Real height ); ///< Zoom in/out, closer to the ground, limit to min, or farther away from the ground, limit to max
191191
virtual void setZoomToDefault( void ) { m_zoom = 1.0f; } ///< Set zoom to default value
192-
virtual Real getMaxZoom( void ) { return m_maxZoom; } ///< return max zoom value
193192
virtual void setOkToAdjustHeight( Bool val ) { m_okToAdjustHeight = val; } ///< Set this to adjust camera height
194193

195194
// for debugging
@@ -267,8 +266,6 @@ class View : public Snapshot
267266
Real m_angle; ///< Angle at which view has been rotated about the Z axis
268267
Real m_pitchAngle; ///< Rotation of view direction around horizontal (X) axis
269268

270-
Real m_maxZoom; ///< Largest zoom value (minimum actual zoom)
271-
Real m_minZoom; ///< Smallest zoom value (maximum actual zoom)
272269
Real m_maxHeightAboveGround; ///< Highest camera above ground value
273270
Real m_minHeightAboveGround; ///< Lowest camera above ground value
274271
Real m_zoom; ///< Current zoom value

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5517,7 +5517,9 @@ void InGameUI::updateAndDrawWorldAnimations( void )
55175517
UnsignedInt height = wad->m_anim->getCurrentFrameHeight();
55185518

55195519
// scale the width and height given the camera zoom level
5520-
Real zoomScale = TheTacticalView->getMaxZoom() / TheTacticalView->getZoom();
5520+
// TheSuperHackers @todo Rework this with sane values. scaler=1.3 originally came from TheTacticalView::getMaxZoom()
5521+
constexpr Real scaler = 1.3f;
5522+
Real zoomScale = scaler / TheTacticalView->getZoom();
55215523
width *= zoomScale;
55225524
height *= zoomScale;
55235525

GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ View::View( void )
4949
m_heightAboveGround = 0.0f;
5050
m_lockDist = 0.0f;
5151
m_maxHeightAboveGround = 0.0f;
52-
m_maxZoom = 0.0f;
5352
m_minHeightAboveGround = 0.0f;
54-
m_minZoom = 0.0f;
5553
m_next = NULL;
5654
m_okToAdjustHeight = TRUE;
5755
m_originX = 0;
@@ -99,9 +97,7 @@ void View::init( void )
9997
m_cameraLockDrawable = NULL;
10098
m_zoomLimited = TRUE;
10199

102-
m_maxZoom = 1.3f;
103-
m_minZoom = 0.2f;
104-
m_zoom = m_maxZoom;
100+
m_zoom = 1.0f;
105101
m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight;
106102
m_minHeightAboveGround = TheGlobalData->m_minCameraHeight;
107103
m_okToAdjustHeight = FALSE;

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,15 +1944,13 @@ void W3DView::setHeightAboveGround(Real z)
19441944

19451945
//-------------------------------------------------------------------------------------------------
19461946
//-------------------------------------------------------------------------------------------------
1947+
// TheSuperHackers @bugfix xezon 18/09/2025 setZoom is no longer clamped by a min and max zoom.
1948+
// Instead the min and max camera height will be clamped elsewhere. Clamping the zoom would cause
1949+
// issues with camera playback in replay playback where changes in terrain elevation would not raise
1950+
// the camera height.
19471951
void W3DView::setZoom(Real z)
19481952
{
1949-
m_zoom = z;
1950-
1951-
if (m_zoom < m_minZoom)
1952-
m_zoom = m_minZoom;
1953-
1954-
if (m_zoom > m_maxZoom)
1955-
m_zoom = m_maxZoom;
1953+
View::setZoom(z);
19561954

19571955
m_doingMoveCameraOnWaypointPath = false;
19581956
m_CameraArrivedAtWaypointOnPathFlag = false;

0 commit comments

Comments
 (0)