Initial commit: Final state of the master project
This commit is contained in:
76
Research/core/OctreeBuilder/PoolBuilderFactory.h
Normal file
76
Research/core/OctreeBuilder/PoolBuilderFactory.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
#include "../../scene/PoolBuilder/StandardPoolBuilder.h"
|
||||
#include "../../scene/PoolBuilder/AdaptivePointerPoolBuilder.h"
|
||||
#include "../../scene/PoolBuilder/OriginalPoolBuilder.h"
|
||||
#include "../../scene/PoolBuilder/VirtualNodePoolBuilder.h"
|
||||
|
||||
enum PoolBuilderType
|
||||
{
|
||||
ORIGINAL, STANDARDPOOL, ADAPTIVELOOKUP1, ADAPTIVEDIRECT1, ADAPTIVELOOKUP2, ADAPTIVEDIRECT2, VIRTUALNODES
|
||||
};
|
||||
|
||||
class PoolBuilderFactory
|
||||
{
|
||||
public:
|
||||
static PoolBuilderType GetType(std::string type)
|
||||
{
|
||||
if (type == "o") return ORIGINAL;
|
||||
if (type == "s") return STANDARDPOOL;
|
||||
if (type == "al" || type.substr(0, 3) == "al2") return ADAPTIVELOOKUP2;
|
||||
if (type == "ad" || type.substr(0, 3) == "ad2") return ADAPTIVEDIRECT2;
|
||||
if (type.substr(0, 3) == "al1") return ADAPTIVELOOKUP1;
|
||||
if (type.substr(0, 3) == "ad1") return ADAPTIVEDIRECT1;
|
||||
if (type == "v") return VIRTUALNODES;
|
||||
return STANDARDPOOL;
|
||||
}
|
||||
|
||||
static BasePoolBuilder<BaseTree>* Create(std::string strType)
|
||||
{
|
||||
PoolBuilderType type = GetType(strType);
|
||||
if (type == ADAPTIVEDIRECT1 || type == ADAPTIVEDIRECT2 || type == ADAPTIVELOOKUP1 || type == ADAPTIVELOOKUP2)
|
||||
{
|
||||
unsigned8 maskSize = (type == ADAPTIVEDIRECT1 || type == ADAPTIVELOOKUP1) ? 1 : 2;
|
||||
bool useLookupTable = type == ADAPTIVELOOKUP1 || type == ADAPTIVELOOKUP2;
|
||||
std::vector<unsigned8> bitSizes = maskSize == 1 ? std::vector<unsigned8> { 1 } : std::vector<unsigned8>{ 1, 2, 3 };
|
||||
if (strType.length() > 3)
|
||||
{
|
||||
unsigned8 requiredNums = (unsigned8)(BitHelper::Exp2(maskSize) - 1);
|
||||
std::string bitSizesStr = strType.substr(3, requiredNums);
|
||||
for (unsigned8 i = 0; i < BitHelper::Exp2(maskSize) - 1; i++)
|
||||
bitSizes[i] = bitSizesStr[i] - '0';
|
||||
}
|
||||
if (maskSize == 1)
|
||||
return new AdaptivePointerPoolBuilder(useLookupTable, 1, bitSizes[0]);
|
||||
else
|
||||
return new AdaptivePointerPoolBuilder(useLookupTable, 2, bitSizes[0], bitSizes[1], bitSizes[2]);
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case ORIGINAL: return new OriginalPoolBuilder(); break;
|
||||
case VIRTUALNODES: return new VirtualNodePoolBuilder(); break;
|
||||
case STANDARDPOOL: default: return new StandardPoolBuilder(); break;
|
||||
}
|
||||
}
|
||||
|
||||
static std::string GetReadableName(std::string strType)
|
||||
{
|
||||
PoolBuilderType type = GetType(strType);
|
||||
switch (type)
|
||||
{
|
||||
case ORIGINAL: return "original";
|
||||
case STANDARDPOOL: return "standard";
|
||||
case ADAPTIVELOOKUP2: return "adaptive \\w lookup table";
|
||||
case ADAPTIVEDIRECT2: return "adaptive \\w direct pointers";
|
||||
case ADAPTIVELOOKUP1: return "adaptive \\w lookup table";
|
||||
case ADAPTIVEDIRECT1: return "adaptive \\w direct pointers";
|
||||
case VIRTUALNODES: return "virtual nodes";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a string that can be used as a regex to match all compressed texture types
|
||||
static std::string GetRegexMatcher()
|
||||
{
|
||||
return std::string("o|s|ad(1[1-4]?|2([1-4][1-4][1-4])?)|al(1[1-4]?|2([1-4][1-4][1-4])?)|v");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user