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
This commit is contained in:
Lynix 2014-03-04 20:21:33 +01:00
parent 2990843f31
commit 5e9201cb22
1 changed files with 8 additions and 4 deletions

View File

@ -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);