From 6390da95d39e4c6fb6eae98581e96baac2149555 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 7 Jul 2018 14:35:11 +0200 Subject: [PATCH] Fix previous commit crash --- .../NDK/Components/GraphicsComponent.inl | 2 +- include/Nazara/Graphics/CullingList.hpp | 6 ++--- include/Nazara/Graphics/CullingList.inl | 24 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 8ddd3e223..08dc3c867 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -40,7 +40,7 @@ namespace Ndk m_volumeCullingEntries.emplace_back(); VolumeCullingEntry& entry = m_volumeCullingEntries.back(); entry.cullingListReleaseSlot.Connect(cullingList->OnCullingListRelease, this, &GraphicsComponent::RemoveFromCullingList); - cullingList->RegisterVolumeTest(this, &entry.listEntry); + entry.listEntry = cullingList->RegisterVolumeTest(this); InvalidateBoundingVolume(); } diff --git a/include/Nazara/Graphics/CullingList.hpp b/include/Nazara/Graphics/CullingList.hpp index 85b4ce2f9..af48f2542 100644 --- a/include/Nazara/Graphics/CullingList.hpp +++ b/include/Nazara/Graphics/CullingList.hpp @@ -41,9 +41,9 @@ namespace Nz std::size_t Cull(const Frustumf& frustum, bool* forceInvalidation = nullptr); - void RegisterNoTest(const T* renderable, NoTestEntry* entry); - void RegisterSphereTest(const T* renderable, SphereEntry* entry); - void RegisterVolumeTest(const T* renderable, VolumeEntry* entry); + NoTestEntry RegisterNoTest(const T* renderable); + SphereEntry RegisterSphereTest(const T* renderable); + VolumeEntry RegisterVolumeTest(const T* renderable); CullingList& operator=(const CullingList& renderable) = delete; CullingList& operator=(CullingList&& renderable) = delete; diff --git a/include/Nazara/Graphics/CullingList.inl b/include/Nazara/Graphics/CullingList.inl index 71cb57fe3..5580efd8b 100644 --- a/include/Nazara/Graphics/CullingList.inl +++ b/include/Nazara/Graphics/CullingList.inl @@ -71,26 +71,30 @@ namespace Nz } template - void CullingList::RegisterNoTest(const T* renderable, NoTestEntry* entry) + auto CullingList::RegisterNoTest(const T* renderable) -> NoTestEntry { - *entry = NoTestEntry(this, m_noTestList.size()); - m_noTestList.emplace_back(NoTestVisibilityEntry{entry, renderable, false}); //< Address of entry will be updated when moving + NoTestEntry newEntry(this, m_volumeTestList.size()); + m_noTestList.emplace_back(NoTestVisibilityEntry{&newEntry, renderable, false}); //< Address of entry will be updated when moving + + return newEntry; } template - void CullingList::RegisterSphereTest(const T* renderable, SphereEntry* entry) + auto CullingList::RegisterSphereTest(const T* renderable) -> SphereEntry { - *entry = SphereEntry(this, m_sphereTestList.size()); - m_sphereTestList.emplace_back(SphereVisibilityEntry{Nz::Spheref(), entry, renderable, false}); //< Address of entry will be updated when moving + SphereEntry newEntry(this, m_sphereTestList.size() - 1); + m_sphereTestList.emplace_back(SphereVisibilityEntry{Nz::Spheref(), &newEntry, renderable, false}); //< Address of entry will be updated when moving - return entry; + return newEntry; } template - void CullingList::RegisterVolumeTest(const T* renderable, VolumeEntry* entry) + auto CullingList::RegisterVolumeTest(const T* renderable) -> VolumeEntry { - *entry = VolumeEntry(this, m_volumeTestList.size()); - m_volumeTestList.emplace_back(VolumeVisibilityEntry{Nz::BoundingVolumef(), entry, renderable, false}); //< Address of entry will be updated when moving + VolumeEntry newEntry(this, m_volumeTestList.size()); + m_volumeTestList.emplace_back(VolumeVisibilityEntry{Nz::BoundingVolumef(), &newEntry, renderable, false}); //< Address of entry will be updated when moving + + return newEntry; } // Interface STD