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

#include <World.hpp>

Inheritance diagram for World:
Inheritance graph
Collaboration diagram for World:
Collaboration graph

Classes

class  WorldGenerator
 

Public Member Functions

 World (bool save=false)
 
 ~World ()
 
 World (World &other)=delete
 
 World (World &&other)=delete
 
Worldoperator= (World &other)=delete
 
Worldoperator= (World &&other)=delete
 
std::shared_ptr< ChunkgetChunk (const glm::ivec3 &position)
 Get the Chunk object. More...
 
void insertChunk (const glm::ivec3 &position, std::shared_ptr< Chunk > chunk)
 
void unloadRegion (const glm::ivec2 region_pos)
 Unloads all chunk inside a region, if save is enabled, will save the region in a region file. More...
 
WorldGeneratorgetWorldGenerator ()
 
SavegetSave ()
 

Static Public Member Functions

static glm::vec3 getBlockChunkPosition (const glm::vec3 &position)
 will return the block position relative to the chunk More...
 
static glm::vec3 getChunkPosition (const glm::vec3 &position)
 will return the chunk position containing the block More...
 

Protected Member Functions

 TracyLockableN (std::mutex, m_players_mutex, "Players")
 
 TracyLockableN (std::mutex, m_mobs_mutex, "Mobs")
 
 TracyLockableN (std::mutex, m_chunks_mutex, "Chunks")
 
std::shared_ptr< ChunkgetChunkNoLock (const glm::ivec3 &position)
 Get a chunk ptr without locking the chunks mutex. More...
 
void insertChunkNoLock (const glm::ivec3 &position, std::shared_ptr< Chunk > chunk)
 
std::unordered_set< glm::ivec3 > updateSkyLight (const glm::ivec3 &block_position)
 Update the sky light of the chunk containing the block. More...
 
std::unordered_set< glm::ivec3 > updateBlockLight (const glm::ivec3 &block_position)
 Update the block light of the chunk containing the block. More...
 

Protected Attributes

std::unordered_map< uint64_t, std::shared_ptr< Player > > m_players
 
std::unordered_map< uint64_t, std::shared_ptr< Mob > > m_mobs
 
uint64_t m_mob_id = 0
 
std::unordered_map< glm::ivec3, std::shared_ptr< Chunk > > m_chunks
 
ExecutorAccessor m_executor
 
WorldGenerator m_world_generator
 
std::unique_ptr< Savem_save
 

Constructor & Destructor Documentation

◆ World() [1/3]

World::World ( bool  save = false)

◆ ~World()

World::~World ( )

◆ World() [2/3]

World::World ( World other)
delete

◆ World() [3/3]

World::World ( World &&  other)
delete

Member Function Documentation

◆ getBlockChunkPosition()

glm::vec3 World::getBlockChunkPosition ( const glm::vec3 &  position)
static

will return the block position relative to the chunk

Parameters
positionthe position of the block in the world
Returns
glm::vec3

◆ getChunk()

std::shared_ptr< Chunk > World::getChunk ( const glm::ivec3 &  position)

Get the Chunk object.

Parameters
position
Return values
std::shared_ptr<Chunk>if the chunk exists
nullptrif the chunk does not exist

◆ getChunkNoLock()

std::shared_ptr< Chunk > World::getChunkNoLock ( const glm::ivec3 &  position)
protected

Get a chunk ptr without locking the chunks mutex.

Warning
you MUST lock the chunks mutex before calling this function
Parameters
position
Return values
std::shared_ptr<Chunk>if the chunk exists
nullptrif the chunk does not exist

◆ getChunkPosition()

glm::vec3 World::getChunkPosition ( const glm::vec3 &  position)
static

will return the chunk position containing the block

Parameters
positionthe position of the block in the world
Returns
glm::vec3

◆ getSave()

Save & World::getSave ( )

◆ getWorldGenerator()

World::WorldGenerator & World::getWorldGenerator ( )

◆ insertChunk()

void World::insertChunk ( const glm::ivec3 &  position,
std::shared_ptr< Chunk chunk 
)

◆ insertChunkNoLock()

void World::insertChunkNoLock ( const glm::ivec3 &  position,
std::shared_ptr< Chunk chunk 
)
protected

◆ operator=() [1/2]

World & World::operator= ( World &&  other)
delete

◆ operator=() [2/2]

World & World::operator= ( World other)
delete

◆ TracyLockableN() [1/3]

World::TracyLockableN ( std::mutex  ,
m_chunks_mutex  ,
"Chunks"   
)
mutableprotected

◆ TracyLockableN() [2/3]

World::TracyLockableN ( std::mutex  ,
m_mobs_mutex  ,
"Mobs"   
)
protected

◆ TracyLockableN() [3/3]

World::TracyLockableN ( std::mutex  ,
m_players_mutex  ,
"Players"   
)
protected

◆ unloadRegion()

void World::unloadRegion ( const glm::ivec2  region_pos)

Unloads all chunk inside a region, if save is enabled, will save the region in a region file.

Parameters
region_poscalculated with Save::Region::toRegionPos

◆ updateBlockLight()

std::unordered_set< glm::ivec3 > World::updateBlockLight ( const glm::ivec3 &  block_position)
protected

Update the block light of the chunk containing the block.

Parameters
block_positionthe position of the block in the world
Returns
a set of chunks that have been modified ( and might need remeshing )

◆ updateSkyLight()

std::unordered_set< glm::ivec3 > World::updateSkyLight ( const glm::ivec3 &  block_position)
protected

Update the sky light of the chunk containing the block.

Parameters
block_positionthe position of the block in the world
Returns
a set of chunks that have been modified ( and might need remeshing )

Member Data Documentation

◆ m_chunks

std::unordered_map<glm::ivec3, std::shared_ptr<Chunk> > World::m_chunks
protected

◆ m_executor

ExecutorAccessor World::m_executor
protected

◆ m_mob_id

uint64_t World::m_mob_id = 0
protected

◆ m_mobs

std::unordered_map<uint64_t, std::shared_ptr<Mob> > World::m_mobs
protected

◆ m_players

std::unordered_map<uint64_t, std::shared_ptr<Player> > World::m_players
protected

◆ m_save

std::unique_ptr<Save> World::m_save
protected

◆ m_world_generator

WorldGenerator World::m_world_generator
protected

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