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) |
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).
|
inline |
Gets the current valid size.
|
inline |
Gets the voxel at the specified index.
Assumes isInside(index) to be true.
| index | index of the voxel to edit. |
|
inline |
Tests if the specified index is inside the size of the data structure.
| index | index to test. |
|
inline |
Tests if the specified index-parts are inside the size of the data structure.
| x | x-index to test. |
| y | y-index to test. |
| z | z-index to test. |
|
inline |
Does a raycast into the voxel structure.
std::nullopt on no hit, else index of hit voxel.
|
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.
| new_size | the new size to set the volume to. |
|
inline |
Edits the voxel at the specified index.
Assumes isInside(index) to be true.
| index | index of the voxel to edit. |
| data | data to set the voxel to. |
|
inline |
Edits the voxel at the specified index.
Assumes isInside(ivec3(x,y,z)) to be true.
| x | x-index of the voxel to edit. |
| y | y-index of the voxel to edit. |
| z | z-index of the voxel to edit. |
| data | data to set the voxel to. |