HPC_Voxel_Engine 0.2.0
High-Performance C++ Voxel Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Chunk Class Reference

Manages voxel block data, procedural mesh generation, and memory-aligned thermal diffusion buffers. More...

#include <src/world/Chunk.h>

Collaboration diagram for Chunk:
Collaboration graph

Public Member Functions

 Chunk ()=delete
 
 Chunk (int iX, int iZ)
 
 ~Chunk ()
 
 Chunk (const Chunk &)=delete
 
Chunkoperator= (const Chunk &)=delete
 
 Chunk (Chunk &&other) noexcept
 
Chunkoperator= (Chunk &&other) noexcept
 
int GetChunkX () const
 
int GetChunkZ () const
 
bool IsValid () const
 
const uint8_t * GetBlockData () const
 
AABB GetAABB () const
 Generates the AABB for the entire chunk based on max height.
 
void Render () const
 
void SetNeighbours (Direction iDir, Chunk *pChunk)
 
int GetFlatIndexOf3DLayer (int iX, int iY, int iZ) const
 
int GetPaddedIndexOf3DLayer (int iX, int iY, int iZ) const
 
__m256i GetFlatIndexOf3DLayer_AVX2 (__m256i vecX, __m256i vecY, __m256i vecZ) const
 
uint8_t GetBlockAt (int iX, int iY, int iZ) const
 Gets a block ID. Handles boundary checks by querying neighbors.
 
void SetBlockAt (int iX, int iY, int iZ, uint8_t uiBlockType)
 
void SetBlockData (const uint8_t *iBlocks)
 
float GetTemperatureAt (int iX, int iY, int iZ) const
 
void ReconstructMesh (bool bEnableNeighborCulling=false)
 
void UploadMesh ()
 
void SwapBuffers ()
 
void InjectHeat (int iX, int iY, int iZ, float fTemp)
 
void ThermalStep (float fThermalDiffusivity, float fDeltaTime)
 
void ThermalStep_AVX2 (float fThermalDiffusivity, float fDeltaTime)
 
float * GetCurrData () const
 
void UpdateThermalTexture ()
 
void Bind (int iVal)
 
void GetMeshStats (size_t &uiOutVertCount, size_t &uiOutTriCount) const
 

Private Member Functions

void updateHeightData ()
 
void updateBuffers ()
 
void addBlockFace (int iX, int iY, int iZ, FaceDirection iDir, int iBlockType)
 

Private Attributes

std::vector< float > m_vec_fVertices
 
std::vector< unsigned int > m_vec_uiIndices
 
size_t m_uiVertexCount = 0
 
size_t m_uiTriangleCount = 0
 
Renderer::VertexArraym_pVAO = nullptr
 
Renderer::VertexBufferm_pVBO = nullptr
 
Renderer::IndexBufferm_pIBO = nullptr
 
Chunkm_pNeighbours [6] = {nullptr}
 
float * m_pfCurrFrameData = nullptr
 
float * m_pfNextFrameData = nullptr
 
std::unique_ptr< Renderer::ThermalVolumem_pThermalTex
 
FastNoiseLite noise {}
 
int m_iHeightData [CHUNK_SIZE][CHUNK_SIZE]
 
int m_iChunkX = 0
 
int m_iChunkZ = 0
 
uint8_t m_iBlocks [CHUNK_VOL] {0}
 
bool m_bVonNeumannBC = true
 

Detailed Description

Manages voxel block data, procedural mesh generation, and memory-aligned thermal diffusion buffers.

Constructor & Destructor Documentation

◆ Chunk() [1/4]

Chunk::Chunk ( )
delete

◆ Chunk() [2/4]

Chunk::Chunk ( int  iX,
int  iZ 
)
Here is the call graph for this function:

◆ ~Chunk()

Chunk::~Chunk ( )
Here is the call graph for this function:

◆ Chunk() [3/4]

Chunk::Chunk ( const Chunk )
delete

◆ Chunk() [4/4]

Chunk::Chunk ( Chunk &&  other)
noexcept

Member Function Documentation

◆ addBlockFace()

void Chunk::addBlockFace ( int  iX,
int  iY,
int  iZ,
FaceDirection  iDir,
int  iBlockType 
)
private
Here is the caller graph for this function:

◆ Bind()

void Chunk::Bind ( int  iVal)
inline

◆ GetAABB()

AABB Chunk::GetAABB ( ) const

Generates the AABB for the entire chunk based on max height.

◆ GetBlockAt()

uint8_t Chunk::GetBlockAt ( int  iX,
int  iY,
int  iZ 
) const
inline

Gets a block ID. Handles boundary checks by querying neighbors.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlockData()

