From fd9db1b63910cd1cddfbb966a36bbd749bea8f1f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 25 Aug 2018 22:41:34 +0200 Subject: [PATCH] Graphics/CullingList: Add forceInvalidation parameter --- SDK/src/NDK/Systems/RenderSystem.cpp | 2 +- include/Nazara/Graphics/CullingList.hpp | 2 +- include/Nazara/Graphics/CullingList.inl | 25 ++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 57da4e78a..56c19abfa 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -208,7 +208,7 @@ namespace Ndk if (m_isCullingEnabled) visibilityHash = m_drawableCulling.Cull(camComponent.GetFrustum(), &forceInvalidation); else - visibilityHash = m_drawableCulling.FillWithAllEntries(); + visibilityHash = m_drawableCulling.FillWithAllEntries(&forceInvalidation); // Always regenerate renderqueue if particle groups are present for now (FIXME) if (!m_lights.empty() || !m_particleGroups.empty()) diff --git a/include/Nazara/Graphics/CullingList.hpp b/include/Nazara/Graphics/CullingList.hpp index df8be7d48..edc6e1621 100644 --- a/include/Nazara/Graphics/CullingList.hpp +++ b/include/Nazara/Graphics/CullingList.hpp @@ -41,7 +41,7 @@ namespace Nz std::size_t Cull(const Frustumf& frustum, bool* forceInvalidation = nullptr); - std::size_t FillWithAllEntries(); + std::size_t FillWithAllEntries(bool* forceInvalidation = nullptr); NoTestEntry RegisterNoTest(const T* renderable); SphereEntry RegisterSphereTest(const T* renderable); diff --git a/include/Nazara/Graphics/CullingList.inl b/include/Nazara/Graphics/CullingList.inl index 55aa8e35c..fb278d019 100644 --- a/include/Nazara/Graphics/CullingList.inl +++ b/include/Nazara/Graphics/CullingList.inl @@ -71,29 +71,52 @@ namespace Nz } template - std::size_t CullingList::FillWithAllEntries() + std::size_t CullingList::FillWithAllEntries(bool* forceInvalidation) { m_results.clear(); + bool forcedInvalidation = false; + std::size_t visibleHash = 0U; for (NoTestVisibilityEntry& entry : m_noTestList) { m_results.push_back(entry.renderable); Nz::HashCombine(visibleHash, entry.renderable); + + if (entry.forceInvalidation) + { + forcedInvalidation = true; + entry.forceInvalidation = false; + } } for (SphereVisibilityEntry& entry : m_sphereTestList) { m_results.push_back(entry.renderable); Nz::HashCombine(visibleHash, entry.renderable); + + if (entry.forceInvalidation) + { + forcedInvalidation = true; + entry.forceInvalidation = false; + } } for (VolumeVisibilityEntry& entry : m_volumeTestList) { m_results.push_back(entry.renderable); Nz::HashCombine(visibleHash, entry.renderable); + + if (entry.forceInvalidation) + { + forcedInvalidation = true; + entry.forceInvalidation = false; + } } + if (forceInvalidation) + *forceInvalidation = forcedInvalidation; + return visibleHash; }