VOX
A little voxel engine
Loading...
Searching...
No Matches
Chunk Class Reference

#include <Chunk.hpp>

Collaboration diagram for Chunk:
Collaboration graph

Classes

struct  biomeInfo
 

Public Types

enum class  genLevel : uint16_t { LIGHT , DECORATE , CAVE , EMPTY }
 
enum class  e_biome : uint8_t {
  FOREST , PLAIN , MOUNTAIN , OCEAN ,
  COAST , DESERT , RIVER , NONE
}
 
typedef std::array< BlockInfo::Type, BLOCKS_PER_CHUNKBlockArray
 
typedef std::array< uint8_t, BLOCKS_PER_CHUNKLightArray
 
typedef std::array< uint8_t, CHUNK_X_SIZE *CHUNK_Z_SIZEHeightArray
 
typedef std::array< biomeInfo, CHUNK_X_SIZE *CHUNK_Z_SIZEBiomeArray
 

Public Member Functions

 Chunk (glm::ivec3 position)
 
 Chunk (const glm::ivec3 &position, const BlockArray &blocks, const LightArray &light, const BiomeArray &biome)
 
 Chunk (const ChunkData &data)
 
 Chunk (const Chunk &other)=delete
 
 Chunk (Chunk &&other)=delete
 
Chunkoperator= (const Chunk &other)=delete
 
Chunkoperator= (const Chunk &&other)=delete
 
 ~Chunk ()
 
BlockArraygetBlocks ()
 
const BlockArraygetBlocks () const
 
BlockInfo::Type getBlock (const int &x, const int &y, const int &z) const
 
BlockInfo::Type getBlock (const glm::ivec3 &position) const
 
void setBlock (const int &x, const int &y, const int &z, BlockInfo::Type block)
 
void setBlock (const glm::ivec3 &position, BlockInfo::Type block)
 
void setBlockColumn (const int &x, const int &z, const std::array< BlockInfo::Type, CHUNK_Y_SIZE > &column)
 
void setBlockColumn (const glm::ivec2 &pos, const std::array< BlockInfo::Type, CHUNK_Y_SIZE > &column)
 
LightArraygetLight ()
 
const LightArraygetLight () const
 
uint8_t getLight (const int &x, const int &y, const int &z) const
 
uint8_t getLight (const glm::ivec3 &position) const
 
void setLight (const int &x, const int &y, const int &z, uint8_t light)
 
void setLight (const glm::ivec3 &position, uint8_t light)
 
uint8_t getSkyLight (const int &x, const int &y, const int &z) const
 
uint8_t getSkyLight (const glm::ivec3 &position) const
 
void setSkyLight (const int &x, const int &y, const int &z, uint8_t light)
 
void setSkyLight (const glm::ivec3 &position, uint8_t light)
 
uint8_t getBlockLight (const int &x, const int &y, const int &z) const
 
uint8_t getBlockLight (const glm::ivec3 &position) const
 
void setBlockLight (const int &x, const int &y, const int &z, uint8_t light)
 
void setBlockLight (const glm::ivec3 &position, uint8_t light)
 
BiomeArraygetBiomes ()
 
const BiomeArraygetBiomes () const
 
biomeInfo getBiome (const int &x, const int &z) const
 
biomeInfo getBiome (const glm::ivec2 &position) const
 
void setBiome (const int &x, const int &z, const biomeInfo &biome)
 
void setBiome (const glm::ivec2 &position, const biomeInfo &biome)
 
HeightArraygetHeights ()
 
const HeightArraygetHeights () const
 
uint8_t getHeight (const int &x, const int &z) const
 
uint8_t getHeight (const glm::ivec2 &position) const
 
void setHeight (const int &x, const int &z, uint8_t height)
 
void setHeight (const glm::ivec2 &position, uint8_t height)
 
const glm::ivec3 & getPosition () const
 
void setPosition (const glm::ivec3 &position)
 
const int & x () const
 
const int & y () const
 
const int & z () const
 
uint64_t getMeshID () const
 
void setMeshID (const uint64_t &mesh_id)
 
bool isMeshed () const
 
void setMeshed (bool meshed)
 
int getLoadLevel () const
 
int getHighestLoadLevel () const
 
void setLoadLevel (const int &load_level)
 
genLevel getGenLevel () const
 
void setGenLevel (const genLevel &level)
 

Static Public Member Functions

static int toBiomeIndex (int x, int z)
 
static int toBiomeIndex (const glm::ivec2 &position)
 
static glm::ivec2 toBiomeCoord (int index)
 