const uint8_t * Chunk::GetBlockData ( ) const
inline
Here is the caller graph for this function:

◆ GetChunkX()

int Chunk::GetChunkX ( ) const
inline
Here is the caller graph for this function:

◆ GetChunkZ()

int Chunk::GetChunkZ ( ) const
inline
Here is the caller graph for this function:

◆ GetCurrData()

float * Chunk::GetCurrData ( ) const
inline

◆ GetFlatIndexOf3DLayer()

int Chunk::GetFlatIndexOf3DLayer ( int  iX,
int  iY,
int  iZ 
) const
inline
Here is the caller graph for this function:

◆ GetFlatIndexOf3DLayer_AVX2()

__m256i Chunk::GetFlatIndexOf3DLayer_AVX2 ( __m256i  vecX,
__m256i  vecY,
__m256i  vecZ 
) const
inline

◆ GetMeshStats()

void Chunk::GetMeshStats ( size_t &  uiOutVertCount,
size_t &  uiOutTriCount 
) const
inline

◆ GetPaddedIndexOf3DLayer()

int Chunk::GetPaddedIndexOf3DLayer ( int  iX,
int  iY,
int  iZ 
) const
inline
Here is the caller graph for this function:

◆ GetTemperatureAt()

float Chunk::GetTemperatureAt ( int  iX,
int  iY,
int  iZ 
) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InjectHeat()

void Chunk::InjectHeat ( int  iX,
int  iY,
int  iZ,
float  fTemp 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValid()

bool Chunk::IsValid ( ) const
inline

◆ operator=() [1/2]

Chunk & Chunk::operator= ( Chunk &&  other)
noexcept

◆ operator=() [2/2]

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

◆ ReconstructMesh()

void Chunk::ReconstructMesh ( bool  bEnableNeighborCulling = false)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Render()

void Chunk::Render ( ) const
Here is the call graph for this function:

◆ SetBlockAt()

void Chunk::SetBlockAt ( int  iX,
int  iY,
int  iZ,
uint8_t  uiBlockType 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBlockData()

void Chunk::SetBlockData ( const uint8_t *  iBlocks)
inline
Here is the caller graph for this function:

◆ SetNeighbours()

void Chunk::SetNeighbours ( Direction  iDir,
Chunk pChunk 
)
inline
Here is the caller graph for this function:

◆ SwapBuffers()

void Chunk::SwapBuffers ( )
inline

◆ ThermalStep()

void Chunk::ThermalStep ( float  fThermalDiffusivity,
float  fDeltaTime 
)
Here is the call graph for this function:

◆ ThermalStep_AVX2()

void Chunk::ThermalStep_AVX2 ( float  fThermalDiffusivity,
float  fDeltaTime 
)
Here is the call graph for this function:

◆ updateBuffers()

void Chunk::updateBuffers ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateHeightData()

void Chunk::updateHeightData ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateThermalTexture()

void Chunk::UpdateThermalTexture ( )
Here is the call graph for this function:

◆ UploadMesh()

void Chunk::UploadMesh ( )
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_bVonNeumannBC

bool Chunk::m_bVonNeumannBC = true
private

◆ m_iBlocks

uint8_t Chunk::m_iBlocks[CHUNK_VOL] {0}
private

◆ m_iChunkX

int Chunk::m_iChunkX = 0
private

◆ m_iChunkZ

int Chunk::m_iChunkZ = 0
private

◆ m_iHeightData

int Chunk::m_iHeightData[CHUNK_SIZE][CHUNK_SIZE]
private

◆ m_pfCurrFrameData

float* Chunk::m_pfCurrFrameData = nullptr
private

◆ m_pfNextFrameData

float* Chunk::m_pfNextFrameData = nullptr
private

◆ m_pIBO

Renderer::IndexBuffer* Chunk::m_pIBO = nullptr
private

◆ m_pNeighbours

Chunk* Chunk::m_pNeighbours[6] = {nullptr}
private

◆ m_pThermalTex

std::unique_ptr<Renderer::ThermalVolume> Chunk::m_pThermalTex
private

◆ m_pVAO

Renderer::VertexArray* Chunk::m_pVAO = nullptr
private

◆ m_pVBO

Renderer::VertexBuffer* Chunk::m_pVBO = nullptr
private

◆ m_uiTriangleCount

size_t Chunk::m_uiTriangleCount = 0
private

◆ m_uiVertexCount

size_t Chunk::m_uiVertexCount = 0
private

◆ m_vec_fVertices

std::vector<float> Chunk::m_vec_fVertices
private

◆ m_vec_uiIndices

std::vector<unsigned int> Chunk::m_vec_uiIndices
private

◆ noise

FastNoiseLite Chunk::noise {}
private

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