class

FVoxelGrid

A solid as a grid of voxels for destruction: voxelized from a mesh or a primitive, carved by spheres, split into what still stands and what fell off, and meshed as its exposed faces.

Module
Destruction
Header
#include "Destruction/VoxelGrid.h"
Namespace
Mowo

Public functions

ReturnsNameDescription
boolInit
FVoxelGridFromTrianglesA closed triangle mesh (local space): every voxel whose centre is inside (parity along +X) or whose box a triangle passes through.
FVoxelGridFromBox
FVoxelGridFromSphere
boolIsValid
uint32_tSizeX
uint32_tSizeY
uint32_tSizeZ
floatCellSize
const Vec3&Origin
uint32_tIndex
boolGet
boolGetIndex
voidSet
voidCoordinates
Vec3VoxelCenter
uint32_tSolidCount
uint32_tCarveRemoves the solid voxels whose centres lie within the sphere (local space); their indices go to removed.
std::vector<FVoxelIsland>DetachIslandsWhatever no longer connects (face to face) to the anchor — the floor layer, or with no floor anchor the largest piece — leaves the grid as islands, largest first.
std::vector<FVoxelIsland>ChunkSplits loose voxels into chunks of chunk voxels a side: the rubble a carve throws out.
TerrainChunkMeshBuildMeshThe exposed faces of every solid voxel (or of an island's voxels alone).
TerrainChunkMeshBuildIslandMesh

Function details

Init

C++
bool Init(const Vec3& origin, float cellSize, uint32_t nx, uint32_t ny, uint32_t nz)

FromTriangles

C++
static FVoxelGrid FromTriangles(const std::vector<Vec3>& vertices, const std::vector<uint32_t>& indices, float cellSize, uint32_t maxDim = 256)

A closed triangle mesh (local space): every voxel whose centre is inside (parity along +X) or whose box a triangle passes through.

FromBox

C++
static FVoxelGrid FromBox(const Vec3& halfExtents, float cellSize)

FromSphere

C++
static FVoxelGrid FromSphere(float radius, float cellSize)

IsValid

C++
bool IsValid() const

SizeX

C++
uint32_t SizeX() const

SizeY

C++
uint32_t SizeY() const

SizeZ

C++
uint32_t SizeZ() const

CellSize

C++
float CellSize() const

Origin

C++
const Vec3& Origin() const

Index

C++
uint32_t Index(uint32_t x, uint32_t y, uint32_t z) const

Get

C++
bool Get(uint32_t x, uint32_t y, uint32_t z) const

GetIndex

C++
bool GetIndex(uint32_t index) const

Set

C++
void Set(uint32_t x, uint32_t y, uint32_t z, bool solid)

Coordinates

C++
void Coordinates(uint32_t index, uint32_t& x, uint32_t& y, uint32_t& z) const

VoxelCenter

C++
Vec3 VoxelCenter(uint32_t index) const

SolidCount

C++
uint32_t SolidCount() const

Carve

C++
uint32_t Carve(const Vec3& center, float radius, std::vector<uint32_t>* removed = nullptr)

Removes the solid voxels whose centres lie within the sphere (local space); their indices go to removed. Returns how many.

DetachIslands

C++
std::vector<FVoxelIsland> DetachIslands(bool anchorFloor)

Whatever no longer connects (face to face) to the anchor — the floor layer, or with no floor anchor the largest piece — leaves the grid as islands, largest first.

Chunk

C++
std::vector<FVoxelIsland> Chunk(const std::vector<uint32_t>& voxels, uint32_t chunk) const

Splits loose voxels into chunks of chunk voxels a side: the rubble a carve throws out.

BuildMesh

C++
TerrainChunkMesh BuildMesh(const Vec4& color) const

The exposed faces of every solid voxel (or of an island's voxels alone).

BuildIslandMesh

C++
TerrainChunkMesh BuildIslandMesh(const FVoxelIsland& island, const Vec3& pivot, const Vec4& color) const
Generated from Destruction/VoxelGrid.h via destruction.json · Oct 26, 2026Version 1.0.0