| 5503 | } |
| 5504 | |
| 5505 | void Engine::LoadLevelData(const Path& level_path) { |
| 5506 | LOGI << "Load Level: \"" << level_path << "\"" << std::endl; |
| 5507 | #if THREADED |
| 5508 | PROFILER_NAME_THREAD(g_profiler_ctx, "Level loading thread"); |
| 5509 | NameCurrentThread("Level loading thread"); |
| 5510 | #endif |
| 5511 | PROFILER_ZONE(g_profiler_ctx, "Loading level"); |
| 5512 | |
| 5513 | LOG_ASSERT(scenegraph_->bullet_world_ == NULL); |
| 5514 | scenegraph_->bullet_world_ = new BulletWorld(); |
| 5515 | scenegraph_->bullet_world_->Init(); |
| 5516 | scenegraph_->bullet_world_->SetGravity(Physics::Instance()->gravity); |
| 5517 | scenegraph_->bullet_world_->CreatePlane(vec3(0.0f, 1.0f, 0.0f), -100.0f); |
| 5518 | |
| 5519 | scenegraph_->abstract_bullet_world_ = new BulletWorld(); |
| 5520 | scenegraph_->abstract_bullet_world_->Init(); |
| 5521 | |
| 5522 | scenegraph_->plant_bullet_world_ = new BulletWorld(); |
| 5523 | scenegraph_->plant_bullet_world_->Init(); |
| 5524 | |
| 5525 | // sound.AttachBulletWorld(scenegraph_->bullet_world_); |
| 5526 | |
| 5527 | AddLoadingText("Loading level..."); |
| 5528 | |
| 5529 | if (LevelLoader::LoadLevel(level_path, *scenegraph_) == false) { |
| 5530 | loading_mutex_.lock(); |
| 5531 | finished_loading_time = (float)SDL_TS_GetTicks(); |
| 5532 | loading_in_progress_ = false; |
| 5533 | waiting_for_input_ = false; |
| 5534 | loading_mutex_.unlock(); |
| 5535 | return; |
| 5536 | } |
| 5537 | |
| 5538 | AddLoadingText("Preloading assets..."); |
| 5539 | |
| 5540 | PreloadAssets(level_path); |
| 5541 | |
| 5542 | // Clear all unused assets, after loading new level. |
| 5543 | while (asset_manager.UnloadUnreferenced(0, 0)) { |
| 5544 | } |
| 5545 | |
| 5546 | loading_mutex_.lock(); |
| 5547 | |
| 5548 | LoadCollisionNormals(scenegraph_); |
| 5549 | |
| 5550 | { |
| 5551 | PROFILER_ZONE(g_profiler_ctx, "UpdateControlledModule"); |
| 5552 | avatar_control_manager.Update(); |
| 5553 | } |
| 5554 | |
| 5555 | finished_loading_time = (float)SDL_TS_GetTicks(); |
| 5556 | loading_in_progress_ = false; |
| 5557 | waiting_for_input_ = true; |
| 5558 | scenegraph_->map_editor->QueueSaveHistoryState(); |
| 5559 | |
| 5560 | loading_mutex_.unlock(); |
| 5561 | } |
| 5562 |
nothing calls this directly
no test coverage detected