|
49 | 49 | #include "mesh.h" |
50 | 50 | #include "matinfo.h" |
51 | 51 |
|
| 52 | +#include "Common/GameEngine.h" |
52 | 53 | #include "Common/GameState.h" |
53 | 54 | #include "Common/GlobalData.h" |
54 | 55 | #include "Common/PerfTimer.h" |
@@ -984,7 +985,7 @@ void WaterRenderObjClass::load(void) |
984 | 985 | Int WaterRenderObjClass::init(Real waterLevel, Real dx, Real dy, SceneClass *parentScene, WaterType type) |
985 | 986 | { |
986 | 987 |
|
987 | | - m_iBumpFrame=0; |
| 988 | + m_fBumpFrame=0; |
988 | 989 | m_fBumpScale=SEA_BUMP_SCALE; |
989 | 990 |
|
990 | 991 | m_dx=dx; |
@@ -1204,38 +1205,35 @@ void WaterRenderObjClass::enableWaterGrid(Bool state) |
1204 | 1205 | } |
1205 | 1206 |
|
1206 | 1207 | // ------------------------------------------------------------------------------------------------ |
1207 | | -/** Update phase for water if we need it. This called once per client frame reguardless |
1208 | | - * of how fast the logic framerate is running */ |
| 1208 | +/** Update phase for water if we need it. */ |
1209 | 1209 | // ------------------------------------------------------------------------------------------------ |
1210 | 1210 | void WaterRenderObjClass::update( void ) |
1211 | 1211 | { |
1212 | | - static UnsignedInt lastLogicFrame = 0; |
1213 | | - UnsignedInt currLogicFrame = 0; |
| 1212 | + // TheSuperHackers @tweak The water movement time step is now decoupled from the render update. |
| 1213 | + const Real timeScale = TheGameEngine->getActualLogicTimeScaleOverFpsRatio(); |
1214 | 1214 |
|
1215 | | - if( TheGameLogic ) |
1216 | | - currLogicFrame = TheGameLogic->getFrame(); |
1217 | | - |
1218 | | - // we only process things if the logic frame has changed |
1219 | | - if( lastLogicFrame != currLogicFrame ) |
1220 | 1215 | { |
| 1216 | + constexpr const Real MagicOffset = 0.0125 * 33 / 5000; ///< the work of top Munkees; do not question it |
1221 | 1217 |
|
1222 | | - m_riverVOrigin += 0.002f; |
1223 | | - m_riverXOffset += (Real)(0.0125*33/5000); |
1224 | | - m_riverYOffset += (Real)(2*0.0125*33/5000); |
1225 | | - if (m_riverXOffset > 1) m_riverXOffset -= 1; |
1226 | | - if (m_riverYOffset > 1) m_riverYOffset -= 1; |
1227 | | - if (m_riverXOffset < -1) m_riverXOffset += 1; |
1228 | | - if (m_riverYOffset < -1) m_riverYOffset += 1; |
1229 | | - m_iBumpFrame++; |
1230 | | - if (m_iBumpFrame >= NUM_BUMP_FRAMES) { |
1231 | | - m_iBumpFrame = 0; |
1232 | | - } |
| 1218 | + m_riverVOrigin += 0.002f * timeScale; |
| 1219 | + m_riverXOffset += (Real)(MagicOffset * timeScale); |
| 1220 | + m_riverYOffset += (Real)(2 * MagicOffset * timeScale); |
| 1221 | + |
| 1222 | + if (m_riverXOffset > 1.0f) |
| 1223 | + m_riverXOffset -= (Int)m_riverXOffset; |
| 1224 | + |
| 1225 | + if (m_riverYOffset > 1.0f) |
| 1226 | + m_riverYOffset -= (Int)m_riverYOffset; |
| 1227 | + |
| 1228 | + m_fBumpFrame += timeScale; |
| 1229 | + if (m_fBumpFrame >= NUM_BUMP_FRAMES) |
| 1230 | + m_fBumpFrame = 0.0f; |
1233 | 1231 |
|
1234 | 1232 | // for vertex animated water we need to update the vector field |
1235 | 1233 | if( m_doWaterGrid && m_meshInMotion == TRUE ) |
1236 | 1234 | { |
1237 | 1235 | const Real PREFERRED_HEIGHT_FUDGE = 1.0f; ///< this is close enough to at rest |
1238 | | - const Real AT_REST_VELOCITY_FUDGE = 1.0f; ///< when we're close enought to at rest height and velocity we will stop |
| 1236 | + const Real AT_REST_VELOCITY_FUDGE = 1.0f; ///< when we're close enough to at rest height and velocity we will stop |
1239 | 1237 | const Real WATER_DAMPENING = 0.93f; ///< use with up force of 15.0 |
1240 | 1238 | Int i, j; |
1241 | 1239 | Int mx = m_gridCellsX+1; |
@@ -1303,9 +1301,6 @@ void WaterRenderObjClass::update( void ) |
1303 | 1301 |
|
1304 | 1302 | } |
1305 | 1303 |
|
1306 | | - // mark the last logic frame we processed on |
1307 | | - lastLogicFrame = currLogicFrame; |
1308 | | - |
1309 | 1304 | } |
1310 | 1305 |
|
1311 | 1306 | } |
@@ -1846,7 +1841,7 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) |
1846 | 1841 | m_pDev->SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); |
1847 | 1842 | m_pDev->SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); |
1848 | 1843 |
|
1849 | | - m_pDev->SetTexture( 0, m_pBumpTexture[m_iBumpFrame]); |
| 1844 | + m_pDev->SetTexture( 0, m_pBumpTexture[(Int)m_fBumpFrame]); |
1850 | 1845 | #ifdef MIPMAP_BUMP_TEXTURE |
1851 | 1846 | m_pDev->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_POINT ); |
1852 | 1847 | m_pDev->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); |
|
0 commit comments