Module transvoxel::voxel_coordinates[][src]

Expand description

Structs for addressing discrete voxels

“Regular” means: at the lower voxel resolution, defined by the block’s subdivisions. That is, without considering transition faces. Even when introducing a transition face and shifting some low resolution voxels toward inside the block, we still call these voxels “regular”, as nothing changes about them in the algorithm, except their contribution to output vertex positions. The density sampled for them should still be the one at their original unshifted world position.

Regular cells and voxels are addressed by x,y,z indices

Transition cells, on the other hand, can only appear on external faces of the block. For addressing them, we do not use the world global XYZ system: For each of the six faces of the block, a rotated UVW system is defined and used, where UV are coordinates along the face (from an origin also defined by the face), and W is perpendicular to the face (with +W toward the inside of the cube). W is used to address voxels only, as cells faces just need UV to be positionned within the block face.

For cells UV, 1 unit is 1 cell (ex +1U moves to the next cell in the U direction). Voxels UVW (HighResolutionVoxelDelta) start at the UV base of the cell, and 1 unit is half the length of a face. (ex +1U +1V is in the middle of the face)

See [Rotation] for the definitions of UVW for each side of the block.

Structs

HighResolutionVoxelDelta

Index of a high resolution voxel within a transition cell

HighResolutionVoxelIndex

Index of a high resolution voxel within a block

RegularCellIndex

Coordinates of a regular cell within the block. Go from 0 to BLOCK_SIZE - 1

RegularVoxelDelta

XYZ index of a regular voxel relative to the base of a regular cell, or to another regular voxel. 1 unit is 1 cell’s size

RegularVoxelIndex

Index of a regular voxel relative to a block. It can refer to a voxel outside of the block, as we need to reach farther out to compute normals

TransitionCellIndex

Index of a transition cell within a block