Initial commit: Final state of the master project
This commit is contained in:
50
Research/scene/PoolBuilder/OriginalPoolBuilder.h
Normal file
50
Research/scene/PoolBuilder/OriginalPoolBuilder.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "BaseTreePoolBuilder.h"
|
||||
|
||||
class OriginalPoolBuilder : public BaseTreePoolBuilder
|
||||
{
|
||||
|
||||
public:
|
||||
using BaseTreePoolBuilder::BaseTreePoolBuilder;
|
||||
virtual ~OriginalPoolBuilder() override {}
|
||||
|
||||
std::string GetFullFileName(const std::string& fileName) const override
|
||||
{
|
||||
return fileName + ".o.pool";
|
||||
}
|
||||
protected:
|
||||
void InitBuild(const BaseTree* tree) override {}
|
||||
void FinishBuild(const BaseTree* tree) override {}
|
||||
bool WordAligned() const override { return true; }
|
||||
|
||||
unsigned8 GetBytesPerPointer(const BaseTree* tree, const unsigned32& nodeId) const override
|
||||
{
|
||||
// All pointers are 4 bytes
|
||||
return 4;
|
||||
}
|
||||
std::vector<unsigned8> WrapPointer(const BaseTree* root, const unsigned32& nodeIndex, const unsigned32& indexInPool, const unsigned32& pointer) const override
|
||||
{
|
||||
return BitHelper::SplitInBytes(pointer);
|
||||
}
|
||||
|
||||
size_t GetPoolInfoSize(const BaseTree* tree) const override { return 0; }
|
||||
std::vector<unsigned8> GetPoolInfo(const BaseTree* tree, const std::vector<size_t>& nodePointers, const std::vector<unsigned32>& nodeOrder) override { return std::vector<unsigned8>(); }
|
||||
|
||||
unsigned8 GetAdditionalPoolInfoForNodeSize(const BaseTree* tree, const unsigned32& nodeIndex) const override
|
||||
{
|
||||
const Node* node = tree->GetNode(nodeIndex);
|
||||
unsigned8 level = node->GetLevel();
|
||||
unsigned8 additionalBytes = tree->GetAdditionalBytesPerNode(level);
|
||||
// The original paper uses 32 bit as the atomic unit. Therefore they have 24 unused bits after each childmask. We put these in here for correctness.
|
||||
// However, if they are used to store, for example, color information (i.e., additionalBytes != 0), we use them for that.
|
||||
if (additionalBytes <= 3) return 3 - additionalBytes;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
std::vector<unsigned8> GetAdditionalPoolInfoForNode(const BaseTree* tree, const unsigned32& nodeIndex, const unsigned32& indexInPool) const override
|
||||
{
|
||||
return std::vector<unsigned8>(GetAdditionalPoolInfoForNodeSize(tree, nodeIndex), 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user