// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_CULLINGLIST_HPP #define NAZARA_CULLINGLIST_HPP #include #include #include #include #include #include #include #include namespace Nz { template class CullingList { public: template class Entry; class NoTestEntry; class SphereEntry; class VolumeEntry; template friend class Entry; friend NoTestEntry; friend SphereEntry; friend VolumeEntry; using ResultContainer = std::vector; CullingList() = default; CullingList(const CullingList& renderable) = delete; CullingList(CullingList&& renderable) = delete; ~CullingList(); std::size_t Cull(const Frustumf& frustum, bool* forceInvalidation = nullptr); 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; // STL API typename ResultContainer::iterator begin(); typename ResultContainer::const_iterator begin() const; typename ResultContainer::const_iterator cbegin() const; typename ResultContainer::const_iterator cend() const; typename ResultContainer::const_reverse_iterator crbegin() const; typename ResultContainer::const_reverse_iterator crend() const; bool empty() const; typename ResultContainer::iterator end(); typename ResultContainer::const_iterator end() const; typename ResultContainer::reverse_iterator rbegin(); typename ResultContainer::const_reverse_iterator rbegin() const; typename ResultContainer::reverse_iterator rend(); typename ResultContainer::const_reverse_iterator rend() const; typename ResultContainer::size_type size() const; NazaraSignal(OnCullingListRelease, CullingList* /*cullingList*/); private: inline void NotifyForceInvalidation(CullTest type, std::size_t index); inline void NotifyMovement(CullTest type, std::size_t index, void* oldPtr, void* newPtr); inline void NotifyRelease(CullTest type, std::size_t index); inline void NotifySphereUpdate(std::size_t index, const Spheref& sphere); inline void NotifyVolumeUpdate(std::size_t index, const BoundingVolumef& boundingVolume); struct NoTestVisibilityEntry { NoTestEntry* entry; const T* renderable; bool forceInvalidation; }; struct SphereVisibilityEntry { Spheref sphere; SphereEntry* entry; const T* renderable; bool forceInvalidation; }; struct VolumeVisibilityEntry { BoundingVolumef volume; VolumeEntry* entry; const T* renderable; bool forceInvalidation; }; std::vector m_noTestList; std::vector m_sphereTestList; std::vector m_volumeTestList; ResultContainer m_results; }; template template class CullingList::Entry { public: Entry(); Entry(const Entry&) = delete; Entry(Entry&& entry); ~Entry(); void ForceInvalidation(); CullingList* GetParent() const; void UpdateIndex(std::size_t index); Entry& operator=(const Entry&) = delete; Entry& operator=(Entry&& entry); protected: Entry(CullingList* parent, std::size_t index); std::size_t m_index; CullingList* m_parent; }; template class CullingList::NoTestEntry : public CullingList::template Entry { friend CullingList; public: NoTestEntry(); private: NoTestEntry(CullingList* parent, std::size_t index); }; template class CullingList::SphereEntry : public CullingList::template Entry { friend CullingList; public: SphereEntry(); void UpdateSphere(const Spheref& sphere); private: SphereEntry(CullingList* parent, std::size_t index); }; template class CullingList::VolumeEntry : public CullingList::template Entry { friend CullingList; public: VolumeEntry(); void UpdateVolume(const BoundingVolumef& sphere); private: VolumeEntry(CullingList* parent, std::size_t index); }; } #include #endif // NAZARA_CULLINGLIST_HPP