Terrain · function

terrainHeightTolerance

The most a decoded height can differ from the one encoded.

Explained in Terrain.

function terrainHeightTolerance(layer: TerrainHeightLayer): number
import { terrainHeightTolerance } from '@driftengine/terrain';

Parameters

ParameterTypeDescription
layerTerrainHeightLayer

In depth

Half a quantisation step plus one float32 step of the range, and the second term is not padding. The normalised value is stored in the latent as a float32, so the code is exact but code / 65535 is not — and the decode multiplies that representation error back up by the whole range. Written as half a step alone, this function is wrong by about a part in a thousand, which is exactly enough for a tolerance assertion to fail on a field somebody did not choose carefully: measured 4.6372e-5 against a half-step of 4.6314e-5 over a range of six metres.

Stated as a function of the layer rather than as a constant, since it is the field's own range that sets both terms.