110 lines
6.5 KiB
C++
110 lines
6.5 KiB
C++
#pragma once
|
|
#include "OctreeBuilderStatistics.h"
|
|
#include "../Defines.h"
|
|
#include "../../inc/glm/vec3.hpp"
|
|
#include <map>
|
|
#include <string>
|
|
|
|
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<unsigned8>& outPool, unsigned& outPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::vector<unsigned8>& outMaterialPool, unsigned& outMaterialPoolSize,
|
|
std::vector<unsigned8>& outBlockPointerPool, std::vector<unsigned8>& outBlockPool,
|
|
std::map<std::string, std::string>& outAdditionalProperties);
|
|
static bool GetPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache,
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::vector<unsigned8>& outMaterialPool, unsigned& outMaterialPoolSize,
|
|
std::vector<unsigned8>& outBlockPointerPool, std::vector<unsigned8>& outBlockPool,
|
|
std::map<std::string, std::string>& outAdditionalProperties,
|
|
bool verbose = false);
|
|
|
|
static bool GetStandardPool(
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize, std::map<std::string, std::string>& outAdditionalProperties);
|
|
static bool GetStandardPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache,
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize, std::map<std::string, std::string>& outAdditionalProperties, bool verbose = false);
|
|
|
|
static bool GetHierarchicalPool(
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::map<std::string, std::string>& outAdditionalProperties);
|
|
static bool GetHierarchicalPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache,
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::map<std::string, std::string>& outAdditionalProperties,
|
|
bool verbose = false);
|
|
|
|
static bool GetOnlyMaterialPool(
|
|
std::vector<unsigned8>& outGeometryPool, unsigned& outGeometryPoolSize,
|
|
std::vector<unsigned8>& outMaterialPool, unsigned& outMaterialPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::map<std::string, std::string>& outAdditionalProperties);
|
|
static bool GetOnlyMaterialPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache,
|
|
std::vector<unsigned8>& outGeometryPool, unsigned& outGeometryPoolSize,
|
|
std::vector<unsigned8>& outMaterialPool, unsigned& outMaterialPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::map<std::string, std::string>& outAdditionalProperties,
|
|
bool verbose = false);
|
|
|
|
static bool GetUniqueIndexPool(
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::vector<unsigned8>& outBlockPointerPool, std::vector<unsigned8>& outBlockPool,
|
|
std::map<std::string, std::string>& outAdditionalProperties);
|
|
static bool GetUniqueIndexPool(std::string treeType, std::string poolType, unsigned8 maxLevel, std::string filename, bool usePoolCache,
|
|
std::vector<unsigned8>& outPool, unsigned& outPoolSize,
|
|
std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize,
|
|
std::vector<unsigned8>& outBlockPointerPool, std::vector<unsigned8>& outBlockPool,
|
|
std::map<std::string, std::string>& 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<unsigned8>& outPool, unsigned& outPoolSize, bool verbose = false);
|
|
static bool ReadNodePool(BaseTree* tree, std::string poolType, std::string poolFullFilename, std::vector<unsigned8>& outPool, unsigned& outPoolSize, bool verbose = false);
|
|
static bool GetMaterialTexture(BaseTree* tree, std::string treeType, std::vector<unsigned8>& outMaterialTexture, unsigned& outMaterialTextureSize);
|
|
static bool GetBlockPointerPool(BaseTree* tree, std::string treeType, std::vector<unsigned8>& outBlockPointerPool);
|
|
static bool GetBlockPool(BaseTree* tree, std::string treeType, std::vector<unsigned8>& outBlockPool);
|
|
static bool GetAdditionalProperties(BaseTree* tree, std::string treeType, std::string poolType, std::map<std::string, std::string>& 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);
|
|
};
|
|
|