Skip to content

Commit b7fcf9f

Browse files
authored
bugfix(view): Prevent overshooting camera zooming or pivoting on low frame rates (#2588)
1 parent a48131d commit b7fcf9f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • Core/GameEngineDevice/Source/W3DDevice/GameClient

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Bool W3DView::zoomCameraToDesiredHeight()
429429
if (fabs(adjustZoom) >= 0.001f)
430430
{
431431
const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio();
432-
const Real adjustFactor = TheGlobalData->m_cameraAdjustSpeed * fpsRatio;
432+
const Real adjustFactor = std::min(TheGlobalData->m_cameraAdjustSpeed * fpsRatio, 1.0f);
433433
m_zoom += adjustZoom * adjustFactor;
434434
return true;
435435
}
@@ -441,12 +441,12 @@ Bool W3DView::zoomCameraToDesiredHeight()
441441
// This is essential to correctly center the camera above the ground when playing.
442442
Bool W3DView::movePivotToGround()
443443
{
444-
const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio();
445-
const Real adjustFactor = TheGlobalData->m_cameraAdjustSpeed * fpsRatio;
446444
const Real groundLevel = m_groundLevel;
447445
const Real groundLevelDiff = m_terrainHeightAtPivot - groundLevel;
448446
if (fabs(groundLevelDiff) > 0.1f)
449447
{
448+
const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio();
449+
const Real adjustFactor = std::min(TheGlobalData->m_cameraAdjustSpeed * fpsRatio, 1.0f);
450450
// Adjust the ground level. This will change the world height of the camera.
451451
m_groundLevel += groundLevelDiff * adjustFactor;
452452

0 commit comments

Comments
 (0)