@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
42 lines (41 loc) • 2.24 kB
TypeScript
import type { NavSimplifyResult } from './fill-exterior';
import type { Bounds } from '../data-table';
import type { GpuDilation } from '../gpu';
import { SparseVoxelGrid } from './sparse-voxel-grid';
/**
* Floor-fill via XZ dilate -> per-column upward walk -> XZ dilate -> OR.
*
* Mirrors the shape of `fillExterior` (dilate -> traverse -> dilate -> OR) but
* the traversal is a per-(lx, lz) upward walk through empty space instead of a
* 3D boundary BFS, and the dilations operate only in X and Z.
*
* Steps with `r = ceil(dilation / voxelResolution)`:
* 1. `S_xz = gpuDilate3(S, r, 0)` closes any XZ holes in horizontal
* surfaces smaller than `2 * r`.
* 2. For every (lx, lz), walk `y = 0` upward through `S_xz`. Mark each
* visited empty voxel into `foundEmpty`. Stop on the first solid voxel
* of `S_xz` or at the grid top.
* 3. `dilatedFound = gpuDilate3(foundEmpty, r, 0)` spreads the found
* under-surface volume back out in XZ to cover the kernel halo.
* 4. `output = S | dilatedFound` adds the dilated under-surface region as
* solid on top of the original solids.
*
* Intended to run before `carve`: it seals the under-side of the floor
* (and patches small XZ holes via the dilation), and the carve handles the
* remaining hole plugging via its 3D dilate + capsule BFS.
*
* With `r = 0` the dilations are skipped and the algorithm degrades to
* "fill the under-side of every column up to the first solid", matching the
* original (pre-dilation) `fillFloor` behavior.
*
* @param grid - Voxel grid (linear-keyed) — mutated as the under-surface
* region is OR'd into it. The same grid instance is returned in
* `NavSimplifyResult.grid`.
* @param gridBounds - Axis-aligned bounds of the voxel grid.
* @param voxelResolution - Size of each voxel in world units.
* @param dilation - XZ dilation radius in world units. 0 disables dilation.
* @param gpu - Reusable GPU dilation context. Required when dilation > 0.
* @returns Modified grid with under-surface regions filled.
*/
declare const fillFloor: (grid: SparseVoxelGrid, gridBounds: Bounds, voxelResolution: number, dilation?: number, gpu?: GpuDilation | null) => Promise<NavSimplifyResult>;
export { fillFloor };