Skip to content

Commit 68ebaf4

Browse files
Fix
1 parent d1e95b8 commit 68ebaf4

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

Engine/Source/Sandbox/Private/Sandbox/DebugRendering.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@ void Sandbox::DrawEntityGizmos()
2323

2424
const auto& settings = UserSettingsManager::GetSettings().sceneSettings;
2525

26-
if (!settings.showGizmos || !m_runtimeScene || !m_runtimeScene->IsFinishedLoadingEntities())
26+
AssetReference<Volt::Scene> tempScene;
27+
28+
if (m_sceneState == SceneState::Edit)
29+
{
30+
tempScene = m_runtimeScene;
31+
}
32+
else
33+
{
34+
tempScene = m_intermediateScene;
35+
}
36+
37+
if (!settings.showGizmos || !tempScene || !tempScene->IsFinishedLoadingEntities())
2738
{
2839
return;
2940
}
3041

3142
// There will be one gizmo per entity.
32-
const entt::registry& registry = m_runtimeScene->GetEntityScene().GetRegistry();
43+
const entt::registry& registry = tempScene->GetEntityScene().GetRegistry();
3344
auto entityView = registry.view<Volt::IDComponent>();
3445

3546
const uint32_t numEntities = static_cast<uint32_t>(entityView.size());
@@ -41,7 +52,7 @@ void Sandbox::DrawEntityGizmos()
4152
&entityView,
4253
&editorCameraPosition,
4354
&editorCameraViewMatrix,
44-
scene = m_runtimeScene,
55+
scene = tempScene,
4556
&debugRenderer = m_debugRenderer,
4657
&visProxyContextManagersMutex = m_visProxyContextManagersMutex,
4758
&visProxyContextManagers = m_visProxyContextManagers

Engine/Source/Sandbox/Private/Sandbox/Sandbox.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ void Sandbox::OpenScene(Volt::AssetHandle sceneHandle)
517517

518518
SelectionManager::DeselectAll();
519519

520+
UnloadActiveScene();
521+
520522
//load new scene
521523
{
522524
Volt::SceneContainer* newSceneContainer = m_sceneManager->LoadScene(sceneHandle);
@@ -531,11 +533,6 @@ void Sandbox::OpenScene(Volt::AssetHandle sceneHandle)
531533
return;
532534
}
533535

534-
if (m_sceneContainer)
535-
{
536-
m_sceneManager->UnloadAndFreeScene(m_sceneContainer);
537-
}
538-
539536
m_sceneContainer = newSceneContainer;
540537
m_runtimeScene = newSceneContainer->GetScene();
541538
}
@@ -580,6 +577,17 @@ bool Sandbox::SaveScene(bool showDialog, bool allowDiscard)
580577
return DirtyAssetsManager::Get().SaveAssets(showDialog, allowDiscard, filter);
581578
}
582579

580+
void Sandbox::UnloadActiveScene()
581+
{
582+
m_sceneRenderer = nullptr;
583+
m_gameSceneRenderer = nullptr;
584+
585+
if (m_sceneContainer)
586+
{
587+
m_sceneManager->UnloadAndFreeScene(m_sceneContainer);
588+
}
589+
}
590+
583591
void Sandbox::RegisterEventListeners()
584592
{
585593
auto isInitializedPred = [this]() { return m_isInitialized; };
@@ -611,7 +619,6 @@ bool Sandbox::PromptUnloadCurrentScene()
611619
return false;
612620
}
613621

614-
615622
m_runtimeScene->UnloadEntities();
616623
m_runtimeScene.Reset();
617624

Engine/Source/Sandbox/Public/Sandbox/Sandbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Sandbox : public Volt::ApplicationLayer, public Volt::EventListener
9292
void OpenScene(Volt::AssetHandle sceneHandle);
9393
//returns false if user cancels save
9494
bool SaveScene(bool showDialog = false, bool allowDiscard = false);
95+
void UnloadActiveScene();
9596

9697
private:
9798
struct SaveSceneAsData

0 commit comments

Comments
 (0)