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

a class to save and load chunks from the disk More...

#include <Save.hpp>

Collaboration diagram for Save:
Collaboration graph

Public Member Functions

 Save ()
 
 Save (const std::filesystem::path &path)
 
 ~Save ()
 
void trackChunk (std::shared_ptr< Chunk > chunk)
 add chunk to the list of chunks to save More...
 
void saveRegion (const glm::ivec2 &position)
 Unloads the region and saves it to the disk. More...
 
std::shared_ptr< ChunkgetChunk (const glm::ivec3 &position)
 Tries to load a chunk from the disk. More...
 

Static Public Member Functions

static glm::ivec2 toRegionPos (glm::ivec3 chunkPos3D)
 

Static Public Attributes

static constexpr int REGION_SIZE = 32
 
static const std::filesystem::path SAVE_DIR { "saves" }
 
static const std::filesystem::path DEFAULT_NAME { "myWorld" }
 

Detailed Description

a class to save and load chunks from the disk

Constructor & Destructor Documentation

◆ Save() [1/2]

Save::Save ( )

◆ Save() [2/2]

Save::Save ( const std::filesystem::path &  path)

◆ ~Save()

Save::~Save ( )

Member Function Documentation

◆ getChunk()

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

Tries to load a chunk from the disk.

Parameters
positionposition of the chunk
Return values
nullptrif the chunk is not found
std::shared_ptr<Chunk>if the chunk is found

◆ saveRegion()

void Save::saveRegion ( const glm::ivec2 &  position)

Unloads the region and saves it to the disk.

Warning
You SHOULD NOT have any references left to the chunks in the region, you take the risk of losing any changes made to the chunks as they will be untracked.
Parameters
position

◆ toRegionPos()

glm::ivec2 Save::toRegionPos ( glm::ivec3  chunkPos3D)
static

◆ trackChunk()

void Save::trackChunk ( std::shared_ptr< Chunk chunk)

add chunk to the list of chunks to save

Note
you dont have to call trackChunk for chunks that you got from getChunk
Parameters
chunk

Member Data Documentation

◆ DEFAULT_NAME

const std::filesystem::path Save::DEFAULT_NAME { "myWorld" }
static

◆ REGION_SIZE

constexpr int Save::REGION_SIZE = 32
staticconstexpr

◆ SAVE_DIR

const std::filesystem::path Save::SAVE_DIR { "saves" }
static

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