five-on-it / packages/catalogue/src/region/terrain
packages/catalogue/src/region/terrain
A region's ground as one mesh, from its corners' levels: a vertex every 4 m, its height the tile's four corners blended plus a seeded bump that is nothing on the tile's edges, so along an edge the height depends on that edge's two corners alone and two tiles always meet. Each triangle takes the biome's colour for its height and slope: grass (its darker patches by tile), rock where it is high or steep, snow on the peaks; unless it is painted (a ski run's snow, a volcano's rock, its flow of lava, LAVA_COLOR, between banks of ash). A town's tiles are left out (its own ground covers them, meeting this one's vertices on their edges). Its look (GroundLook) adds the rich ground's tones, the landuse areas' paint and the ponds dug into it (ground.ts); without it the ground is as it always was. The roads are graded in: within a metre of a road's edge the ground is the road's height, a flat bed under it, and beyond, an embankment or a cutting blends back to the land (none under a bridge, which stands over the land as it is; under a tunnel's roof, a cutting with steep walls, the shortest blend, which the roof covers). TerrainSurface.heightAt reads the mesh itself (its triangles, not the blend), so whatever stands on it stands on what collides.