MCPcopy Create free account
hub / github.com/Illation/ETEngine / LoadScene

Method LoadScene

Engine/source/EtFramework/SceneGraph/UnifiedScene.cpp:105–175  ·  view source on GitHub ↗

------------------------- UnifiedScene::LoadScene

Source from the content-addressed store, hash-verified

103// UnifiedScene::LoadScene
104//
105void UnifiedScene::LoadScene(core::HashString const assetId)
106{
107 // preparation
108 //-------------
109
110 // notification before beginning the process so systems can prepare (splash screen, loading bar, timer etc)
111 m_EventDispatcher.Notify(E_SceneEvent::SceneSwitch, new SceneEventData(this));
112
113 if (m_CurrentScene != 0u)
114 {
115 UnloadScene();
116 }
117
118 // timer etc
119 core::ContextManager::GetInstance()->SetActiveContext(&m_Context);
120
121 m_PhysicsWorld.Initialize();
122
123 m_CurrentScene = assetId;
124
125 // load scene descriptor and translate into ECS
126 //----------------------------------------------
127 AssetPtr<SceneDescriptor> const sceneDesc = core::ResourceManager::Instance()->GetAssetData<SceneDescriptor>(m_CurrentScene);
128 ET_ASSERT(sceneDesc != nullptr);
129
130 for (EntityDescriptor const& entDesc : sceneDesc->entities)
131 {
132 AddEntity(entDesc, INVALID_ENTITY_ID);
133 }
134
135 // while adding entities all entity links should be resolved, so we can now reset the link resolver
136 EntityLinkResolver::Instance().Clear();
137
138 // render settings
139 if (!(sceneDesc->skybox.IsEmpty()))
140 {
141 m_RenderScene.SetSkyboxMap(sceneDesc->skybox);
142 }
143
144 if (!(sceneDesc->starfield.IsEmpty()))
145 {
146 m_RenderScene.SetStarfield(sceneDesc->starfield);
147 }
148
149 m_ActiveCamera = sceneDesc->activeCamera.id;
150 ET_ASSERT(m_ActiveCamera != INVALID_ENTITY_ID);
151
152 m_RenderScene.SetPostProcessingSettings(sceneDesc->postprocessing);
153
154 // audio settings
155 m_AudioListener = sceneDesc->audioListener.id;
156 if (m_AudioListener != INVALID_ENTITY_ID)
157 {
158 ET_ASSERT(m_Scene.HasComponent<AudioListenerComponent>(m_AudioListener));
159 m_Scene.AddComponents(m_AudioListener, ActiveAudioListenerComponent());
160 }
161
162 // physics settings

Callers 3

OnTickMethod · 0.80
InitInternalMethod · 0.80
RunMethod · 0.80

Calls 12

ToBtVec3Function · 0.85
SetActiveContextMethod · 0.80
IsEmptyMethod · 0.80
SetSkyboxMapMethod · 0.80
SetStarfieldMethod · 0.80
AddComponentsMethod · 0.80
GetWorldMethod · 0.80
StartMethod · 0.80
InitializeMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected