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
ChunkManager Class Reference

Orchestrates infinite world generation, active chunk tracking, and multi-threaded data loading. More...

#include <src/world/ChunkManager.h>

Collaboration diagram for ChunkManager:
Collaboration graph

Public Member Functions

 ChunkManager ()=delete
 
 ChunkManager (std::string &strFolderPath)
 
void Update (float fPlayerX, float fPlayerZ)
 Core lifecycle loop. Synchronizes asynchronous chunks and manages the active render radius.
 
void ReloadAllChunks ()
 
void SetBlock (int iWorldX, int iWorldY, int iWorldZ, uint8_t iBlockType)
 Modifies a voxel block and invalidates necessary chunk meshes (including boundaries).
 
void SaveWorld ()
 Persists all active chunks to disk.
 
ChunkGetChunk (int iX, int iZ)
 Retrieves a pointer to a loaded chunk. Returns nullptr if not loaded.
 
const ChunkGetChunk (int iX, int iZ) const
 
std::map< std::pair< int, int >, std::unique_ptr< Chunk > > & GetMutableChunks ()
 
const std::map< std::pair< int, int >, std::unique_ptr< Chunk > > & GetChunks () const
 
void SetActiveThreads (int iCt)
 
int GetActiveThreads ()
 
size_t GetGeneratedVertCount () const
 
size_t GetGeneratedTriaCount () const
 
void AddToUploadedVertCount (size_t iCt)
 
void ResetUploadedVertCount ()
 
size_t GetUploadedVertCount () const
 
void AddToUploadedTriaCount (size_t iCt)
 
void ResetUploadedTriaCount ()
 
size_t GetUploadedTriaCount () const
 
void SetNeighborCulling (bool bNeighborCulling)
 
bool GetNeighborCulling () const
 

Private Member Functions

void enqueueLoadChunk (int iX, int iZ)
 
void updateChunkNeighbours (Chunk *pChunk)
 
void updateGeneratedMeshStats ()
 

Private Attributes

std::map< std::pair< int, int >, std::unique_ptr< Chunk > > m_mapChunks
 
std::set< std::pair< int, int > > m_setPendingCoords
 
std::mutex m_mutexPending
 
RegionManager m_objRegionManager
 
Core::ThreadSafeQueue< Chunkm_objFinishedQueue
 
Core::ThreadPool m_objThreadPool
 
int m_iRenderDistance = 6
 
int m_iLastPlayerChunkX = -999999
 
int m_iLastPlayerChunkZ = -999999
 
int m_iActiveThreads = 4
 
size_t m_iGeneratedVertexCount = 0
 
size_t m_iGeneratedTriangleCount = 0
 
size_t m_iUploadedVertexCount = 0
 
size_t m_iUploadedTriangleCount = 0
 
bool m_bEnableNeighborCulling = true
 

Detailed Description

Orchestrates infinite world generation, active chunk tracking, and multi-threaded data loading.

Constructor & Destructor Documentation

◆ ChunkManager() [1/2]

ChunkManager::ChunkManager ( )
delete

◆ ChunkManager() [2/2]

ChunkManager::ChunkManager ( std::string &  strFolderPath)
inline

Member Function Documentation

◆ AddToUploadedTriaCount()

void ChunkManager::AddToUploadedTriaCount ( size_t  iCt)
inline
Here is the caller graph for this function:

◆ AddToUploadedVertCount()

void ChunkManager::AddToUploadedVertCount ( size_t  iCt)
inline
Here is the caller graph for this function:

◆ enqueueLoadChunk()

