Skip to content

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.

fix(gameenginedevice): slow the water animation to a swell, not a boil

Olcay Seygan0602bf072262
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h
index 3e11655e4..eccef2079 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWater.h
@@ -170,6 +170,7 @@ protected:
LPDIRECT3DTEXTURE8 m_pBumpTexture[NUM_BUMP_FRAMES]; ///<animation frames
LPDIRECT3DTEXTURE8 m_pBumpTexture2[NUM_BUMP_FRAMES]; ///<animation frames
Int m_iBumpFrame; ///<current animation frame
+ Real m_bumpFrameAccum; ///<fractional carry, so the flipbook can run slower than one frame per tick
Real m_fBumpScale; ///<scales bump map uv perturbation
TextureClass * m_pReflectionTexture; ///<render target for reflection
RenderObjClass *m_skyBox; ///<box around level
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
index 0779e466b..a929e996f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
@@ -376,6 +376,8 @@ WaterRenderObjClass::WaterRenderObjClass(void)
m_waterSparklesTexture=0;
m_riverXOffset=0;
m_riverYOffset=0;
+ m_iBumpFrame=0;
+ m_bumpFrameAccum=0.0f;
}
//-------------------------------------------------------------------------------------------------
@@ -992,6 +994,7 @@ Int WaterRenderObjClass::init(Real waterLevel, Real dx, Real dy, SceneClass *par
{
m_iBumpFrame=0;
+ m_bumpFrameAccum=0.0f;
m_fBumpScale=SEA_BUMP_SCALE;
m_dx=dx;
@@ -1231,16 +1234,30 @@ void WaterRenderObjClass::update( void )
// along at whatever the frame rate happened to be. They belong on the logic clock with
// the rest of this function.
//
- m_riverVOrigin += 0.002f;
- m_riverXOffset += (Real)(0.0125*33/5000);
- m_riverYOffset += (Real)(2*0.0125*33/5000);
+ // EA's step sizes were authored per render frame and read as a boil rather than a swell,
+ // most visibly on the shell map behind the main menu. WATER_ANIM_SPEED scales the whole
+ // animation - scroll and bump cycle alike - so the surface keeps its shape and only its
+ // tempo changes. 1.0f restores the shipped rate.
+ //
+ const Real WATER_ANIM_SPEED = 0.35f;
+
+ m_riverVOrigin += 0.002f * WATER_ANIM_SPEED;
+ m_riverXOffset += (Real)(0.0125*33/5000) * WATER_ANIM_SPEED;
+ m_riverYOffset += (Real)(2*0.0125*33/5000) * WATER_ANIM_SPEED;
if (m_riverXOffset > 1) m_riverXOffset -= 1;
if (m_riverYOffset > 1) m_riverYOffset -= 1;
if (m_riverXOffset < -1) m_riverXOffset += 1;
if (m_riverYOffset < -1) m_riverYOffset += 1;
- m_iBumpFrame++;
- if (m_iBumpFrame >= NUM_BUMP_FRAMES) {
- m_iBumpFrame = 0;
+
+ // the bump texture is a flipbook, so it can only be slowed by holding each frame longer
+ m_bumpFrameAccum += WATER_ANIM_SPEED;
+ while (m_bumpFrameAccum >= 1.0f)
+ {
+ m_bumpFrameAccum -= 1.0f;
+ m_iBumpFrame++;
+ if (m_iBumpFrame >= NUM_BUMP_FRAMES) {
+ m_iBumpFrame = 0;
+ }
}