FeatherMC/src/world/PalettedContainer.h

35 lines
891 B
C++

#pragma once
#include "Common.h"
#include "Palette.h"
#include <array>
namespace Feather
{
// A container that maps values from a local palette to a
template <typename T, uint MaxSize, uint MaxBits>
struct PalettedContainer
{
//const Palette<T>& globalPalette;
static constexpr size_t NUM_LONGS = Math::CeilDiv(MaxSize * MaxBits, bitsizeof(uint64));
std::array<uint64, NUM_LONGS> data;
// TODO: this could eventually be Palette<BlockState> to avoid double lookup
// Palette of local indexs to indexs in the global palette
IDMapper<int> palette;
uint size = MaxSize;
uint8 bits = MaxBits;
public:
PalettedContainer(uint size, uint8 bits) : size(size), bits(bits), data() {}
inline void SetBits(uint8 nbits) { bits = nbits; }
inline constexpr size_t GetNumLongs() { return NUM_LONGS; }
};
}