void ChunkManager::enqueueLoadChunk ( int  iX,
int  iZ 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetActiveThreads()

int ChunkManager::GetActiveThreads ( )
inline
Here is the caller graph for this function:

◆ GetChunk() [1/2]

Chunk * ChunkManager::GetChunk ( int  iX,
int  iZ 
)

Retrieves a pointer to a loaded chunk. Returns nullptr if not loaded.

Here is the caller graph for this function:

◆ GetChunk() [2/2]

const Chunk * ChunkManager::GetChunk ( int  iX,
int  iZ 
) const

◆ GetChunks()

const std::map< std::pair< int, int >, std::unique_ptr< Chunk > > & ChunkManager::GetChunks ( ) const
inline
Here is the caller graph for this function:

◆ GetGeneratedTriaCount()

size_t ChunkManager::GetGeneratedTriaCount ( ) const
inline
Here is the caller graph for this function:

◆ GetGeneratedVertCount()

size_t ChunkManager::GetGeneratedVertCount ( ) const
inline
Here is the caller graph for this function:

◆ GetMutableChunks()

std::map< std::pair< int, int >, std::unique_ptr< Chunk > > & ChunkManager::GetMutableChunks ( )
inline
Here is the caller graph for this function:

◆ GetNeighborCulling()

bool ChunkManager::GetNeighborCulling ( ) const
inline
Here is the caller graph for this function:

◆ GetUploadedTriaCount()

size_t ChunkManager::GetUploadedTriaCount ( ) const
inline
Here is the caller graph for this function:

◆ GetUploadedVertCount()

size_t ChunkManager::GetUploadedVertCount ( ) const
inline
Here is the caller graph for this function:

◆ ReloadAllChunks()

void ChunkManager::ReloadAllChunks ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetUploadedTriaCount()

void ChunkManager::ResetUploadedTriaCount ( )
inline
Here is the caller graph for this function:

◆ ResetUploadedVertCount()

void ChunkManager::ResetUploadedVertCount ( )
inline
Here is the caller graph for this function:

◆ SaveWorld()

void ChunkManager::SaveWorld ( )

Persists all active chunks to disk.

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

◆ SetActiveThreads()

void ChunkManager::SetActiveThreads ( int  iCt)
inline
Here is the caller graph for this function:

◆ SetBlock()

void ChunkManager::SetBlock ( int  iWorldX,
int  iWorldY,
int  iWorldZ,
uint8_t  iBlockType 
)

Modifies a voxel block and invalidates necessary chunk meshes (including boundaries).

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

◆ SetNeighborCulling()

void ChunkManager::SetNeighborCulling ( bool  bNeighborCulling)
inline
Here is the caller graph for this function:

◆ Update()

void ChunkManager::Update ( float  fPlayerX,
float  fPlayerZ 
)

Core lifecycle loop. Synchronizes asynchronous chunks and manages the active render radius.

Parameters
fPlayerXPlayer world X.
fPlayerZPlayer world Z.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateChunkNeighbours()

void ChunkManager::updateChunkNeighbours ( Chunk pChunk)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGeneratedMeshStats()

void ChunkManager::updateGeneratedMeshStats ( )
private
Here is the caller graph for this function:

Member Data Documentation

◆ m_bEnableNeighborCulling

bool ChunkManager::m_bEnableNeighborCulling = true
private

◆ m_iActiveThreads

int ChunkManager::m_iActiveThreads = 4
private

◆ m_iGeneratedTriangleCount

size_t ChunkManager::m_iGeneratedTriangleCount = 0
private

◆ m_iGeneratedVertexCount

size_t ChunkManager::m_iGeneratedVertexCount = 0
private

◆ m_iLastPlayerChunkX

int ChunkManager::m_iLastPlayerChunkX = -999999
private

◆ m_iLastPlayerChunkZ

int ChunkManager::m_iLastPlayerChunkZ = -999999
private

◆ m_iRenderDistance

int ChunkManager::m_iRenderDistance = 6
private

◆ m_iUploadedTriangleCount

size_t ChunkManager::m_iUploadedTriangleCount = 0
private

◆ m_iUploadedVertexCount

size_t ChunkManager::m_iUploadedVertexCount = 0
private

◆ m_mapChunks

std::map<std::pair<int, int>, std::unique_ptr<Chunk> > ChunkManager::m_mapChunks
private

◆ m_mutexPending

std::mutex ChunkManager::m_mutexPending
private

◆ m_objFinishedQueue

Core::ThreadSafeQueue<Chunk> ChunkManager::m_objFinishedQueue
private

◆ m_objRegionManager

RegionManager ChunkManager::m_objRegionManager
private

◆ m_objThreadPool

Core::ThreadPool ChunkManager::m_objThreadPool
private

◆ m_setPendingCoords

std::set<std::pair<int, int> > ChunkManager::m_setPendingCoords
private

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