| 1241 | #endif // __EMSCRIPTEN__ |
| 1242 | |
| 1243 | void RunFrame() |
| 1244 | { |
| 1245 | PROFILED_FUNCTION(); |
| 1246 | |
| 1247 | const auto deltaTime = _timer.GetElapsedTimeAndRestart().count(); |
| 1248 | |
| 1249 | // Make sure we catch the state change and reset it. |
| 1250 | bool useVariableFrame = ShouldRunVariableFrame(); |
| 1251 | if (_variableFrame != useVariableFrame) |
| 1252 | { |
| 1253 | _variableFrame = useVariableFrame; |
| 1254 | |
| 1255 | // Switching from variable to fixed frame requires reseting |
| 1256 | // of entity positions back to end of tick positions |
| 1257 | auto& tweener = EntityTweener::Get(); |
| 1258 | tweener.Restore(); |
| 1259 | tweener.Reset(); |
| 1260 | } |
| 1261 | |
| 1262 | UpdateTimeAccumulators(deltaTime); |
| 1263 | |
| 1264 | Network::Update(); |
| 1265 | |
| 1266 | if (useVariableFrame) |
| 1267 | { |
| 1268 | RunVariableFrame(deltaTime); |
| 1269 | } |
| 1270 | else |
| 1271 | { |
| 1272 | RunFixedFrame(deltaTime); |
| 1273 | } |
| 1274 | |
| 1275 | Network::Flush(); |
| 1276 | } |
| 1277 | |
| 1278 | void UpdateTimeAccumulators(float deltaTime) |
| 1279 | { |