19 template <
class ElementType,
size_t ElementCount, ElementType DefaultValue>
22 using Type = std::array<ElementType, ElementCount>;
41 void SetSection(
const ElementType (& a_Source)[ElementCount],
size_t a_Y);
136 #define ChunkDef_ForEachSection(BlockData, LightData, Callback) \
139 for (size_t Y = 0; Y < cChunkDef::NumSections; ++Y) \
141 const auto Blocks = BlockData.GetSection(Y); \
142 const auto Metas = BlockData.GetMetaSection(Y); \
143 const auto BlockLights = LightData.GetBlockLightSection(Y); \
144 const auto SkyLights = LightData.GetSkyLightSection(Y); \
145 if ((Blocks != nullptr) || (Metas != nullptr) || (BlockLights != nullptr) || (SkyLights != nullptr)) \
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
std::array< ElementType, ElementCount > Type
void SetSection(const ElementType(&a_Source)[ElementCount], size_t a_Y)
Copies the data from the specified flat section array into the internal representation.
Type * GetSection(size_t a_Y) const
Returns a raw pointer to the internal representation of the specified section.
ElementType Get(Vector3i a_Position) const
Gets one value at the given position.
void Assign(const ChunkDataStore< ElementType, ElementCount, DefaultValue > &a_Other)
Copy assign from another ChunkDataStore.
void SetAll(const ElementType(&a_Source)[cChunkDef::NumSections *ElementCount])
Copies the data from the specified flat array into the internal representation.
std::unique_ptr< Type > Store[cChunkDef::NumSections]
Contains all the sections this ChunkDataStore manages.
void Set(Vector3i a_Position, ElementType a_Value)
Sets one value at the given position.
decltype(m_Blocks)::Type BlockArray
void SetAll(const cChunkDef::BlockTypes &a_BlockSource, const cChunkDef::BlockNibbles &a_MetaSource)
MetaArray * GetMetaSection(size_t a_Y) const
static constexpr size_t SectionBlockCount
NIBBLETYPE GetMeta(Vector3i a_Position) const
static constexpr BLOCKTYPE DefaultValue
static constexpr NIBBLETYPE DefaultMetaValue
NIBBLETYPE[SectionMetaCount] SectionMetaType
static constexpr size_t SectionMetaCount
decltype(m_Metas)::Type MetaArray
void Assign(const ChunkBlockData &a_Other)
void SetSection(const SectionType &a_BlockSource, const SectionMetaType &a_MetaSource, size_t a_Y)
BlockArray * GetSection(size_t a_Y) const
void SetMeta(Vector3i a_Position, NIBBLETYPE a_Meta)
BLOCKTYPE GetBlock(Vector3i a_Position) const
void SetBlock(Vector3i a_Position, BLOCKTYPE a_Block)
BLOCKTYPE[SectionBlockCount] SectionType
ChunkDataStore< NIBBLETYPE, SectionMetaCount, DefaultMetaValue > m_Metas
ChunkDataStore< BLOCKTYPE, SectionBlockCount, DefaultValue > m_Blocks
static constexpr NIBBLETYPE DefaultSkyLightValue
void SetAll(const cChunkDef::BlockNibbles &a_BlockLightSource, const cChunkDef::BlockNibbles &a_SkyLightSource)
NIBBLETYPE[SectionLightCount] SectionType
decltype(m_BlockLights)::Type LightArray
LightArray * GetSkyLightSection(size_t a_Y) const
ChunkDataStore< NIBBLETYPE, SectionLightCount, DefaultBlockLightValue > m_BlockLights
void SetSection(const SectionType &a_BlockLightSource, const SectionType &a_SkyLightSource, size_t a_Y)
LightArray * GetBlockLightSection(size_t a_Y) const
NIBBLETYPE GetSkyLight(Vector3i a_Position) const
static constexpr NIBBLETYPE DefaultBlockLightValue
ChunkDataStore< NIBBLETYPE, SectionLightCount, DefaultSkyLightValue > m_SkyLights
NIBBLETYPE GetBlockLight(Vector3i a_Position) const
static constexpr size_t SectionLightCount
void Assign(const ChunkLightData &a_Other)
BLOCKTYPE BlockTypes[NumBlocks]
The type used for block type operations and storage, AXIS_ORDER ordering.
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
static const size_t NumSections
static const int SectionHeight