Moondog, day 24 (13 Nov): rivers, twelve woods, and 15.4 million trees

61 commits. The generated land got rivers, a forest of new species, and then every tree it will ever need, plus the first undergrowth plants.

Rivers

Rivers come out of the world generator as reaches, each with a surface height, width and current, plus waterfalls. On the server they slot in after lakes and before the sea, so swimming, fishing, creatures and boats all find river water without special cases. A swimmer or a rowed boat is carried by the current. Rapids (1.4 m/s or more) and waterfalls stop boats. Ships drift with the current too: my test knarr went 6.7 m in 10 s.

The client draws reaches within 3 km as ribbons of water with ripples running downstream at the current's speed, white where it's fast. Waterfalls get a curtain, and there's a burble near flowing water and a roar near falls.

Two fixes once it was live:

  • A wide river's water at a point was taken from the highest nearby stretch, so swimmers floated a metre too high. Now it uses the nearest stretch.
  • The current was measured over 8 m steps and flickered between slack and quick. Now it's averaged over at least 40 m.

Lakes that a river passes through are split into the pieces that are really their own water.

Twelve new woods

Willow, alder, poplar, swamp cypress, ash, larch, juniper, holly, wild cherry, rowan, hawthorn and hazel. Each one has a log carrying its real figures (where data was missing I picked stand-ins; hazel's density came from a 2025 paper), a wood lore, and five grown tree forms with their own leaf card: weeping and pollard willows, ash with keys and dieback, berried holly and rowan, and a wild cherry in full spring blossom as a sixth form. The first billboard sheet filled up, so the new species draw from a second sheet, and then a third.

Trees on the land

Trees on the generated land aren't entities. They're tile instances, planted by a script according to country, height, slope and water. The client draws far billboards per tile and full models within 90 m. When you first chop a tree, it becomes an ordinary world entity, gets felled by the existing code, and goes through stump, sapling and young tree over a week before the tile tree returns. A young tree gives one log and is a stump again.

A few things to get right first:

  • Billboards and full models now swap exactly, one instance at a time, so a tree is never drawn as both or neither. Felling one tree touches only that tree; nothing gets rebuilt.
  • Rowan, hawthorn, hazel and wild cherry were imported before their sheet existed and showed up as tall oaks. They now take their sheet from their own material.
  • Static entities go to each client only within 2 km of it. Otherwise every felled tree would grow one world-wide list forever.

After a 73,000-tree test area worked, I planted the whole generated land: 43,392 tiles, 15.4 million trees. The first run kept every tile in memory for the preview picture and ran my PC out of memory.

The snow line moved too. It was set for the home island at about 90 m, which put snow on everything above 95 m on the new land. It now sits at 1,000 m, with painted alpine snow above.

Undergrowth

Each plant is drawn into a card and stood up as clumps by its own script, like the trees: meadow grass, yarrow, chamomile, foxglove, St John's wort, comfrey, poppy, ox-eye daisy, common reed, bulrush, soft rush, bracken, male fern, bramble, elder and blackthorn. Then they went onto the land. The client grows them in 32 m squares around the camera from each spot's paint, slope, trees and water. It's the same plants every time and never stored.

The first version loaded about forty plant models at once on the main thread. That froze the game long enough that the server thought the client was gone, and it reconnected. They load in the background now.

Measuring stalls honestly

The server's pacing report showed the last tick, not the worst one in the window, so a long step earlier read as zero and stalls got blamed on the host. It now keeps the worst, and logs every gap over 150 ms as it happens, along with what filled it. The first catch: arriving in the planted area paused the server for 0.42 s, mostly from setting up 2,226 tree trunks. That's tomorrow's job.