Skip to content

Commit

Permalink
Fix render system problem when reloading current level (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoomingTechDev authored May 24, 2022
1 parent 4a38fb3 commit 204567e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions engine/source/editor/source/editor_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ namespace Pilot
if (ImGui::MenuItem("Reload Current Level"))
{
g_runtime_global_context.m_world_manager->reloadCurrentLevel();
g_runtime_global_context.m_render_system->clearForLevelReloading();
g_editor_global_context.m_scene_manager->onGObjectSelected(k_invalid_gobject_id);
}
if (ImGui::MenuItem("Save Current Level"))
Expand Down
9 changes: 8 additions & 1 deletion engine/source/runtime/function/render/render_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,14 @@ namespace Pilot

GuidAllocator<GameObjectPartId>& RenderSystem::getGOInstanceIdAllocator() { return m_instance_id_allocator; }

GuidAllocator<MeshSourceDesc>& RenderSystem::getMeshAssetIdAllocator() { return m_mesh_asset_id_allocator; }
GuidAllocator<MeshSourceDesc>& RenderSystem::getMeshAssetIdAllocator() { return m_mesh_asset_id_allocator; }

void RenderSystem::clearForLevelReloading()
{
m_instance_id_allocator.clear();
m_mesh_object_id_map.clear();
m_render_scene->m_render_entities.clear();
}

void RenderSystem::setRenderPipelineType(RENDER_PIPELINE_TYPE pipeline_type)
{
Expand Down
2 changes: 2 additions & 0 deletions engine/source/runtime/function/render/render_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace Pilot
GuidAllocator<GameObjectPartId>& getGOInstanceIdAllocator();
GuidAllocator<MeshSourceDesc>& getMeshAssetIdAllocator();

void clearForLevelReloading();

private:
RENDER_PIPELINE_TYPE m_render_pipeline_type {RENDER_PIPELINE_TYPE::DEFERRED_PIPELINE};

Expand Down

0 comments on commit 204567e

Please sign in to comment.