@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
34 lines (33 loc) • 1.62 kB
TypeScript
import { SparseVoxelGrid } from './sparse-voxel-grid';
/**
* Two-level BFS on a sparse voxel grid.
*
* Exploits the fact that most blocks in the blocked grid are BLOCK_EMPTY (all
* 64 voxels free). When BFS reaches such a block, ALL voxels are reachable
* (mutually face-connected within the 4x4x4 cube), so we mark the entire
* block as visited and propagate at block granularity -- 64x fewer operations.
*
* Two queues:
* Block queue -- processes BLOCK_EMPTY (in blocked) blocks at block level
* Voxel queue -- processes individual voxels in BLOCK_MIXED blocks
*
* When the voxel BFS enters a BLOCK_EMPTY block it switches to block fill.
* When block fill hits a BLOCK_MIXED neighbor it enqueues free face voxels.
*
* @param blocked - Sparse voxel grid marking blocked voxels.
* @param blockSeeds - Block indices to seed block-level BFS from.
* @param voxelSeeds - Voxel coordinates to seed voxel-level BFS from.
* @param nx - Grid dimension X in voxels.
* @param ny - Grid dimension Y in voxels.
* @param nz - Grid dimension Z in voxels.
* @param onBlockFilled - Optional progress callback receiving the running
* count of whole-block fills. Throttled internally so callers can wire it
* directly to a progress bar without worrying about per-block overhead.
* @returns Sparse voxel grid marking all reachable voxels.
*/
declare function twoLevelBFS(blocked: SparseVoxelGrid, blockSeeds: number[], voxelSeeds: {
ix: number;
iy: number;
iz: number;
}[], nx: number, ny: number, nz: number, onBlockFilled?: (count: number) => void): SparseVoxelGrid;
export { twoLevelBFS };