/////////////////////////////////////////////////////////////////////
| 2020 | |
| 2021 | ////////////////////////////////////////////////////////////////////////// |
| 2022 | void CLevelSystem::UnLoadLevel() |
| 2023 | { |
| 2024 | if (gEnv->IsEditor()) |
| 2025 | return; |
| 2026 | if (!m_pLoadingLevelInfo) |
| 2027 | return; |
| 2028 | |
| 2029 | CryLog("UnLoadLevel Start"); |
| 2030 | INDENT_LOG_DURING_SCOPE(); |
| 2031 | |
| 2032 | CTimeValue tBegin = gEnv->pTimer->GetAsyncTime(); |
| 2033 | |
| 2034 | // One last update to execute pending requests. |
| 2035 | // Do this before the EntitySystem resets! |
| 2036 | if (gEnv->pFlowSystem) |
| 2037 | { |
| 2038 | gEnv->pFlowSystem->Update(); |
| 2039 | } |
| 2040 | |
| 2041 | I3DEngine* p3DEngine = gEnv->p3DEngine; |
| 2042 | if (p3DEngine) |
| 2043 | { |
| 2044 | IDeferredPhysicsEventManager* pPhysEventManager = p3DEngine->GetDeferredPhysicsEventManager(); |
| 2045 | if (pPhysEventManager) |
| 2046 | { |
| 2047 | // clear deferred physics queues before renderer, since we could have jobs running |
| 2048 | // which access a rendermesh |
| 2049 | pPhysEventManager->ClearDeferredEvents(); |
| 2050 | } |
| 2051 | } |
| 2052 | |
| 2053 | //AM: Flush render thread (Flush is not exposed - using EndFrame()) |
| 2054 | //We are about to delete resources that could be in use |
| 2055 | if (gEnv->pRenderer) |
| 2056 | { |
| 2057 | gEnv->pRenderer->EndFrame(); |
| 2058 | |
| 2059 | // force a black screen as last render command |
| 2060 | gEnv->pRenderer->BeginFrame(); |
| 2061 | gEnv->pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST); |
| 2062 | gEnv->pRenderer->Draw2dImage(0, 0, 800, 600, -1, 0.0f, 0.0f, 1.0f, 1.0f, 0.f, |
| 2063 | 0.0f, 0.0f, 0.0f, 1.0, 0.f); |
| 2064 | gEnv->pRenderer->EndFrame(); |
| 2065 | |
| 2066 | //flush any outstanding texture requests |
| 2067 | gEnv->pRenderer->FlushPendingTextureTasks(); |
| 2068 | } |
| 2069 | |
| 2070 | // Disable filecaching during level unloading |
| 2071 | // will be reenabled when we get back to the IIS (frontend directly) |
| 2072 | // or after level loading is finished (via system event system) |
| 2073 | gEnv->pSystem->GetPlatformOS()->AllowOpticalDriveUsage(false); |
| 2074 | |
| 2075 | if (gEnv->pScriptSystem) |
| 2076 | { |
| 2077 | gEnv->pScriptSystem->ResetTimers(); |
| 2078 | } |
| 2079 |
no test coverage detected