From 5e9201cb225cb6b3d63e40e405a0eb387bcd02ab Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Mar 2014 20:21:33 +0100 Subject: [PATCH] Optimized Scenes configuration The scene class no longer create a default background/default rendertechnique at construction, instead it waits for Scene::Cull method and create them if they are invalid Former-commit-id: b5d031abc5d7df4be5ad4edd6036ad7d60cacbb4 --- src/Nazara/Graphics/Scene.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Graphics/Scene.cpp b/src/Nazara/Graphics/Scene.cpp index f61526b68..ad281d102 100644 --- a/src/Nazara/Graphics/Scene.cpp +++ b/src/Nazara/Graphics/Scene.cpp @@ -31,7 +31,7 @@ struct NzSceneImpl NzClock updateClock; NzColor ambientColor = NzColor(25,25,25); NzSceneRoot root; - NzAbstractViewer* viewer; + NzAbstractViewer* viewer = nullptr; bool update; float frameTime; float updateTime; @@ -42,8 +42,6 @@ struct NzSceneImpl NzScene::NzScene() { m_impl = new NzSceneImpl(this); - m_impl->background.reset(new NzColorBackground); - m_impl->renderTechnique.reset(NzRenderTechniques::GetByRanking(-1, &m_impl->renderTechniqueRanking)); } NzScene::~NzScene() @@ -66,13 +64,16 @@ void NzScene::Cull() } #endif + if (!m_impl->renderTechnique) + m_impl->renderTechnique.reset(NzRenderTechniques::GetByRanking(-1, &m_impl->renderTechniqueRanking)); + NzAbstractRenderQueue* renderQueue = m_impl->renderTechnique->GetRenderQueue(); renderQueue->Clear(false); m_impl->visibleUpdateList.clear(); // Frustum culling - RecursiveFrustumCull(m_impl->renderTechnique->GetRenderQueue(), m_impl->viewer->GetFrustum(), &m_impl->root); + RecursiveFrustumCull(renderQueue, m_impl->viewer->GetFrustum(), &m_impl->root); ///TODO: Occlusion culling @@ -91,6 +92,9 @@ void NzScene::Draw() m_impl->viewer->ApplyView(); + if (!m_impl->background) + m_impl->background.reset(new NzColorBackground); + try { NzErrorFlags errFlags(nzErrorFlag_ThrowException);