Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(w3ddevice): ease a wheel zoom made during a scroll
Olcay Seygan51a1392f0613
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.hindex f621f4164..988227d68 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h@@ -280,6 +280,7 @@ private:Coord2D m_scrollAmount; ///< scroll speedCameraScrollClock m_scrollClock; ///< elapsed render time, also sampled while idleReal m_scrollAmountCutoff; ///< scroll speed at which we do not adjust height+ Real m_scrollWheelHeight; ///< height the wheel asked for during a scroll that the zoom has not eased through yetReal m_groundLevel; ///< height of ground.diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cppindex e9c0dcad4..d95a61266 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp@@ -195,6 +195,7 @@ W3DView::W3DView()m_recalcCamera = false;m_zoomAnchorValid = false;+ m_scrollWheelHeight = 0.0f;} // end W3DView@@ -1525,10 +1526,22 @@ void W3DView::update(void)m_zoom += zoomAdj;recalcCamera = true;}+ m_scrollWheelHeight = 0.0f;+ }+ else if (m_scrollWheelHeight != 0.0f)+ {+ // the wheel still moves the camera while it pans; the terrain under it does not+ Real heightAdj = m_scrollWheelHeight*cameraAdjustSpeed;+ if (fabs(heightAdj) < 0.01f)+ heightAdj = m_scrollWheelHeight;+ m_scrollWheelHeight -= heightAdj;+ m_zoom += heightAdj / m_cameraOffset.z;+ recalcCamera = true;}}else{+ m_scrollWheelHeight = 0.0f;// we're not scrolling; settle toward desired height above groundReal zoomAdj = (m_zoom - desiredZoom)*cameraAdjustSpeed;Real zoomAdjAbs = fabs(zoomAdj);@@ -2218,6 +2231,7 @@ void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)//-------------------------------------------------------------------------------------------------void W3DView::setHeightAboveGround(Real z){+ const Real previousHeightAboveGround = m_heightAboveGround;m_heightAboveGround = z;// if our zoom is limited, we will stay within a predefined distance from the terrain@@ -2232,6 +2246,11 @@ void W3DView::setHeightAboveGround(Real z)} // end if+ // A fast scroll does not settle the zoom on the terrain, so it would not move towards this height+ // either; update() eases the wheel's part of it on its own until the scroll ends.+ if (TheInGameUI->isScrolling())+ m_scrollWheelHeight += m_heightAboveGround - previousHeightAboveGround;+stopDoingScriptedCamera();m_cameraConstraintValid = false; // recalc it.m_recalcCamera = true;