VoxelTerrainView

The march of a voxel (heightmap) terrain, with no drawing: for each screen column, a ray steps front to back over the map, and wherever the terrain rises above what the column already shows it adds a span. Spans in a column never overlap, run upward from the view's bottom with increasing depth, and same-coloured neighbours merge.

Steps double every bandSteps steps; each band samples the mip level whose cells are about as far apart as its samples (the coarser of the gap between columns and the step), which keeps far terrain from flickering. Map positions are 16.16 fixed point. See specs/2026-11-21-voxel-terrain-spike.md.

Properties

  • columns (integer) — Columns across the view
  • bandSteps (integer) — Steps in each depth band
  • fogColor (integer) — RGB colour far terrain blends towards (-1 for none), from fogStart (a fraction of the
  • fogStart (float)
  • columnSpans (dynamic) — Per column, its spans from the last march: top, height, RGBA colour and the depth (world
  • columnTops (dynamic) — Per column, each place its top rose: depth (world units) then the new top, repeated, in
  • columnWidth (float) — Width of each column in pixels
  • viewHeight (float) — Height of the level view last marched
  • spanCount (integer) — Spans and depth steps in the last march
  • stepCount (integer)

Constructor

new VoxelTerrainView(map: BGE.VoxelMap): VoxelTerrainView

Parameters


Instance Methods

getMap(): BGE.VoxelMap

The map being marched.

Returns

setMap(map: BGE.VoxelMap): void

Swaps the map; the next march rebuilds everything that depends on it.

Parameters

Returns

  • void

occluderTopAt(column: integer, depth: float): float

The top of the last span in a column that starts nearer than depth: everything in the column from there down hides what's at that depth. The view's height if none does.

Parameters

  • column (integer)
  • depth (float) — world units along the view direction

Returns

  • float

march(pose: BGE.VoxelTerrainPose): void

Marches every column for a pose, replacing columnSpans.

Parameters

Returns

  • void

getBandLevels(): Array.<integer>

The band levels of the last march, for tests and the demo's readout.

Returns

  • Array.<integer>