Overte C++ Documentation
VoxelVolume Class Reference

Public Member Functions

bool isInside (const glm::ivec3 &index)
 
bool isInside (const int32_t x, const int32_t y, const int32_t z)
 
void setVoxelAt (const glm::ivec3 &index, VoxelType data)
 
void setVoxelAt (int32_t x, int32_t y, int32_t z, uint8_t data)
 
VoxelType getVoxelAt (const glm::ivec3 &index)
 
void resize (const glm::ivec3 &new_size)
 
const glm::ivec3 & getSize ()
 
std::optional< glm::ivec3 > raycast (glm::vec4 originInVoxel, glm::vec4 farInVoxel)
 

Detailed Description

A data structure storing voxel data.

The structure uses a vector as it's backing structure which holds allocated_size of voxels.

The backing structure only resizes, when a user tries to edit a voxel (inside the valid_size, but outside allocated_size, i.e. editing a VoxelVolume with valid_size=5x5x5,allocated_size=3x3x3 at index=4,4,4 should resize the backing data structure to fit 5x5x5).

Member Function Documentation

◆ getSize()

const glm::ivec3& VoxelVolume::getSize ( )
inline

Gets the current valid size.

Returns
the current valid size.

◆ getVoxelAt()

VoxelType VoxelVolume::getVoxelAt ( const glm::ivec3 &  index)
inline

Gets the voxel at the specified index.

Assumes isInside(index) to be true.

Parameters
indexindex of the voxel to edit.
Returns
data of the voxel.

◆ isInside() [1/2]

bool VoxelVolume::isInside ( const glm::ivec3 &  index)
inline

Tests if the specified index is inside the size of the data structure.

Parameters
indexindex to test.

◆ isInside() [2/2]

bool VoxelVolume::isInside ( const int32_t  x,
const int32_t  y,
const int32_t  z 
)
inline

Tests if the specified index-parts are inside the size of the data structure.

Parameters
xx-index to test.
yy-index to test.
zz-index to test.

◆ raycast()

std::optional<glm::ivec3> VoxelVolume::raycast ( glm::vec4  originInVoxel,
glm::vec4  farInVoxel 
)
inline

Does a raycast into the voxel structure.

Returns
std::nullopt on no hit, else index of hit voxel.

◆ resize()

void VoxelVolume::resize ( const glm::ivec3 &  new_size)
inline

Resizes the volume to the new_size

Note: actual reallocation of the backing structure should happen at the first edit outside of allocated_size.

Parameters
new_sizethe new size to set the volume to.

◆ setVoxelAt() [1/2]

void VoxelVolume::setVoxelAt ( const glm::ivec3 &  index,
VoxelType  data 
)
inline

Edits the voxel at the specified index.

Assumes isInside(index) to be true.

Parameters
indexindex of the voxel to edit.
datadata to set the voxel to.

◆ setVoxelAt() [2/2]

void VoxelVolume::setVoxelAt ( int32_t  x,
int32_t  y,
int32_t  z,
uint8_t  data 
)
inline

Edits the voxel at the specified index.

Assumes isInside(ivec3(x,y,z)) to be true.

Parameters
xx-index of the voxel to edit.
yy-index of the voxel to edit.
zz-index of the voxel to edit.
datadata to set the voxel to.

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