MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / flushActions

Method flushActions

Source/Engine/Level/Level.cpp:895–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

893}
894
895void LevelImpl::flushActions()
896{
897 // Calculate time budget for the streaming (relative to the game frame rate to scale across different devices)
898 SceneAction::Context context;
899 float targetFps = 60;
900 if (Time::UpdateFPS > ZeroTolerance)
901 targetFps = Time::UpdateFPS;
902 else if (Engine::GetFramesPerSecond() > 0)
903 targetFps = (float)Engine::GetFramesPerSecond();
904 context.TimeBudget = Level::StreamingFrameBudget / targetFps;
905 if (EngineIdleTime > 0.001)
906 context.TimeBudget += (float)(EngineIdleTime * 0.5); // Increase time budget if engine has some idle time for spare
907#if USE_EDITOR
908 // Throttle up in Editor
909 context.TimeBudget *= Editor::IsPlayMode ? 1.2f : 2.0f;
910#endif
911#if BUILD_DEBUG
912 // Throttle up in Debug
913 context.TimeBudget *= 1.2f;
914#endif
915 if (context.TimeBudget <= 0.0f)
916 context.TimeBudget = MAX_float; // Unlimited if 0
917 context.TimeBudget = Math::Max(context.TimeBudget, 0.001f); // Minimum 1ms
918
919 // Runs actions in order
920 ScopeLock lock(_sceneActionsLocker);
921 for (int32 i = 0; i < _sceneActions.Count() && context.TimeBudget >= 0.0; i++)
922 {
923 auto action = _sceneActions[0];
924 Stopwatch time;
925 auto result = action->Do(context);
926 time.Stop();
927 context.TimeBudget -= time.GetTotalSeconds();
928 if (result != SceneResult::Wait)
929 {
930 _sceneActions.RemoveAtKeepOrder(i--);
931 Delete(action);
932 }
933 }
934}
935
936bool LevelImpl::unloadScene(Scene* scene)
937{

Callers

nothing calls this directly

Calls 7

GetFramesPerSecondFunction · 0.85
DeleteFunction · 0.85
RemoveAtKeepOrderMethod · 0.80
MaxFunction · 0.50
CountMethod · 0.45
DoMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected