|
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" |
@@ -961,7 +962,7 @@ void WaterRenderObjClass::load(void) |
961 | 962 | Int WaterRenderObjClass::init(Real waterLevel, Real dx, Real dy, SceneClass *parentScene, WaterType type) |
962 | 963 | { |
963 | 964 |
|
964 | | - m_iBumpFrame=0; |
| 965 | + m_fBumpFrame=0; |
965 | 966 | m_fBumpScale=SEA_BUMP_SCALE; |
966 | 967 |
|
967 | 968 | m_dx=dx; |
@@ -1181,38 +1182,33 @@ void WaterRenderObjClass::enableWaterGrid(Bool state) |
1181 | 1182 | } |
1182 | 1183 |
|
1183 | 1184 | // ------------------------------------------------------------------------------------------------ |
1184 | | -/** Update phase for water if we need it. This called once per client frame reguardless |
1185 | | - * of how fast the logic framerate is running */ |
| 1185 | +/** Update phase for water if we need it. */ |
1186 | 1186 | // ------------------------------------------------------------------------------------------------ |
1187 | 1187 | void WaterRenderObjClass::update( void ) |
1188 | 1188 | { |
1189 | | - static UnsignedInt lastLogicFrame = 0; |
1190 | | - UnsignedInt currLogicFrame = 0; |
| 1189 | + // TheSuperHackers @tweak The water movement time step is now decoupled from the render update. |
| 1190 | + const Real timeScale = TheGameEngine->getActualLogicTimeScaleOverFpsRatio(); |
1191 | 1191 |
|
1192 | | - if( TheGameLogic ) |
1193 | | - currLogicFrame = TheGameLogic->getFrame(); |
1194 | | - |
1195 | | - // we only process things if the logic frame has changed |
1196 | | - if( lastLogicFrame != currLogicFrame ) |
1197 | 1192 | { |
| 1193 | + constexpr const Real MagicOffset = 0.0125f * 33 / 5000; ///< the work of top Munkees; do not question it |
1198 | 1194 |
|
1199 | | - m_riverVOrigin += 0.002f; |
1200 | | - m_riverXOffset += (Real)(0.0125*33/5000); |
1201 | | - m_riverYOffset += (Real)(2*0.0125*33/5000); |
1202 | | - if (m_riverXOffset > 1) m_riverXOffset -= 1; |
1203 | | - if (m_riverYOffset > 1) m_riverYOffset -= 1; |
1204 | | - if (m_riverXOffset < -1) m_riverXOffset += 1; |
1205 | | - if (m_riverYOffset < -1) m_riverYOffset += 1; |
1206 | | - m_iBumpFrame++; |
1207 | | - if (m_iBumpFrame >= NUM_BUMP_FRAMES) { |
1208 | | - m_iBumpFrame = 0; |
1209 | | - } |
| 1195 | + m_riverVOrigin += 0.002f * timeScale; |
| 1196 | + m_riverXOffset += (Real)(MagicOffset * timeScale); |
| 1197 | + m_riverYOffset += (Real)(2 * MagicOffset * timeScale); |
| 1198 | + |
| 1199 | + // This moves offsets towards zero when smaller -1.0 or larger 1.0 |
| 1200 | + m_riverXOffset -= (Int)m_riverXOffset; |
| 1201 | + m_riverYOffset -= (Int)m_riverYOffset; |
| 1202 | + |
| 1203 | + m_fBumpFrame += timeScale; |
| 1204 | + if (m_fBumpFrame >= NUM_BUMP_FRAMES) |
| 1205 | + m_fBumpFrame = 0.0f; |
1210 | 1206 |
|
1211 | 1207 | // for vertex animated water we need to update the vector field |
1212 | 1208 | if( m_doWaterGrid && m_meshInMotion == TRUE ) |
1213 | 1209 | { |
1214 | 1210 | const Real PREFERRED_HEIGHT_FUDGE = 1.0f; ///< this is close enough to at rest |
1215 | | - const Real AT_REST_VELOCITY_FUDGE = 1.0f; ///< when we're close enought to at rest height and velocity we will stop |
| 1211 | + const Real AT_REST_VELOCITY_FUDGE = 1.0f; ///< when we're close enough to at rest height and velocity we will stop |
1216 | 1212 | const Real WATER_DAMPENING = 0.93f; ///< use with up force of 15.0 |
1217 | 1213 | Int i, j; |
1218 | 1214 | Int mx = m_gridCellsX+1; |
@@ -1280,9 +1276,6 @@ void WaterRenderObjClass::update( void ) |
1280 | 1276 |
|
1281 | 1277 | } |
1282 | 1278 |
|
1283 | | - // mark the last logic frame we processed on |
1284 | | - lastLogicFrame = currLogicFrame; |
1285 | | - |
1286 | 1279 | } |
1287 | 1280 |
|
1288 | 1281 | } |
@@ -1823,7 +1816,7 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) |
1823 | 1816 | m_pDev->SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); |
1824 | 1817 | m_pDev->SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); |
1825 | 1818 |
|
1826 | | - m_pDev->SetTexture( 0, m_pBumpTexture[m_iBumpFrame]); |
| 1819 | + m_pDev->SetTexture( 0, m_pBumpTexture[(Int)m_fBumpFrame]); |
1827 | 1820 | #ifdef MIPMAP_BUMP_TEXTURE |
1828 | 1821 | m_pDev->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_POINT ); |
1829 | 1822 | m_pDev->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); |
|
0 commit comments