static int toHeightIndex (const int &x, const int &z)
 
static int toHeightIndex (const glm::ivec2 &position)
 
static int toIndex (const int &x, const int &y, const int &z)
 
static glm::ivec3 toCoord (const int &index)
 

Public Attributes

Status status
 
std::unordered_set< uint64_t > entity_ids
 
std::unordered_set< uint64_t > observing_player_ids
 

Static Public Attributes

static constexpr size_t DATA_SIZE = sizeof(BlockArray) + sizeof(LightArray) + sizeof(BiomeArray) + sizeof(genLevel)
 

Member Typedef Documentation

◆ BiomeArray

◆ BlockArray

◆ HeightArray

typedef std::array<uint8_t, CHUNK_X_SIZE * CHUNK_Z_SIZE> Chunk::HeightArray

◆ LightArray

typedef std::array<uint8_t, BLOCKS_PER_CHUNK> Chunk::LightArray

Member Enumeration Documentation

◆ e_biome

enum class Chunk::e_biome : uint8_t
strong
Enumerator
FOREST 
PLAIN 
MOUNTAIN 
OCEAN 
COAST 
DESERT 
RIVER 
NONE 

◆ genLevel

enum class Chunk::genLevel : uint16_t
strong
Enumerator
LIGHT 
DECORATE 
CAVE 
EMPTY 

Constructor & Destructor Documentation

◆ Chunk() [1/5]

Chunk::Chunk ( glm::ivec3  position)

◆ Chunk() [2/5]

Chunk::Chunk ( const glm::ivec3 &  position,
const BlockArray blocks,
const LightArray light,
const BiomeArray biome 
)

◆ Chunk() [3/5]

Chunk::Chunk ( const ChunkData data)

◆ Chunk() [4/5]

Chunk::Chunk ( const Chunk other)
delete

◆ Chunk() [5/5]

Chunk::Chunk ( Chunk &&  other)
delete

◆ ~Chunk()

Chunk::~Chunk ( )

Member Function Documentation

◆ getBiome() [1/2]

Chunk::biomeInfo Chunk::getBiome ( const glm::ivec2 &  position) const

◆ getBiome() [2/2]

Chunk::biomeInfo Chunk::getBiome ( const int &  x,
const int &  z 
) const

◆ getBiomes() [1/2]

Chunk::BiomeArray & Chunk::getBiomes ( )

◆ getBiomes() [2/2]

const Chunk::BiomeArray & Chunk::getBiomes ( ) const

◆ getBlock() [1/2]

BlockInfo::Type Chunk::getBlock ( const glm::ivec3 &  position) const

◆ getBlock() [2/2]

BlockInfo::Type Chunk::getBlock ( const int &  x,
const int &  y,
const int &  z 
) const

◆ getBlockLight() [1/2]

uint8_t Chunk::getBlockLight ( const glm::ivec3 &  position) const

◆ getBlockLight() [2/2]

uint8_t Chunk::getBlockLight ( const int &  x,
const int &  y,
const int &  z 
) const

◆ getBlocks() [1/2]

Chunk::BlockArray & Chunk::getBlocks ( )

◆ getBlocks() [2/2]

const Chunk::BlockArray & Chunk::getBlocks ( ) const

◆ getGenLevel()

Chunk::genLevel Chunk::getGenLevel ( ) const

◆ getHeight() [1/2]

uint8_t Chunk::getHeight ( const glm::ivec2 &  position) const

◆ getHeight() [2/2]

uint8_t Chunk::getHeight ( const int &  x,
const int &  z 
) const

◆ getHeights() [1/2]

Chunk::HeightArray & Chunk::getHeights ( )

◆ getHeights() [2/2]

const Chunk::HeightArray & Chunk::getHeights ( ) const

◆ getHighestLoadLevel()

int Chunk::getHighestLoadLevel ( ) const

◆ getLight() [1/4]

Chunk::LightArray & Chunk::getLight ( )

◆ getLight() [2/4]

const Chunk::LightArray & Chunk::getLight ( ) const

◆ getLight() [3/4]

uint8_t Chunk::getLight ( const glm::ivec3 &  position) const

◆ getLight() [4/4]

uint8_t Chunk::getLight ( const int &  x,
const int &  y,
const int &  z 
) const

◆ getLoadLevel()

int Chunk::getLoadLevel ( ) const

◆ getMeshID()

uint64_t Chunk::getMeshID ( ) const

◆ getPosition()

const glm::ivec3 & Chunk::getPosition ( ) const

◆ getSkyLight() [1/2]

