From 8ec377e72f0f91ed2a1b7c72c24ccce00f1f4c71 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 16 Sep 2016 00:40:01 +0200 Subject: [PATCH] Culling: Fix some issues Former-commit-id: cc91c0e8a7f0651743439ce8ac19efacae1aed69 [formerly d7463103fce8210ea8e495a627e5d84e3e4d430b] [formerly 274c2b2c16df1784823027f3f50c6d7024640eee [formerly d5baf025e09e3ef48f5c1db64a07775c75594a8a]] Former-commit-id: 15230bf754acd065e6db4ba8dd79d37f43ba8a02 [formerly 81b85f2234f378de5eed976d4924ce8ccb08296f] Former-commit-id: 3cdd9b2416ada3c6ae9bc8bdc527da83c46e0459 --- SDK/src/NDK/Components/GraphicsComponent.cpp | 4 ++++ SDK/src/NDK/Systems/RenderSystem.cpp | 6 +++++- src/Nazara/Graphics/ForwardRenderQueue.cpp | 18 ++++++++++++++++++ src/Nazara/Graphics/ForwardRenderTechnique.cpp | 5 ----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index a90853d1d..8a8516e16 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -161,7 +161,11 @@ namespace Ndk NazaraUnused(node); // Our view matrix depends on NodeComponent position/rotation + InvalidateBoundingVolume(); InvalidateTransformMatrix(); + + for (VolumeCullingEntry& entry : m_volumeCullingEntries) + entry.listEntry.ForceInvalidation(); //< Force invalidation on movement } /*! diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 7b83ca1af..806a45e8c 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -183,10 +183,14 @@ namespace Ndk graphicsComponent.EnsureBoundingVolumeUpdate(); } - bool forceInvalidation = !m_particleGroups.empty(); //< Always regenerate renderqueue if particle groups are present for now (FIXME) + bool forceInvalidation = false; std::size_t visibilityHash = m_drawableCulling.Cull(camComponent.GetFrustum(), &forceInvalidation); + // Always regenerate renderqueue if particle groups are present for now (FIXME) + if (!m_particleGroups.empty()) + forceInvalidation = true; + if (camComponent.UpdateVisibility(visibilityHash) || m_forceRenderQueueInvalidation || forceInvalidation) { renderQueue->Clear(); diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 2de6b66e4..2ffa45208 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -527,6 +527,24 @@ namespace Nz layers.erase(it++); else { + for (auto& pipelinePair : layer.billboards) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.enabled) + { + for (auto& matIt : pipelinePair.second.materialMap) + { + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; + + billboardVector.clear(); + } + } + + pipelineEntry.enabled = false; + } + for (auto& pipelinePair : layer.basicSprites) { auto& pipelineEntry = pipelinePair.second; diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 959ef2f03..659261bf4 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -469,8 +469,6 @@ namespace Nz Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); } while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -562,8 +560,6 @@ namespace Nz Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -773,7 +769,6 @@ namespace Nz } } } - instances.clear(); } } }