#pragma once #include "OctreeBuilderStatistics.h" #include "../Defines.h" #include "../../inc/glm/vec3.hpp" #include #include class BaseTree; // Singleton wrapper that reads the settings and creates the correct octreebuilder class OctreeLoader { public: static const size_t TEXTURESIZE = 1024; static BaseTree* CreateTree(std::string type, unsigned8 maxLevel); // Reads the settings and verifies that the current file exists. Returns false if usecache is turned off. static bool VerifyCache(); // Verify the cache. Returns true if the cache is valid. static bool VerifyCache(std::string treeType, unsigned8 maxLevel, std::string filename); static BaseTree* ReadCache(); static BaseTree* ReadCache(std::string treeType, unsigned8 maxLevel, std::string filename, bool verbose = false); static void DeleteCache(std::string treeType, unsigned8 maxLevel, std::string filename); static bool WriteCache(BaseTree* tree, std::string treeType, std::string filename, bool verbose); static bool VerifyPool(); static bool VerifyPool(std::string treeType, unsigned8 maxLevel, std::string filename); static bool GetPool( std::vector& outPool, unsigned& outPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::vector& outMaterialPool, unsigned& outMaterialPoolSize, std::vector& outBlockPointerPool, std::vector& outBlockPool, std::map& outAdditionalProperties); static bool GetPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache, std::vector& outPool, unsigned& outPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::vector& outMaterialPool, unsigned& outMaterialPoolSize, std::vector& outBlockPointerPool, std::vector& outBlockPool, std::map& outAdditionalProperties, bool verbose = false); static bool GetStandardPool( std::vector& outPool, unsigned& outPoolSize, std::map& outAdditionalProperties); static bool GetStandardPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache, std::vector& outPool, unsigned& outPoolSize, std::map& outAdditionalProperties, bool verbose = false); static bool GetHierarchicalPool( std::vector& outPool, unsigned& outPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::map& outAdditionalProperties); static bool GetHierarchicalPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache, std::vector& outPool, unsigned& outPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::map& outAdditionalProperties, bool verbose = false); static bool GetOnlyMaterialPool( std::vector& outGeometryPool, unsigned& outGeometryPoolSize, std::vector& outMaterialPool, unsigned& outMaterialPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::map& outAdditionalProperties); static bool GetOnlyMaterialPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache, std::vector& outGeometryPool, unsigned& outGeometryPoolSize, std::vector& outMaterialPool, unsigned& outMaterialPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::map& outAdditionalProperties, bool verbose = false); static bool GetUniqueIndexPool( std::vector& outPool, unsigned& outPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::vector& outBlockPointerPool, std::vector& outBlockPool, std::map& outAdditionalProperties); static bool GetUniqueIndexPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache, std::vector& outPool, unsigned& outPoolSize, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize, std::vector& outBlockPointerPool, std::vector& outBlockPool, std::map& outAdditionalProperties, bool verbose = false); // Returns the GPU memory requirements in bytes for the current settings (returns 0 if no tree is found) static size_t GetGPUMemoryRequirements(); static size_t GetGPUMemoryRequirements(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename); static size_t GetGPUMemoryRequirements(std::string treeType, std::string poolType, BaseTree* tree); static size_t GetMainTreeGPUMemoryRequirements(); static size_t GetMainTreeGPUMemoryRequirements(std::string treeType, std::string poolType, BaseTree* tree); static std::string GetFullFilename(); static std::string GetFullFilename(std::string treeType, unsigned8 maxLevel, std::string filename); private: static bool BuildNodePool(BaseTree* tree, std::string poolType, std::string poolFullFilename, std::vector& outPool, unsigned& outPoolSize, bool verbose = false); static bool ReadNodePool(BaseTree* tree, std::string poolType, std::string poolFullFilename, std::vector& outPool, unsigned& outPoolSize, bool verbose = false); static bool GetMaterialTexture(BaseTree* tree, std::string treeType, std::vector& outMaterialTexture, unsigned& outMaterialTextureSize); static bool GetBlockPointerPool(BaseTree* tree, std::string treeType, std::vector& outBlockPointerPool); static bool GetBlockPool(BaseTree* tree, std::string treeType, std::vector& outBlockPool); static bool GetAdditionalProperties(BaseTree* tree, std::string treeType, std::string poolType, std::map& outAdditionalProperties); static bool HasMaterialTexture(BaseTree* treeType); static bool HasBlockTexture(BaseTree* treeType); static bool HasAdditionalProperties(BaseTree* treeType); static size_t CeilToTextureSize(size_t size); static void PrintGPUMemoryRequirements(std::string treeType, std::string poolType, unsigned8 maxLevel, BaseTree* tree); static void PrintGPUMemoryRequirements(size_t poolSize, size_t materialTextureSize, size_t blockPoolSize, size_t blockPointerPoolSize); };