uint8_t Chunk::getSkyLight ( const glm::ivec3 &  position) const

◆ getSkyLight() [2/2]

uint8_t Chunk::getSkyLight ( const int &  x,
const int &  y,
const int &  z 
) const

◆ isMeshed()

bool Chunk::isMeshed ( ) const

◆ operator=() [1/2]

Chunk & Chunk::operator= ( const Chunk &&  other)
delete

◆ operator=() [2/2]

Chunk & Chunk::operator= ( const Chunk other)
delete

◆ setBiome() [1/2]

void Chunk::setBiome ( const glm::ivec2 &  position,
const biomeInfo biome 
)

◆ setBiome() [2/2]

void Chunk::setBiome ( const int &  x,
const int &  z,
const biomeInfo biome 
)

◆ setBlock() [1/2]

void Chunk::setBlock ( const glm::ivec3 &  position,
BlockInfo::Type  block 
)

◆ setBlock() [2/2]

void Chunk::setBlock ( const int &  x,
const int &  y,
const int &  z,
BlockInfo::Type  block 
)

◆ setBlockColumn() [1/2]

void Chunk::setBlockColumn ( const glm::ivec2 &  pos,
const std::array< BlockInfo::Type, CHUNK_Y_SIZE > &  column 
)

◆ setBlockColumn() [2/2]

void Chunk::setBlockColumn ( const int &  x,
const int &  z,
const std::array< BlockInfo::Type, CHUNK_Y_SIZE > &  column 
)

◆ setBlockLight() [1/2]

void Chunk::setBlockLight ( const glm::ivec3 &  position,
uint8_t  light 
)

◆ setBlockLight() [2/2]

void Chunk::setBlockLight ( const int &  x,
const int &  y,
const int &  z,
uint8_t  light 
)

◆ setGenLevel()

void Chunk::setGenLevel ( const genLevel level)

◆ setHeight() [1/2]

void Chunk::setHeight ( const glm::ivec2 &  position,
uint8_t  height 
)

◆ setHeight() [2/2]

void Chunk::setHeight ( const int &  x,
const int &  z,
uint8_t  height 
)

◆ setLight() [1/2]

void Chunk::setLight ( const glm::ivec3 &  position,
uint8_t  light 
)

◆ setLight() [2/2]

void Chunk::setLight ( const int &  x,
const int &  y,
const int &  z,
uint8_t  light 
)

◆ setLoadLevel()

void Chunk::setLoadLevel ( const int &  load_level)

◆ setMeshed()

void Chunk::setMeshed ( bool  meshed)

◆ setMeshID()

void Chunk::setMeshID ( const uint64_t &  mesh_id)

◆ setPosition()

void Chunk::setPosition ( const glm::ivec3 &  position)

◆ setSkyLight() [1/2]

void Chunk::setSkyLight ( const glm::ivec3 &  position,
uint8_t  light 
)

◆ setSkyLight() [2/2]

void Chunk::setSkyLight ( const int &  x,
const int &  y,
const int &  z,
uint8_t  light 
)

◆ toBiomeCoord()

glm::ivec2 Chunk::toBiomeCoord ( int  index)
static

◆ toBiomeIndex() [1/2]

int Chunk::toBiomeIndex ( const glm::ivec2 &  position)
static

◆ toBiomeIndex() [2/2]

int Chunk::toBiomeIndex ( int  x,
int  z 
)
static

◆ toCoord()

glm::ivec3 Chunk::toCoord ( const int &  index)
static

◆ toHeightIndex() [1/2]

int Chunk::toHeightIndex ( const glm::ivec2 &  position)
static

◆ toHeightIndex() [2/2]

int Chunk::toHeightIndex ( const int &  x,
const int &  z 
)
static

◆ toIndex()

int Chunk::toIndex ( const int &  x,
const int &  y,
const int &  z 
)
static

◆ x()

const int & Chunk::x ( ) const
inline

◆ y()

const int & Chunk::y ( ) const
inline

◆ z()

const int & Chunk::z ( ) const
inline

Member Data Documentation

◆ DATA_SIZE

constexpr size_t Chunk::DATA_SIZE = sizeof(BlockArray) + sizeof(LightArray) + sizeof(BiomeArray) + sizeof(genLevel)
staticconstexpr

◆ entity_ids

std::unordered_set<uint64_t> Chunk::entity_ids

◆ observing_player_ids

std::unordered_set<uint64_t> Chunk::observing_player_ids

◆ status

Status Chunk::status

The documentation for this class was generated from the following files: