▣
module · drop-in viewer
What it does
vheight
The shape of Amagiri, as one function.
VH.height(x, z) is the authority on where the ground is. The rendered
terrain mesh and the physics heightfield are two samplings of that same
function, so what you see and what you stand on are the same surface by
construction rather than by agreement.
local VH = require("valley.vheight")
local y = VH.height(12.0, -40.0) -- world Y of the ground there
local d, py = VH.nearestOnPath(x, z) -- distance to the cliff path, and its height
local e, handle = VH.buildGround(root, material)
What the function is made of
Read in order, each term laid over the last:
- the drowned floor at
Game.FLOOD_FLOOR, with only a little relief — the water surface fades out where the column it crosses is very short, so a floor that wanders breaks the flood into plates of bare ground; - the south shelf rising out of the flats to the landing;
- the north massif, measured from the flood floor — a massif based at zero takes the maximum against the drowned half of the valley and lifts the whole floor to exactly water level;
- a shallow basin under the flood, so the water has a depth to read through;
- rock relief, scaled by how far above the water a place already is;
- the rim — walls of last resort, so the valley is closed by slope rather than by an invisible plane at the edge of the map;
- the places that have to be exactly where
Game.ANCHORSsays they are; - the cliff path, cut in last so it always wins over the rock it crosses.
The grid
193 vertices over 236 metres — a 1.23 m cell, fine enough for a seven-metre
cliff ledge to read as a ledge. Collision is a HeightfieldCollider over the
same grid: one cell lookup per test rather than a walk down a triangle tree,
which is what makes a valley this size collide for nothing.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.