Skip to content

Commit b1eac2a

Browse files
authored
bugfix(fps): Fix mouse wheel zoom speed and decouple zoom update from logic step (#1587)
1 parent c8324cb commit b1eac2a

File tree

4 files changed

+18
-26
lines changed
  • GeneralsMD/Code
  • Generals/Code

4 files changed

+18
-26
lines changed

Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,19 +399,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
399399

400400
Int spin = msg->getArgument( 1 )->integer;
401401

402-
// TheSuperHackers @tweak The camera zoom is now decoupled from the render update.
403-
const Real fpsRatio = (Real)BaseFps / TheGameEngine->getUpdateFps();
404-
const Real zoomHeight = (Real)View::ZoomHeightPerSecond * fpsRatio;
405-
406402
if (spin > 0)
407403
{
408404
for ( ; spin > 0; spin--)
409-
TheTacticalView->zoom( -zoomHeight );
405+
TheTacticalView->zoom( -View::ZoomHeightPerSecond );
410406
}
411407
else
412408
{
413409
for ( ;spin < 0; spin++ )
414-
TheTacticalView->zoom( +zoomHeight );
410+
TheTacticalView->zoom( +View::ZoomHeightPerSecond );
415411
}
416412

417413
break;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,34 +1184,34 @@ void W3DView::update(void)
11841184
{
11851185
Real desiredHeight = (m_terrainHeightUnderCamera + m_heightAboveGround);
11861186
Real desiredZoom = desiredHeight / m_cameraOffset.z;
1187+
11871188
if (didScriptedMovement || (TheGameLogic->isInReplayGame() && TheGlobalData->m_useCameraInReplay))
11881189
{
11891190
// if we are in a scripted camera movement, take its height above ground as our desired height.
11901191
m_heightAboveGround = m_currentHeightAboveGround;
11911192
//DEBUG_LOG(("Frame %d: height above ground: %g %g %g %g", TheGameLogic->getFrame(), m_heightAboveGround,
11921193
// m_cameraOffset.z, m_zoom, m_terrainHeightUnderCamera));
11931194
}
1195+
11941196
if (TheInGameUI->isScrolling())
11951197
{
11961198
// if scrolling, only adjust if we're too close or too far
11971199
if (m_scrollAmount.length() < m_scrollAmountCutoff || (m_currentHeightAboveGround < m_minHeightAboveGround) || (TheGlobalData->m_enforceMaxCameraHeight && m_currentHeightAboveGround > m_maxHeightAboveGround))
11981200
{
1199-
Real zoomAdj = (desiredZoom - m_zoom)*TheGlobalData->m_cameraAdjustSpeed;
1200-
if (fabs(zoomAdj) >= 0.0001) // only do positive
1201+
Real zoomAdj = (desiredZoom - m_zoom) * TheGlobalData->m_cameraAdjustSpeed * TheGameEngine->getActualLogicTimeScaleOverFpsRatio();
1202+
if (fabs(zoomAdj) >= 0.0001f) // only do positive
12011203
{
12021204
m_zoom += zoomAdj;
12031205
recalcCamera = true;
12041206
}
12051207
}
12061208
}
1207-
else
1209+
else if (!didScriptedMovement)
12081210
{
12091211
// we're not scrolling; settle toward desired height above ground
1210-
Real zoomAdj = (m_zoom - desiredZoom)*TheGlobalData->m_cameraAdjustSpeed;
1211-
Real zoomAdjAbs = fabs(zoomAdj);
1212-
if (zoomAdjAbs >= 0.0001 && !didScriptedMovement)
1212+
Real zoomAdj = (m_zoom - desiredZoom) * TheGlobalData->m_cameraAdjustSpeed * TheGameEngine->getActualLogicTimeScaleOverFpsRatio();
1213+
if (fabs(zoomAdj) >= 0.0001f)
12131214
{
1214-
//DEBUG_LOG(("W3DView::update() - m_zoom=%g, desiredHeight=%g", m_zoom, desiredZoom));
12151215
m_zoom -= zoomAdj;
12161216
recalcCamera = true;
12171217
}

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,19 +398,15 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
398398

399399
Int spin = msg->getArgument( 1 )->integer;
400400

401-
// TheSuperHackers @tweak The camera zoom is now decoupled from the render update.
402-
const Real fpsRatio = (Real)BaseFps / TheGameEngine->getUpdateFps();
403-
const Real zoomHeight = (Real)View::ZoomHeightPerSecond * fpsRatio;
404-
405401
if (spin > 0)
406402
{
407403
for ( ; spin > 0; spin--)
408-
TheTacticalView->zoom( -zoomHeight );
404+
TheTacticalView->zoom( -View::ZoomHeightPerSecond );
409405
}
410406
else
411407
{
412408
for ( ;spin < 0; spin++ )
413-
TheTacticalView->zoom( +zoomHeight );
409+
TheTacticalView->zoom( +View::ZoomHeightPerSecond );
414410
}
415411

416412
break;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,34 +1333,34 @@ void W3DView::update(void)
13331333
{
13341334
Real desiredHeight = (m_terrainHeightUnderCamera + m_heightAboveGround);
13351335
Real desiredZoom = desiredHeight / m_cameraOffset.z;
1336+
13361337
if (didScriptedMovement || (TheGameLogic->isInReplayGame() && TheGlobalData->m_useCameraInReplay))
13371338
{
13381339
// if we are in a scripted camera movement, take its height above ground as our desired height.
13391340
m_heightAboveGround = m_currentHeightAboveGround;
13401341
//DEBUG_LOG(("Frame %d: height above ground: %g %g %g %g", TheGameLogic->getFrame(), m_heightAboveGround,
13411342
// m_cameraOffset.z, m_zoom, m_terrainHeightUnderCamera));
13421343
}
1344+
13431345
if (TheInGameUI->isScrolling())
13441346
{
13451347
// if scrolling, only adjust if we're too close or too far
13461348
if (m_scrollAmount.length() < m_scrollAmountCutoff || (m_currentHeightAboveGround < m_minHeightAboveGround) || (TheGlobalData->m_enforceMaxCameraHeight && m_currentHeightAboveGround > m_maxHeightAboveGround))
13471349
{
1348-
Real zoomAdj = (desiredZoom - m_zoom)*TheGlobalData->m_cameraAdjustSpeed;
1349-
if (fabs(zoomAdj) >= 0.0001) // only do positive
1350+
Real zoomAdj = (desiredZoom - m_zoom) * TheGlobalData->m_cameraAdjustSpeed * TheGameEngine->getActualLogicTimeScaleOverFpsRatio();
1351+
if (fabs(zoomAdj) >= 0.0001f) // only do positive
13501352
{
13511353
m_zoom += zoomAdj;
13521354
recalcCamera = true;
13531355
}
13541356
}
13551357
}
1356-
else
1358+
else if (!didScriptedMovement)
13571359
{
13581360
// we're not scrolling; settle toward desired height above ground
1359-
Real zoomAdj = (m_zoom - desiredZoom)*TheGlobalData->m_cameraAdjustSpeed;
1360-
Real zoomAdjAbs = fabs(zoomAdj);
1361-
if (zoomAdjAbs >= 0.0001 && !didScriptedMovement)
1361+
Real zoomAdj = (m_zoom - desiredZoom) * TheGlobalData->m_cameraAdjustSpeed * TheGameEngine->getActualLogicTimeScaleOverFpsRatio();
1362+
if (fabs(zoomAdj) >= 0.0001f)
13621363
{
1363-
//DEBUG_LOG(("W3DView::update() - m_zoom=%g, desiredHeight=%g", m_zoom, desiredZoom));
13641364
m_zoom -= zoomAdj;
13651365
recalcCamera = true;
13661366
}

0 commit comments

Comments
 (0)