| 5561 | } |
| 5562 | |
| 5563 | void Engine::ClearLoadedLevel() { |
| 5564 | // We want music in menues now, levels have to clear their own sounds. |
| 5565 | sound.ClearTransient(); |
| 5566 | sound.UpdateGameTimestep(game_timer.timestep); |
| 5567 | sound.UpdateGameTimescale(1.0f); |
| 5568 | sound.Update(); |
| 5569 | if (scenegraph_) { |
| 5570 | scenegraph_->Dispose(); |
| 5571 | delete scenegraph_; |
| 5572 | scenegraph_ = NULL; |
| 5573 | } |
| 5574 | Models::Instance()->Dispose(); |
| 5575 | Online::Instance()->ClearIDTranslations(); |
| 5576 | |
| 5577 | asset_manager.Update(); |
| 5578 | asset_manager.DumpLoadWarningData("asset_manager_warnings.xml"); |
| 5579 | ActiveCameras::Get()->SetCameraObject(NULL); |
| 5580 | level_loaded_ = false; |
| 5581 | DebugDraw::Instance()->Dispose(); |
| 5582 | |
| 5583 | if (config["full_level_unload"].toBool()) { |
| 5584 | LOGI << "Unloading all unreferenced assets after clearing level [full_level_unload: true]..." << std::endl; |
| 5585 | size_t pre_count = asset_manager.GetLoadedAssetCount(); |
| 5586 | size_t tex_pre_count = asset_manager.GetAssetTypeCount(TEXTURE_ASSET); |
| 5587 | while (asset_manager.UnloadUnreferenced(0, 0)) { |
| 5588 | } |
| 5589 | Textures::Instance()->DeleteUnusedTextures(); |
| 5590 | LOGI << (pre_count - asset_manager.GetLoadedAssetCount()) << " Assets were unloaded" << std::endl; |
| 5591 | LOGI << (tex_pre_count - asset_manager.GetAssetTypeCount(TEXTURE_ASSET)) << " Texture assets were unloaded" << std::endl; |
| 5592 | } else { |
| 5593 | LOGE << "Skipping post-clear level unload (Increases peak memory usage)[full_level_unload: false]" << std::endl; |
| 5594 | } |
| 5595 | } |
| 5596 | |
| 5597 | void Engine::LoadLevel(Path queued_level) { |
| 5598 | GetAssetManager()->SetLoadWarningMode(false, "", ""); |
nothing calls this directly
no test coverage detected