Skip to content

ocean: no-flux walls, bodies make waves, boats, a drivable boat (O8c, O9, O11b, O11c) - #1194

Merged
transfix merged 44 commits into
masterfrom
feat/ocean-boat
Nov 14, 2026
Merged

transfix merged 44 commits into
masterfrom
feat/ocean-boat

Conversation

@transfix

@transfix transfix commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

The rest of Phases C and D in docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md:

  • eWave walls that reflect a crest as a crest (O8c, Joe's "lets fix this");
  • bodies make waves (O9);
  • boats in cvc::physics (O11b);
  • a drivable boat in lsystem_coast (O11c).

Stacked on #1172 (O10, forces at a point), #1173 (O11a, the hull model), #1174 (O8, eWave) and #1181 (the sea_surface memo out of a thread_local, which replaced #1193). O8c's branch, feat/ocean-ewave-walls, is merged in here rather than opened as its own PR. Until those merge, this diff includes them. Auto-merge goes on once they have landed and master is merged in here.

O8c: no-flux walls, stable (section 6)

O8's walls zeroed the water, so a crest came back as a trough. A real vertical wall is no-flux: a crest returns as a crest, doubled at the wall. Walls are now no-flux by default, and walls = zero keeps the old behaviour bit for bit.

A first design was unstable (the branch history keeps it). It overwrote the wall cells each step with the water's mirror image. A straight wall came out right, but curved, island and thin-wall basins grew without bound: a disc 31× in 20000 steps.

The design that shipped.

  • The operator. The state lives on the water cells, and its vertical velocity is M⁻¹ Rᵀ G̃ R φ:
    • R fills the wall cells with the water's mirror image across the nearest shore;
    • G̃ is the spectral operator;
    • Rᵀ folds the image back with the same weights;
    • M is the lumped mass.
  • Why it is stable. Rᵀ G̃ R is symmetric for any wall shape, so the energy is conserved exactly. The step is Störmer–Verlet in a fixed substep per window (default 1/60 s, capped at the stable limit), and leftover time carries to the next frame. Every substep is the same linear map whatever the frame's dt.
  • Exact dispersion kept. G̃ uses κ̃ = 4 sin²(ω dt/2)/(g dt²), so the substep keeps eWave's exact frequency.
  • Exact where possible. A straight wall with its whole mirror is exact. Windows with no walls keep the exact any-dt step and their pins.

Measured in ocean_ewave_test (18 tests) and cvcgl_ewave:

  • Exact on a straight channel: the operator to 3e-15, the steps to round-off.
  • Stable:
    • 7 closed basins (disc, island, breakwater, 45° channel, thin walls) × 3 step sizes × 20000 steps: the conserved energy stays within 1.3e-14 of its start.
    • Frame-time jitter is now stable. Before the fixed substep, alternating dt resonated, growing 1e188×.
    • An adversarial reviewer's 22 basins at five step sizes found no growth.
  • Reflection: a ring off a straight wall matches the even image to 2.2 % (the first design: 6.8 %), with gain 1.9 and slope +1.001. Zero walls still give the odd image.
  • Thin walls leak no more than zero walls do: 1 cell 40 % against 41 %, 2 cells 27 % against 27 %.
  • Damping is the same with either wall. In a disc 36 m across with damping_k2 2e-3, a ring keeps 75.7 % of its energy after 10 s with no-flux walls and 75.5 % with zero walls (DampingK2TakesTheSameShareWhateverTheWalls).
  • Pins: zero walls a4933455f6946eca, unchanged; no-flux aefff2ae097ed743, measured on Windows MSVC.
  • The GPU matches the CPU to about 1e-5 of the RMS height. A substep is 35 passes at 256².
  • Mask setup is O(n²) (a Felzenszwalb–Huttenlocher distance transform): 11–13 ms at 256².

In lsystem_coast the sea's and the lake's windows now use no-flux walls. The cliffs and the lake's banks reflect crest for crest, and beaches still absorb through their ramp.

  • --wake-check and --boat-check exit 0, with the same boat numbers.
  • GPU time per frame is about 3.6 ms at a 1/30 s frame (two substeps), against 1.7 ms before.
  • Fixed: the lake's ring faded too fast. At first the closed lake's ring kept only 20 % of its energy 10 s after the drop, against 55 % with zero walls.
    • The cause was the damping_k2 filter under no-flux walls, h ← M⁻¹RᵀFRh, which is not the identity even with no damping (F = 1). Wherever a ghost's mirror point falls between cells, M⁻¹RᵀR averages the water there with its neighbours. A round lake compresses its banks' image over most of its water, and the smoothing ran 60 times a second.
    • The filter is now h ← h − M⁻¹Rᵀ(1 − F)Rh on the CPU and the GPU. It is unchanged beside a straight wall, still only takes energy, and is exactly the identity at F = 1. In the test's disc the old form kept 49.3 %, and at damping_k2 1e-15 its heights were 99 % off the undamped run's (now 1.5e-13).
    • The lake now keeps 48 % after 10 s and 34 % after 20 s (absorbing banks: 13 % and 1 %).
    • The check reads the water's own Σh², which leaves out the image weighting M (mean 1.31 in such a disc). That reading sits about 0.85 of the energy the walls conserve once the ring reaches the banks, and accounts for the rest of the gap to 55 %. It is a share that moves, not a loss: without damping, the conserved energy stays at 1.000.

O9: bodies make waves (section 6: C2, C3, C4, C6)

  • Shared immersion code. cvc/physics/immersion.h gives a body's columns of immersed depth ζ over a grid, from its box, sphere, convex hull or hull_mesh, its pose and the fluid's surface. It is exact per column, and it is what a client without a physics world (arisrv) computes from a replicated pose.
    • It agrees with the field step's immersed volume: exactly for a level box, and to the cells' resolution elsewhere (worst, a barrel, 2.5–2.9 %).
    • Pinned at b582404bf028ed63, measured on Windows MSVC.
  • Sources. WakeSource turns each body into dh = −(ζ(t) − ζ(t − dt)), smoothed by a volume-keeping [1 2 1]/4 kernel. The volume holds to 1e-16 m³.
  • The windows in lsystem_coast:
    • The sea: a 256² window at 0.5 m that follows the camera's target by whole cells (EWave::shift, one exact pass). Its mask comes from the shore: beaches absorb over a 3 m ramp, and steep shores reflect.
    • The crater lake: a 128² window with reflecting banks.
    • Drawing: the wake height in the vertex shader (tent-filtered), its slope in the fragment normal, and foam from its curvature and speed.
  • Evidence.
    • cvcgl_wake: a box footprint moved across still water through the immersion code and the GPU window leaves a wake whose edges read 19.43–20.02° at 2.5 m/s and 19.34–19.79° at 3.0 m/s (Kelvin is 19.47°). A rock casts a shadow, 23 % of the open-water height behind it.
    • --wake-check: the lake's ring reflects off its banks. 48 % and 34 % of its energy is left after 10 and 20 s, against 13 % and 1 % with absorbing banks (55 % and 34 % under O9's zero walls; see O8c).

O11b: boats in cvc::physics (section 7, D3)

  • API (cvc/physics/boat.h): world::add_boat / set_boat_controls / boat_state / remove_boat, like vehicles. A boat is a hull body (O11a) with a propeller (thrust falling off with inflow, an optional outboard that vectors it) and a rudder (lift ½ρAC_L(α)v² and drag from the flow at it).
  • Every step. Both act each physics step through O10's force-at-a-point path, only while wet.
  • State. In save() and state_hash() when boats exist; a world without boats keeps every hash.
  • physics_boat_test (10 tests):
    • full throttle reaches the speed where thrust equals the hull's resistance (to 0.02 N);
    • reverse backs the boat; rudder turns shrink the circle (422 m, then 111 m diameter);
    • a propeller out of the water gives no thrust; an outboard turns the boat 11× more than the rudder at low speed;
    • pitch tracks the swell (correlation 0.9998);
    • pinned at bb8e1b22f58136b2.

O11c: a drivable boat in lsystem_coast (section 7, D5 and its exit)

  • The boat. A 5 m skiff: a 378-triangle hull and a convex collision hull, with a propeller and a rudder.
  • Controls. Arrow keys and I/J/K/L drive it, plus a Boat panel with a chase camera; scripts use coast.boat.*. The wake window follows the boat.
  • No water inside the hull (D5). The water shader discards fragments inside the hull's waterline footprint.
  • --boat-check (exit code 6 if the boat doesn't move or turn):
    • 6.85 m/s in the lee, 9.14 m/s at most;
    • a full-rudder circle of 31.5 m (2U/r gives 31.0);
    • heave 0.13 m, pitch 1.5° and roll 3.1° RMS in the lee, and 0.33 m heave along the reflecting south-west shore;
    • the wake's cusp line at 3.5 m/s (Froude 0.5) reads 20.4° against Kelvin's 19.47°. At full throttle (Froude 1.08) it narrows to 10–15°.
  • Frames show the foam V and the Kelvin chevrons, and a dry cockpit.

Checked locally (Windows Release, GL build), on this branch with the four PRs below it merged in

  • ctest -R Physics: 177 passed, 2 skipped by design.
  • physics_immersion_test 7, physics_boat_test 10, physics_hull_test 15, ocean_ewave_test 12, ocean_sea_test 19 and physics_field_test 22, all passing, with goldens unchanged.
  • cvcgl_ewave, cvcgl_wake and cvcgl_ocean_fft pass.
  • lsystem_coast: --boat-check exits 0 with the numbers above; --debris-check --wake-check (60 s) exits 0 with O7c's debris numbers unchanged.

Each part had an independent review: 5 findings for O9, 3 for O11b and 4 for O11c, all fixed. For example, a teleported body made a false wake source, and the drawn pose was paired with the water at a different time.

Known limits and follow-ups

  • The demo's default sea is about 4× JONSWAP's significant wave height for its wind (6 m at 9 m/s, wave_amp 1.2). The skiff stalls in it, so --boat-check uses a moderate sea. Calibrating the cascades is a follow-up.
  • Wake cost: about 5–6 ms CPU a frame, mostly immersing the hull and the sea's band at the frame's time, which could move off the render thread. About 1.7–2 ms GPU.
  • Not done:
    • spray, propeller wash and wet-hull darkening;
    • the boat feeling waves (C5);
    • dyn_boat_plant (D4) and the Ariadne boat node (D6);
    • boats in snapshot() and pycvc.

…(O8a)

cvc::ocean::ewave runs Tessendorf's eWave (roadmap C1, C3, C5) on an
n x n window: h and phi packed as one complex field, one forward and one
inverse FFT a step, each wavenumber moved on exactly for any dt in one
depth, then the mask, the edge sponge and the sources in real space.
det math and fft.h, built without FMA contraction, so a window gives
the same bits on every platform; its digest is pinned.

ocean_ewave_test checks the exact mode oscillation, energy conservation,
the ring's group velocity and isotropy, reflection off a straight wall,
the sponge, shallow-water speed, the Kelvin wake angle at two speeds,
the digest and the refusals, and prints the step's cost.
…surface

A dynamic body may carry a hull (body_desc::hull, cvc/physics/hull.h): a
closed triangle list apart from its collision shape. Fluid fields push on
its triangles in place of the 8-cells-per-side sample: each triangle is
split at the waterline (the free surface's height at its vertices, or the
box top), and its submerged part feels hydrostatic pressure at its centre
of pressure, ITTC-57 friction, pressure drag growing with (v.n)^2, a
bounded added-mass slamming term and the field's damping in heave. The
velocity terms are integrated implicitly in their own linear and rotational
rates. det:: math, a fixed order.

A world with hulls saves a CVCHULL1 section (each hull's digest and its
triangles' last wetted areas), so state_hash covers them and restore
refuses other hulls; a world without hulls saves and hashes as before.
physics_hull_test covers floating, righting, towing resistance, a drop, a
light hull, heave on a swell and the state, and pins a hull scene's hash.
world::add_force_at(id, force, point) applies a world-frame force at a
world-frame point, so off the centre of mass it also torques the body;
world::add_torque(id, torque) applies a world-frame torque. Both check
that every value is finite and otherwise act as add_force does: through
the next step only, waking a sleeping body, refusing an unknown id.
New backend_impl calls carry them to Jolt (AddForce at a point, moved to
the engine's floating-origin frame, and AddTorque) and to the null
backend, which checks the id. pycvc binds both.

Tests in physics_world_test check the spin against r x F dt / I, that a
force at the centre of mass gives add_force's state hash, that a torque
does not translate, that both wake a sleeping body, and the refusals.
This is roadmap item D1 of OCEAN-AND-WEATHER-ROADMAP.md.
pycvc's add_force_at refuses a point of None instead of reading it as the
world origin. world.h and PHYSICS_API.md say body_state::position is the
body's origin, not its centre of mass, which differs for a hull or a
vehicle chassis; a new test shows a force at a hull's origin torques it.
ForceAtAndTorqueAreChecked now covers a kinematic body, and roadmap 1.2
marks off-centre forces done.
The field's damping on a hull now sums to the cells' c V_sub, shared among
the downward faces by the water column over each; upward faces under water
took their column too, so a submerged hull was damped more the deeper it
went. The horizontal drag is scaled in the rate without the damping, so the
damping no longer slows a towed hull. add_body keeps a private copy of the
hull mesh, so the cached normals, wetted areas and digest always describe
what is simulated. The torque's inertia estimate also takes the collision
shape's where that is lower.

New tests: the first-step torque on a heeled box is the wall-sided righting
moment (12 and 432 triangles), a sinking hull keeps its speed at depth, and
changing the caller's mesh after add_body changes nothing. The towing test
now checks the absolute resistance. The hull scene's pinned hash is
re-measured (2f71a1fe229afa75); the docs say CI has yet to confirm it.
- A beach mask value is now a damping rate, beach_rate (1 - m), applied as
  exp(-rate dt) like the sponge, so a beach absorbs the same share per
  second at any step size. Land (m = 0) is still zeroed every step. New
  test: a beach band leaves 68.95 / 68.96 / 68.89 % of a ring's energy
  after 10 s at 30, 60 and 10 Hz. The pinned digest moves to
  0xa4933455f6946eca.
- New test for a wall band with open water behind it: a 3 m band lets
  through 4.6 % of the incident amplitude (held below 6 %), a 6 m band less.
- The standing-mode test computes omega from the dispersion relation
  itself instead of the library's omega().
- The Kelvin test runs the source 140 m in a 512^2 window with an 8 s ramp,
  so the rows it reads are steady wake. It checks the edge at 30, 40 and
  50 % of the row maximum, at 2.5 and 3.0 m/s.
- Roadmap section 6: the as-built block gets the new measurements, a
  labelled diagnostic for the wrap-around share of thin-wall leakage, and a
  note that the update is still unchecked against the eWave paper.
EWave (src/cvcGL/ocean) runs the CPU eWave's window in float with
fragment passes: z = h + i phi in RG32F, the forward FFT, an update
pass that separates H and PHI at k and -k and applies the exact
per-mode update and damping, the inverse FFT, and a real-space pass
for the normalisation, the mask's beach, the sponge and land. 34
passes a step at 256^2. Sources go into h at once, as on the CPU.

The butterfly LUT, pass and pass setup move from OceanFFT.cpp into
OceanButterfly.{h,cpp}; the forward transform conjugates the twiddle
in the shader. OceanFFT's output is unchanged.

cvcgl_ewave runs one scenario on both windows (GPU vs CPU within
2.3e-5 of the RMS field), the wall test on the GPU, and the passes and
GPU time per step.
Count the passes step() renders instead of adding passesPerStep()'s
formula: OceanButterfly counts its own passes and EWave counts the update,
real-space and source passes, so cvcgl_ewave's 34-pass check (and a new
one-pass check for addDrop) measures something.

Say in EWave.h that only the mask is held before init(); setState, addDrop,
addHeights and step do nothing until init() succeeds.

Name OceanButterfly.{h,cpp} and the cvcgl_ocean_band and cvcgl_ewave tests
in the ABYSSAL notice, and correct roadmap section 6's Cost paragraph: a
cascade is 35 passes, so three are 105 and eWave adds about 32 % by pass
count, not the +60 % the old count of 57 gave.
world::add_boat adds a hull body with a propeller (thrust falling off
with the inflow, only while under the free surface; an optional outboard
that vectors it) and a rudder (lift to the stall, then a flat plate, and
drag, from the flow past it), driven through first-order actuators by
set_boat_controls. The forces go through add_force_at before each engine
step, in boat id order, with det:: math. A boat's description digest,
controls, actuators and last forces are a CVCBOAT1 save section; a world
without boats saves and hashes as before.

physics_boat_test checks the thrust-resistance balance at terminal
speed, backing, steady turning circles against rudder angle, a dry
propeller, an outboard at low speed, pitching on a swell, the state, and
pins a boat scene's hash (measured on Windows; CI confirms elsewhere).
Document boat_state::water_velocity as the water's under or at the centre of mass (0 only where no fluid covers it) and boat_state::inflow as measured along the propeller's ahead direction. Correct the restore() claim: the boat section is checked after the engine is restored, so a refused state leaves the boats unchanged but not the bodies.
O8's mask zeroed h and phi on wall cells each step: a Dirichlet wall,
under which a crest comes back as a trough. A vertical wall or cliff is
no-flux (d phi / dn = 0), about which h and phi are even, so a crest comes
back as a crest. Walls are now no-flux by default, by ghost cells (the
image method), on the CPU and the GPU.

cvc::ocean::ewave_wall_ghosts finds, at set_mask, the nearest water cell q
of each wall cell p within the ghost band (exact integer search, no wrap),
mirrors p across the shore half a cell from q (p' = p + 2 s n), and stores
p' as bilinear corners restricted to water with renormalised weights. Each
step, after the real-space pass, and after each source, the ghost cells
take h and phi from their corners. A straight wall is exact (a no-flux
channel's own mode oscillates at omega to 3e-14); staircase and curved
walls are first order.

ewave_params::walls picks no_flux (the default) or zero (O8a's wall, bit
for bit: the digest leaves both new fields out under zero, so the pin
0xa4933455f6946eca stands). ghost_cells defaults to 16, the knee of the
measured reflection error (the spectral operator is not local, so the
image's cut at the band shows as about 1 / band). A no_flux pin is added,
0xfc278a415ad67d3f, measured on Windows; CI checks Linux and macOS.

EWave (cvcGL) runs the same fill as one more pass when there are ghosts
(35 a step, 34 without), from the CPU's own table uploaded as an RG32F
corner texture and an RGBA32F weight texture, fetching the four corners
itself. On the wall test it gives the even image to 6.7 % and agrees with
the CPU to 6.1e-5 RMS.

ocean_ewave_test: the straight-wall test now checks both kinds (the even
image to 6.8 % RMS under no_flux, the odd one to 18.8 % under zero, the
reflection's sign), plus a no-flux channel mode, lossless closed basins
(straight, 45-degree, disc: no growth over 300 s), the thin-wall leak
under no_flux, and set_mask's cost. AThinWallLeaksLittle and the digest
test pin their O8a claims to walls = zero. Roadmap section 6 gains the
"As built (O8c)" block with the measurements.
#1159 (O7c) kept the last source sea_surface found in a thread_local, so
the velocity a fluid field reads after a cell's height at the same point
and time did not invert the sideways move again. A thread_local that
keeps state between calls is a static cache, which libcvc's no-singletons
rule forbids (VOLROVER-LIBRARY-PORTS-ROADMAP.md 1.3,
tools/singleton_scan). #1159's release-grpc job, where the scan runs, was
cancelled, so the scan never judged it; the next PR that merges master
would fail that lane on it.

The memo now belongs to the caller:

- sea_surface::source_memo, and height() / velocity() overloads that take
  one. The plain reads share nothing.
- fluid_surface::height_with / velocity_with and a surface_memo the
  caller owns; the defaults ignore it. ocean_surface passes it to the sea.
- field_set::apply keeps one memo per cell, for the cell's height and its
  velocity at the same clipped centre.

The memo is keyed on the point, the time and the digest as before, so
every value is unchanged.
The shared immersion code, cvc/physics/immersion.h: a body's columns of
immersed depth over a grid window from its shape (box, sphere, convex
hull, or its hull mesh), its pose and the water, as the field step
immerses it; standard library, the same bits on every platform (pinned
in physics_immersion_test, measured on Windows; CI checks Linux/macOS).

WakeSource turns it into EWave's sources, -(zeta(t) - zeta(t - dt)),
and EWave gains a one-pass shift so a window can follow something.
cvcgl_wake checks the sources, the shift, a box footprint's Kelvin wake
read from the GPU (19.3-20.0 deg at 2.5 and 3 m/s) and a rock's shadow.

lsystem_coast draws the debris' wakes: a 128 m sea window on the
camera's target (D3) with a mask from the shore, and one on the crater
lake whose banks reflect; height, slope and foam in both water shaders;
--wake-check reports the windows' energy and a lake drop's ring.
- A teleported body (the wake check's drop, "drop them again") no
  longer leaves a false ring where it floated: the sources only record
  the columns until the drawn poses are the ones after it.
- The sea sources cut each drawn pose against the sea at that pose's
  field time (one physics step behind the frame), not at the frame's.
- --wake-check now fails (rc 5) when a window with bodies has no waves,
  the drop makes no ring, or the lake keeps no more than its absorbing
  twin.
- add_immersion: a hull mesh in unbounded water is wholly under, not
  NaN read as dry; new test.
- immersion.h and the roadmap no longer claim exact agreement or smooth
  zeta; the roadmap's lake and sea numbers are re-measured.
…an-boat

# Conflicts:
#	docs/PHYSICS_API.md
#	src/cvc/CMakeLists.txt
#	src/cvc/tests/CMakeLists.txt
The review measured no-flux walls growing without bound in curved and
thin closed basins. Confirmed: overwriting the ghosts with the image is
an oblique projection, and the water's update it gives is not symmetric
where the image is not an exact mirror or is cut off at the band. None
of the stabilisers tried in a scratch probe (a taper, capping each water
cell's ghost weight, no ghosts near a medial axis, k^2 damping, folding
the fill's transpose back as an orthogonal projection, and partial or
first-layer folds) held every basin while keeping the straight wall's
reflection, so:

- walls = zero (O8a, bit for bit) is the default again; no_flux is opt
  in, its stability limits documented in ewave.h with the measured
  growth and the damping (0.004 /s) that held every basin at 1/30 s.
- New WallsStayBounded: broadband noise in closed basins (disc, island,
  breakwater, straight channel, thin wall) at dt 0.1, 0.25 and 1/30 s.
  Zero walls never exceed their start; no_flux growth is printed; the
  straight channel and thin wall stay level at 1/30 s, and 0.004 /s of
  damping holds every basin there.
- NoFluxWallsAreLossless becomes NoFluxWallsAreNearlyLossless and no
  longer claims stability; it adds the whole-wall straight channel and
  checks energy() against the water-only sum.
- energy() counts the water only (mask > 0): the ghosts are left out
  and, with ghosts, the kinetic part is sum phi (K phi) over the water.
  Without ghosts it is unchanged. height(), phi(), at() and
  EWave::heightTexture() are documented to include the ghost image.
- cvcgl_ewave: scenario 1 adds a round island whose ghosts have
  fractional weights with wall corners zeroed, and checks the GPU
  against the CPU within 3 m of it (a swapped weight channel fails it).
- The band sweep covers 1 cell; the roadmap's O8c block is corrected.
A 5 m skiff with an outboard, a cvc::physics boat in the debris' world,
floated by the hull mesh it is drawn as. I/J/K/L and the panel's Boat
section drive it through coast.boat.* knobs; C toggles a chase camera
that also brings the sea's wake window along. Its columns feed the wake
window like the debris', and the sea's shader discards water inside the
hull (D5).

--boat-check drives a scripted course and reports speed, turning circle,
heave/pitch/roll on the lee and along the reflecting south-west shore,
and the wake's angle at two speeds; --snap writes frames at given times.
…finite

GCC's glibc declares ::finite(double), so inside EWave's member functions an unqualified
finite() found both it and the file's own helper and was ambiguous; MSVC has no ::finite,
so only the Linux lanes failed to build cvcgl_ewave. Rename the helper; nothing else
changes.
…O8c)

The ghost-cell walls overwrote the wall cells with the water's mirror image
after each exact step: an oblique projection, unstable wherever the image
was not an exact mirror (a disc grew 31x in 2000 s, a thin wall 1e72x).
They are replaced by a scheme that conserves energy by construction, and
no_flux walls are the default again.

The state lives on the water; R extends it over the window (ghost cells
take their mirror image), R^T folds back, S = R^T G R is symmetric positive
semidefinite for any ghosts and weights, and M is the lumped mass (the row
sums of R^T R, ewave_lumped_mass). Stormer-Verlet in substeps that keep
omega_max dt_s <= 1.8 (ewave_substeps): S <= max(G) M bounds every mode
inside the limit, and the step conserves its modified energy exactly, so
nothing can grow at any dt. G is kappa~ = 4 sin^2(omega dt_s / 2) /
(g dt_s^2), so open water keeps eWave's exact dispersion (with kappa a
straight wall's reflection was 55 % off its even image at dt 0.1 s).
damping_k2, the beach and the sponge act on h through M-contractions;
the global damping on both. Windows without ghosts keep the exact step bit
for bit (the zero-walls pin 0xa4933455f6946eca holds).

Accuracy: the fold carries G's response at every ghost back into the water,
so an image cut short (or two shores' images meeting in a thin wall) shows
at the cut's mirror distance. The default band now reaches as far as the
image does (ghost_cells = 4096), and the weights taper to 0 over 8 cells
near the cuts and seams that remain. No water cell is read by more than 12
ghosts (whole ghosts dropped, farthest first, on CPU and GPU alike).

Measured (Windows): a no-flux channel is the exact Neumann operator
(2.9e-15) and its mode matches Stormer-Verlet's discrete solution to
4e-14; broadband noise in seven closed basins for 20000 steps at omega_max
dt 1.8, 0.25 s and 1/30 s keeps the modified energy within 1.3e-14 and
energy() never above its start; the straight wall matches the even image
to 2.9e-14 without the sponge and 2.2 % with it (6.8 % before), gain 1.90,
slope +1.001; rings in closed ponds lose nothing over 300 s; thin walls
leak 10.8 / 5.7 / 3.0 % at 3 / 6 / 12 m. New no_flux pin
0x40cb161804c270ca (Linux and macOS to be confirmed by CI).

EWave runs the same scheme from the same CPU tables: per substep a fill
pass, the forward butterflies, a multiply pass, the inverse butterflies
and a gather pass (readers in six RGBA32F textures, 1 / M in an R32F one):
4 log2 n + 3 = 35 passes at 256^2, plus one real-space pass a step (36 at
1/30 s, against 34 without walls). It agrees with the CPU to 1e-5 RMS,
reflects crest for crest (2.1 % against the even image) and stays bounded
over a long broadband run. Roadmap section 6's O8c block is rewritten.
lsystem_coast draws the D5 hole from the pose present() posed the hull
with (a group of one in the binding), not a second tracker sample that a
threaded physics step could land between. --boat-check prints the wake
window's depth and depth Froude number; the new knob coast.wake.depth
forces the window's depth, and a deep rerun shows the full-throttle
narrowing is the length Froude number's, not the shallow window's.
--snap no longer puts its tag into a dotted directory name. The roadmap
has coast.boat.enabled's sense right and the depth result.
…ocal

The writable-data scan (#1152 made its allowlist a ratchet) refuses process-wide state, and
sea_surface::source kept its last source in a thread_local (O7c, #1159), so every PR's
package-linux release-grpc lane now fails on master's code. The memo moves into the time's
frame, under the mutex the frame already has for its lattice: a frame is the surface at one
time, so the point alone is the key, and as a memo of a pure function it changes no value.
ocean_sea_test (19, pins unchanged) and physics_field_test (22, goldens unchanged) pass; the
exact height-and-velocity pair still costs about what it did (3.8 us, 1.76 us on the lattice).
…ocean-ewave-walls

# Conflicts:
#	src/cvcGL/ocean/EWave.cpp
- The symmetric step's substep no longer follows the caller's dt. kappa~
  and Stormer-Verlet's invariant both depend on it, so a dt that changed
  between steps switched between maps with different invariants and grew
  by parametric resonance (the review: a disc 1e103-fold in 4000 steps of
  0.136 and 0.101 s in turn). A window now has one substep,
  ewave_params::substep (default 1/60 s, capped at 1.8 / omega_max):
  step(dt) runs whole substeps (ewave_substep_count) and carries the rest
  in pending(). The beach, sponge, global damping and damping_k2 act every
  substep for dt_s, so every substep is the same linear map whatever the
  dts. Same on the GPU: the count is made on the host in double, and the
  real-space factors move into the gather pass. New tests
  (VariableStepsAreStable on the CPU, jittered dt in cvcgl_ewave): the
  modified energy holds to 6e-15 under alternating and jittered dt.
- A wall one cell thick is a seam: its nearest water lies on opposite
  sides, so its image tapers to almost 0 instead of holding the front
  water beside the water behind. It leaked 87.6 %; now 40.4 % (zero walls
  41.1 %). AThinWallLeaksLittle covers 1, 2 and 4 cells.
- ewave_wall_ghosts finds each wall cell's nearest water with a distance
  transform, O(n^2) whatever the band (1024^2 set_mask: 0.21-0.25 s,
  against 10 s), ties exact within 32 cells of the shore.
- The GPU gather decodes a reader's cell by truncation (int(cell + 0.5)
  rounded odd indices up past 2^23); the header gives the reader
  textures' memory.
- Docs: stability now holds for any sequence of steps; the 2.2 %
  reflection is the best case where the whole image fits; the mean
  potential's drift where S annihilates constants is documented (not
  gauged: the GPU would need a reduction).
- The no_flux pin is re-measured on Windows: 0x9d1fde2b635d7dbf. The
  zero-walls pin 0xa4933455f6946eca holds.
…t/ocean-boat

# Conflicts:
#	docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md
#	src/cvcGL/ocean/EWave.cpp
#	src/cvcGL/ocean/EWave.h
@transfix transfix changed the title ocean: bodies make waves, boats, a drivable boat in lsystem_coast (O9, O11b, O11c) ocean: no-flux walls, bodies make waves, boats, a drivable boat (O8c, O9, O11b, O11c) Nov 12, 2026
The symmetric step applied damping_k2 as h <- M^-1 R^T F R h. At F = 1 that
is not the identity: M^-1 R^T R averages each water cell a ghost reads with
the corners round the ghost's mirror point, wherever that point falls between
cells. Run once a substep, the smoothing took lsystem_coast's crater lake's
ring faster under no-flux banks than under zero ones (20 % of the energy left
10 s after the drop, against 55 %).

The filter is now h <- h - M^-1 R^T (1 - F) R h (1 - F as -expm1, and as
x (1 - x/2) below 1e-3 in the GPU's float): the same beside a straight wall,
still self-adjoint under M with eigenvalues in (0, 1], and the identity as F
goes to 1. In a disc 36 m across with damping_k2 2e-3, the energy left after
10 s is 75.7 % under no-flux walls against 75.5 % under zero walls (the first
form: 49.3 %); at damping_k2 1e-15 the heights match the undamped run to
1.5e-13 (the first form: 99 % off). New test:
DampingK2TakesTheSameShareWhateverTheWalls. The no-flux digest pin is
re-measured.

lsystem_coast's lake now keeps 48 % after 10 s (13 % with absorbing banks).
The rest of the gap to 55 % is the check's reading, the water's sum of h^2
without M, which sits near 1 / mean(M) of the conserved energy once the ring
reaches the banks. The roadmap's O8c and O9 blocks have the numbers.
… into feat/ocean-boat

# Conflicts:
#	docs/PHYSICS_API.md
@transfix

Copy link
Copy Markdown
Owner Author

This branch carried #1193's fix for the sea's source memo, so the writable-data scan would pass. #1193 was closed as superseded by #1181, Joe's pick, so I swapped it:

Until #1181 merges, this PR's diff includes #1181's 10 files. Once #1181 lands they match master, and this PR merges with only its own changes.

The other order is safe too: the branch now carries exactly #1181's code, so whichever merges first, the master that results was tested. Physics and ocean tests pass locally on Windows Release.

…/ocean-boat

# Conflicts:
#	docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md
#	examples/CMakeLists.txt
#	inc/cvc/ocean/ewave.h
#	src/cvc/ocean/ewave.cpp
#	src/cvc/tests/ocean_ewave_test.cpp
#	src/cvcGL/CMakeLists.txt
#	src/cvcGL/ocean/EWave.cpp
#	src/cvcGL/ocean/EWave.h
#	src/cvcGL/test/cvcgl_ewave.cpp
…/ocean-boat

# Conflicts:
#	docs/PHYSICS_API.md
#	src/cvc/CMakeLists.txt
#	src/cvc/physics/world.cpp
#	src/cvc/tests/CMakeLists.txt
…eps in unoptimized builds

Ewave.WallsAreStable and Ewave.VariableStepsAreStable step a 64^2 basin tens of
thousands of times: 83-129 s and 29-42 s in a Release build, and past ctest's
300 s in the Debug package lanes (package-linux libcvc-debug and -debug-grpc on
#1194), which run these tests about 10 times slower.

As #908 did for the stepped mesher tests, gated on the optimizer rather than
NDEBUG: an unoptimized build divides run_basin's step count and its energy()
sampling interval by kBasinScale (20), so each quarter still averages as many
samples. The printouts report the steps actually run.

Forced to 20 in a Release build, both pass in 4.5 s and 1.7 s: modified energy
within 8.2e-15 (limit 1e-9), last-quarter drift at most 0.0008 (limit 0.005),
damped runs end at 1.6e-6 of their start (limit 0.5). Optimized builds are
unchanged (18/18 ocean_ewave_test, full counts).
@transfix
transfix merged commit bfd339d into master Nov 14, 2026
27 checks passed
@transfix
transfix deleted the feat/ocean-boat branch November 14, 2026 09:31
transfix added a commit that referenced this pull request Nov 14, 2026
#1194's symmetric step (no-flux walls, the default) takes kappa~ = 4 sin^2(omega dt_s / 2) /
(g dt_s^2) in its multiply pass, from GLSL's sin: at the default substep the argument is a tenth of
a radian or less, where GLSL's absolute 2^-11 is a relative error of several percent. sinCos is now
one string literal (CVC_EWAVE_SINCOS_GLSL) that the update and multiply passes both take in, and
the multiply pass's sin is its .x. EWave.h keeps #1194's description, with where sin and cos come
from.
transfix added a commit that referenced this pull request Nov 14, 2026
…urfaces

A clean merge. #1225 makes master build again after #1203; its cmd_trace
change is the one this branch already had. The diff against master is only
this PR's own 14 files again.
transfix added a commit that referenced this pull request Nov 14, 2026
…#1222-#1225, #1229)

Master's #1190 (file-pick and http-upload) was written for a single async host; this branch runs
an isolated document's programs on its own group's host, on a pool worker in an `any` group.

- net_intrinsics.cpp: StartedRequest takes master's deliver()/on_outcome, settling through the
  host's finisher. http-upload is its own provider, `any` as the requests are: it parks on the
  calling program's host (ictx.host), takes its progress path from ictx.root_path (no tree walk
  on a worker), and a started upload (a browser page) keeps the host's finisher, not the host.
- ariadne.cpp: file-pick, file-info and file-forget bind into the program's env as they are, in
  every group (install_backend_verbs), not through the backend verbs' host_proxied wrapper, which
  cannot park an async verb. file-pick parks on the program's own host, claims the Runtime's
  picker hub under its lock where it is called, and opens the picker on the host thread
  (exec_pool::run_on_host; inline when called there). Its answer goes through the host's
  finisher, as the host may be gone by then.
- ci.yml: the sanitizer list keeps this branch's tests and master's point_classes_test.
- STATE_EXEC_THREADED.md: rows for http-upload, the file verbs, and the contours and
  point-classes providers. The last two are registered without a kind, so they are host_only, and
  an isolated document in an app that installs them goes to a host-affinity group.
- New test: AriadneIsolatedDocs.FilePickOpensItsPickerOnTheFramesThread.
transfix added a commit that referenced this pull request Nov 14, 2026
…ates

#1194 gave EWave the CPU's symmetric step for no-flux walls (fill, multiply
and gather passes) and #1224 gave the update and multiply passes their own sin
and cos series. Both rewrote the code this branch changed, so EWave.cpp and
EWave.h start from master's and take this branch's change on both paths:

- The exact step reads each mode's coefficients (modeCoefficients, as
  ewave::prepare) and each cell's real-space factor (realFactors, as
  ewave::update_real) from textures worked out on the host in double.
- The symmetric step's multiply pass reads kappa~ and damping_k2's 1 - F
  (symmetricMultipliers, as ewave::prepare_symmetric, -expm1 for 1 - F), and
  its gather pass reads the real-space factors for dt_s.
- The last pass home only zeroes walls, as before. No pass takes a sin, cos,
  exp, sqrt or tanh of its own, so #1224's series goes.
- Each table is worked out again only when the step, the depth (setDepth) or
  the mask changes; dt_s is fixed, so the symmetric step pays once.

cvcgl_ewave and cvcgl_wake pass on Windows (Intel Arc). Against master's
#1224 on the same machine: step 48 (no-flux walls) h 3.14e-6 -> 2.20e-6, phi
2.23e-6 -> 1.53e-6; the zero-wall run 1.04e-5 -> 9.62e-6, the no-flux wall run
5.05e-6 -> 3.63e-6. Step times within run-to-run noise.
transfix added a commit that referenced this pull request Nov 15, 2026
…PU FFT ocean (O15 part 2) (#1253)

* ocean: eWave on the CPU, a deterministic window of waves bodies make (O8a)

cvc::ocean::ewave runs Tessendorf's eWave (roadmap C1, C3, C5) on an
n x n window: h and phi packed as one complex field, one forward and one
inverse FFT a step, each wavenumber moved on exactly for any dt in one
depth, then the mask, the edge sponge and the sources in real space.
det math and fft.h, built without FMA contraction, so a window gives
the same bits on every platform; its digest is pinned.

ocean_ewave_test checks the exact mode oscillation, energy conservation,
the ring's group velocity and isotropy, reflection off a straight wall,
the sponge, shallow-water speed, the Kelvin wake angle at two speeds,
the digest and the refusals, and prints the step's cost.

* physics: the hull model (O11a), forces per triangle against the free surface

A dynamic body may carry a hull (body_desc::hull, cvc/physics/hull.h): a
closed triangle list apart from its collision shape. Fluid fields push on
its triangles in place of the 8-cells-per-side sample: each triangle is
split at the waterline (the free surface's height at its vertices, or the
box top), and its submerged part feels hydrostatic pressure at its centre
of pressure, ITTC-57 friction, pressure drag growing with (v.n)^2, a
bounded added-mass slamming term and the field's damping in heave. The
velocity terms are integrated implicitly in their own linear and rotational
rates. det:: math, a fixed order.

A world with hulls saves a CVCHULL1 section (each hull's digest and its
triangles' last wetted areas), so state_hash covers them and restore
refuses other hulls; a world without hulls saves and hashes as before.
physics_hull_test covers floating, righting, towing resistance, a drop, a
light hull, heave on a swell and the state, and pins a hull scene's hash.

* physics: add_force_at and add_torque on world (O10)

world::add_force_at(id, force, point) applies a world-frame force at a
world-frame point, so off the centre of mass it also torques the body;
world::add_torque(id, torque) applies a world-frame torque. Both check
that every value is finite and otherwise act as add_force does: through
the next step only, waking a sleeping body, refusing an unknown id.
New backend_impl calls carry them to Jolt (AddForce at a point, moved to
the engine's floating-origin frame, and AddTorque) and to the null
backend, which checks the id. pycvc binds both.

Tests in physics_world_test check the spin against r x F dt / I, that a
force at the centre of mass gives add_force's state hash, that a torque
does not translate, that both wake a sleeping body, and the refusals.
This is roadmap item D1 of OCEAN-AND-WEATHER-ROADMAP.md.

* physics: address review of add_force_at and add_torque (O10)

pycvc's add_force_at refuses a point of None instead of reading it as the
world origin. world.h and PHYSICS_API.md say body_state::position is the
body's origin, not its centre of mass, which differs for a hull or a
vehicle chassis; a new test shows a force at a hull's origin torques it.
ForceAtAndTorqueAreChecked now covers a kinematic body, and roadmap 1.2
marks off-centre forces done.

* physics: address review of the hull model (O11a)

The field's damping on a hull now sums to the cells' c V_sub, shared among
the downward faces by the water column over each; upward faces under water
took their column too, so a submerged hull was damped more the deeper it
went. The horizontal drag is scaled in the rate without the damping, so the
damping no longer slows a towed hull. add_body keeps a private copy of the
hull mesh, so the cached normals, wetted areas and digest always describe
what is simulated. The torque's inertia estimate also takes the collision
shape's where that is lower.

New tests: the first-step torque on a heeled box is the wall-sided righting
moment (12 and 432 triangles), a sinking hull keeps its speed at depth, and
changing the caller's mesh after add_body changes nothing. The towing test
now checks the absolute resistance. The hull scene's pinned hash is
re-measured (2f71a1fe229afa75); the docs say CI has yet to confirm it.

* ocean: address review of the CPU eWave (O8a)

- A beach mask value is now a damping rate, beach_rate (1 - m), applied as
  exp(-rate dt) like the sponge, so a beach absorbs the same share per
  second at any step size. Land (m = 0) is still zeroed every step. New
  test: a beach band leaves 68.95 / 68.96 / 68.89 % of a ring's energy
  after 10 s at 30, 60 and 10 Hz. The pinned digest moves to
  0xa4933455f6946eca.
- New test for a wall band with open water behind it: a 3 m band lets
  through 4.6 % of the incident amplitude (held below 6 %), a 6 m band less.
- The standing-mode test computes omega from the dispersion relation
  itself instead of the library's omega().
- The Kelvin test runs the source 140 m in a 512^2 window with an 8 s ramp,
  so the rows it reads are steady wake. It checks the edge at 30, 40 and
  50 % of the row maximum, at 2.5 and 3.0 m/s.
- Roadmap section 6: the as-built block gets the new measurements, a
  labelled diagnostic for the wrap-around share of thin-wall leakage, and a
  note that the update is still unchecked against the eWave paper.

* ocean: eWave on the GPU, the window in cvcGL (O8b)

EWave (src/cvcGL/ocean) runs the CPU eWave's window in float with
fragment passes: z = h + i phi in RG32F, the forward FFT, an update
pass that separates H and PHI at k and -k and applies the exact
per-mode update and damping, the inverse FFT, and a real-space pass
for the normalisation, the mask's beach, the sponge and land. 34
passes a step at 256^2. Sources go into h at once, as on the CPU.

The butterfly LUT, pass and pass setup move from OceanFFT.cpp into
OceanButterfly.{h,cpp}; the forward transform conjugates the twiddle
in the shader. OceanFFT's output is unchanged.

cvcgl_ewave runs one scenario on both windows (GPU vs CPU within
2.3e-5 of the RMS field), the wall test on the GPU, and the passes and
GPU time per step.

* ocean: address review of the GPU eWave (O8b)

Count the passes step() renders instead of adding passesPerStep()'s
formula: OceanButterfly counts its own passes and EWave counts the update,
real-space and source passes, so cvcgl_ewave's 34-pass check (and a new
one-pass check for addDrop) measures something.

Say in EWave.h that only the mask is held before init(); setState, addDrop,
addHeights and step do nothing until init() succeeds.

Name OceanButterfly.{h,cpp} and the cvcgl_ocean_band and cvcgl_ewave tests
in the ABYSSAL notice, and correct roadmap section 6's Cost paragraph: a
cascade is 35 passes, so three are 105 and eWave adds about 32 % by pass
count, not the +60 % the old count of 57 gave.

* physics: boats, a propeller and rudder applied every step (O11b)

world::add_boat adds a hull body with a propeller (thrust falling off
with the inflow, only while under the free surface; an optional outboard
that vectors it) and a rudder (lift to the stall, then a flat plate, and
drag, from the flow past it), driven through first-order actuators by
set_boat_controls. The forces go through add_force_at before each engine
step, in boat id order, with det:: math. A boat's description digest,
controls, actuators and last forces are a CVCBOAT1 save section; a world
without boats saves and hashes as before.

physics_boat_test checks the thrust-resistance balance at terminal
speed, backing, steady turning circles against rudder angle, a dry
propeller, an outboard at low speed, pitching on a swell, the state, and
pins a boat scene's hash (measured on Windows; CI confirms elsewhere).

* physics: address review of O11b

Document boat_state::water_velocity as the water's under or at the centre of mass (0 only where no fluid covers it) and boat_state::inflow as measured along the propeller's ahead direction. Correct the restore() claim: the boat section is checked after the engine is restored, so a refused state leaves the boats unchanged but not the bodies.

* ocean: eWave walls that reflect a crest as a crest (O8c)

O8's mask zeroed h and phi on wall cells each step: a Dirichlet wall,
under which a crest comes back as a trough. A vertical wall or cliff is
no-flux (d phi / dn = 0), about which h and phi are even, so a crest comes
back as a crest. Walls are now no-flux by default, by ghost cells (the
image method), on the CPU and the GPU.

cvc::ocean::ewave_wall_ghosts finds, at set_mask, the nearest water cell q
of each wall cell p within the ghost band (exact integer search, no wrap),
mirrors p across the shore half a cell from q (p' = p + 2 s n), and stores
p' as bilinear corners restricted to water with renormalised weights. Each
step, after the real-space pass, and after each source, the ghost cells
take h and phi from their corners. A straight wall is exact (a no-flux
channel's own mode oscillates at omega to 3e-14); staircase and curved
walls are first order.

ewave_params::walls picks no_flux (the default) or zero (O8a's wall, bit
for bit: the digest leaves both new fields out under zero, so the pin
0xa4933455f6946eca stands). ghost_cells defaults to 16, the knee of the
measured reflection error (the spectral operator is not local, so the
image's cut at the band shows as about 1 / band). A no_flux pin is added,
0xfc278a415ad67d3f, measured on Windows; CI checks Linux and macOS.

EWave (cvcGL) runs the same fill as one more pass when there are ghosts
(35 a step, 34 without), from the CPU's own table uploaded as an RG32F
corner texture and an RGBA32F weight texture, fetching the four corners
itself. On the wall test it gives the even image to 6.7 % and agrees with
the CPU to 6.1e-5 RMS.

ocean_ewave_test: the straight-wall test now checks both kinds (the even
image to 6.8 % RMS under no_flux, the odd one to 18.8 % under zero, the
reflection's sign), plus a no-flux channel mode, lossless closed basins
(straight, 45-degree, disc: no growth over 300 s), the thin-wall leak
under no_flux, and set_mask's cost. AThinWallLeaksLittle and the digest
test pin their O8a claims to walls = zero. Roadmap section 6 gains the
"As built (O8c)" block with the measurements.

* ocean: bodies make waves (O9)

The shared immersion code, cvc/physics/immersion.h: a body's columns of
immersed depth over a grid window from its shape (box, sphere, convex
hull, or its hull mesh), its pose and the water, as the field step
immerses it; standard library, the same bits on every platform (pinned
in physics_immersion_test, measured on Windows; CI checks Linux/macOS).

WakeSource turns it into EWave's sources, -(zeta(t) - zeta(t - dt)),
and EWave gains a one-pass shift so a window can follow something.
cvcgl_wake checks the sources, the shift, a box footprint's Kelvin wake
read from the GPU (19.3-20.0 deg at 2.5 and 3 m/s) and a rock's shadow.

lsystem_coast draws the debris' wakes: a 128 m sea window on the
camera's target (D3) with a mask from the shore, and one on the crater
lake whose banks reflect; height, slope and foam in both water shaders;
--wake-check reports the windows' energy and a lake drop's ring.

* ocean: address review of O9

- A teleported body (the wake check's drop, "drop them again") no
  longer leaves a false ring where it floated: the sources only record
  the columns until the drawn poses are the ones after it.
- The sea sources cut each drawn pose against the sea at that pose's
  field time (one physics step behind the frame), not at the frame's.
- --wake-check now fails (rc 5) when a window with bodies has no waves,
  the drop makes no ring, or the lake keeps no more than its absorbing
  twin.
- add_immersion: a hull mesh in unbounded water is wholly under, not
  NaN read as dry; new test.
- immersion.h and the roadmap no longer claim exact agreement or smooth
  zeta; the roadmap's lake and sea numbers are re-measured.

* ocean: address review of the no-flux walls

The review measured no-flux walls growing without bound in curved and
thin closed basins. Confirmed: overwriting the ghosts with the image is
an oblique projection, and the water's update it gives is not symmetric
where the image is not an exact mirror or is cut off at the band. None
of the stabilisers tried in a scratch probe (a taper, capping each water
cell's ghost weight, no ghosts near a medial axis, k^2 damping, folding
the fill's transpose back as an orthogonal projection, and partial or
first-layer folds) held every basin while keeping the straight wall's
reflection, so:

- walls = zero (O8a, bit for bit) is the default again; no_flux is opt
  in, its stability limits documented in ewave.h with the measured
  growth and the damping (0.004 /s) that held every basin at 1/30 s.
- New WallsStayBounded: broadband noise in closed basins (disc, island,
  breakwater, straight channel, thin wall) at dt 0.1, 0.25 and 1/30 s.
  Zero walls never exceed their start; no_flux growth is printed; the
  straight channel and thin wall stay level at 1/30 s, and 0.004 /s of
  damping holds every basin there.
- NoFluxWallsAreLossless becomes NoFluxWallsAreNearlyLossless and no
  longer claims stability; it adds the whole-wall straight channel and
  checks energy() against the water-only sum.
- energy() counts the water only (mask > 0): the ghosts are left out
  and, with ghosts, the kinetic part is sum phi (K phi) over the water.
  Without ghosts it is unchanged. height(), phi(), at() and
  EWave::heightTexture() are documented to include the ghost image.
- cvcgl_ewave: scenario 1 adds a round island whose ghosts have
  fractional weights with wall corners zeroed, and checks the GPU
  against the CPU within 3 m of it (a swapped weight channel fails it).
- The band sweep covers 1 cell; the roadmap's O8c block is corrected.

* ocean: a drivable boat in lsystem_coast (O11c)

A 5 m skiff with an outboard, a cvc::physics boat in the debris' world,
floated by the hull mesh it is drawn as. I/J/K/L and the panel's Boat
section drive it through coast.boat.* knobs; C toggles a chase camera
that also brings the sea's wake window along. Its columns feed the wake
window like the debris', and the sea's shader discards water inside the
hull (D5).

--boat-check drives a scripted course and reports speed, turning circle,
heave/pitch/roll on the lee and along the reflecting south-west shore,
and the wake's angle at two speeds; --snap writes frames at given times.

* ocean: EWave's finite() helper is finite_value(), clear of glibc's ::finite

GCC's glibc declares ::finite(double), so inside EWave's member functions an unqualified
finite() found both it and the file's own helper and was ambiguous; MSVC has no ::finite,
so only the Linux lanes failed to build cvcgl_ewave. Rename the helper; nothing else
changes.

* ocean: no-flux walls as a symmetric operator with a symplectic step (O8c)

The ghost-cell walls overwrote the wall cells with the water's mirror image
after each exact step: an oblique projection, unstable wherever the image
was not an exact mirror (a disc grew 31x in 2000 s, a thin wall 1e72x).
They are replaced by a scheme that conserves energy by construction, and
no_flux walls are the default again.

The state lives on the water; R extends it over the window (ghost cells
take their mirror image), R^T folds back, S = R^T G R is symmetric positive
semidefinite for any ghosts and weights, and M is the lumped mass (the row
sums of R^T R, ewave_lumped_mass). Stormer-Verlet in substeps that keep
omega_max dt_s <= 1.8 (ewave_substeps): S <= max(G) M bounds every mode
inside the limit, and the step conserves its modified energy exactly, so
nothing can grow at any dt. G is kappa~ = 4 sin^2(omega dt_s / 2) /
(g dt_s^2), so open water keeps eWave's exact dispersion (with kappa a
straight wall's reflection was 55 % off its even image at dt 0.1 s).
damping_k2, the beach and the sponge act on h through M-contractions;
the global damping on both. Windows without ghosts keep the exact step bit
for bit (the zero-walls pin 0xa4933455f6946eca holds).

Accuracy: the fold carries G's response at every ghost back into the water,
so an image cut short (or two shores' images meeting in a thin wall) shows
at the cut's mirror distance. The default band now reaches as far as the
image does (ghost_cells = 4096), and the weights taper to 0 over 8 cells
near the cuts and seams that remain. No water cell is read by more than 12
ghosts (whole ghosts dropped, farthest first, on CPU and GPU alike).

Measured (Windows): a no-flux channel is the exact Neumann operator
(2.9e-15) and its mode matches Stormer-Verlet's discrete solution to
4e-14; broadband noise in seven closed basins for 20000 steps at omega_max
dt 1.8, 0.25 s and 1/30 s keeps the modified energy within 1.3e-14 and
energy() never above its start; the straight wall matches the even image
to 2.9e-14 without the sponge and 2.2 % with it (6.8 % before), gain 1.90,
slope +1.001; rings in closed ponds lose nothing over 300 s; thin walls
leak 10.8 / 5.7 / 3.0 % at 3 / 6 / 12 m. New no_flux pin
0x40cb161804c270ca (Linux and macOS to be confirmed by CI).

EWave runs the same scheme from the same CPU tables: per substep a fill
pass, the forward butterflies, a multiply pass, the inverse butterflies
and a gather pass (readers in six RGBA32F textures, 1 / M in an R32F one):
4 log2 n + 3 = 35 passes at 256^2, plus one real-space pass a step (36 at
1/30 s, against 34 without walls). It agrees with the CPU to 1e-5 RMS,
reflects crest for crest (2.1 % against the even image) and stays bounded
over a long broadband run. Roadmap section 6's O8c block is rewritten.

* ocean: address review of O11c

lsystem_coast draws the D5 hole from the pose present() posed the hull
with (a group of one in the binding), not a second tracker sample that a
threaded physics step could land between. --boat-check prints the wake
window's depth and depth Froude number; the new knob coast.wake.depth
forces the window's depth, and a deep rerun shows the full-throttle
narrowing is the length Froude number's, not the shallow window's.
--snap no longer puts its tag into a dotted directory name. The roadmap
has coast.boat.enabled's sense right and the depth result.

* ocean: sea_surface keeps its last source in the frame, not a thread_local

The writable-data scan (#1152 made its allowlist a ratchet) refuses process-wide state, and
sea_surface::source kept its last source in a thread_local (O7c, #1159), so every PR's
package-linux release-grpc lane now fails on master's code. The memo moves into the time's
frame, under the mutex the frame already has for its lattice: a frame is the surface at one
time, so the point alone is the key, and as a memo of a pure function it changes no value.
ocean_sea_test (19, pins unchanged) and physics_field_test (22, goldens unchanged) pass; the
exact height-and-velocity pair still costs about what it did (3.8 us, 1.76 us on the lattice).

* ocean: address review of the stable no-flux walls

- The symmetric step's substep no longer follows the caller's dt. kappa~
  and Stormer-Verlet's invariant both depend on it, so a dt that changed
  between steps switched between maps with different invariants and grew
  by parametric resonance (the review: a disc 1e103-fold in 4000 steps of
  0.136 and 0.101 s in turn). A window now has one substep,
  ewave_params::substep (default 1/60 s, capped at 1.8 / omega_max):
  step(dt) runs whole substeps (ewave_substep_count) and carries the rest
  in pending(). The beach, sponge, global damping and damping_k2 act every
  substep for dt_s, so every substep is the same linear map whatever the
  dts. Same on the GPU: the count is made on the host in double, and the
  real-space factors move into the gather pass. New tests
  (VariableStepsAreStable on the CPU, jittered dt in cvcgl_ewave): the
  modified energy holds to 6e-15 under alternating and jittered dt.
- A wall one cell thick is a seam: its nearest water lies on opposite
  sides, so its image tapers to almost 0 instead of holding the front
  water beside the water behind. It leaked 87.6 %; now 40.4 % (zero walls
  41.1 %). AThinWallLeaksLittle covers 1, 2 and 4 cells.
- ewave_wall_ghosts finds each wall cell's nearest water with a distance
  transform, O(n^2) whatever the band (1024^2 set_mask: 0.21-0.25 s,
  against 10 s), ties exact within 32 cells of the shore.
- The GPU gather decodes a reader's cell by truncation (int(cell + 0.5)
  rounded odd indices up past 2^23); the header gives the reader
  textures' memory.
- Docs: stability now holds for any sequence of steps; the 2.2 %
  reflection is the best case where the whole image fits; the mean
  potential's drift where S annihilates constants is documented (not
  gauged: the GPU would need a reduction).
- The no_flux pin is re-measured on Windows: 0x9d1fde2b635d7dbf. The
  zero-walls pin 0xa4933455f6946eca holds.

* ocean: no-flux damping_k2 takes what zero walls take

The symmetric step applied damping_k2 as h <- M^-1 R^T F R h. At F = 1 that
is not the identity: M^-1 R^T R averages each water cell a ghost reads with
the corners round the ghost's mirror point, wherever that point falls between
cells. Run once a substep, the smoothing took lsystem_coast's crater lake's
ring faster under no-flux banks than under zero ones (20 % of the energy left
10 s after the drop, against 55 %).

The filter is now h <- h - M^-1 R^T (1 - F) R h (1 - F as -expm1, and as
x (1 - x/2) below 1e-3 in the GPU's float): the same beside a straight wall,
still self-adjoint under M with eigenvalues in (0, 1], and the identity as F
goes to 1. In a disc 36 m across with damping_k2 2e-3, the energy left after
10 s is 75.7 % under no-flux walls against 75.5 % under zero walls (the first
form: 49.3 %); at damping_k2 1e-15 the heights match the undamped run to
1.5e-13 (the first form: 99 % off). New test:
DampingK2TakesTheSameShareWhateverTheWalls. The no-flux digest pin is
re-measured.

lsystem_coast's lake now keeps 48 % after 10 s (13 % with absorbing banks).
The rest of the gap to 55 % is the check's reading, the water's sum of h^2
without M, which sits near 1 / mean(M) of the conserved energy once the ring
reaches the banks. The roadmap's O8c and O9 blocks have the numbers.

* ocean: back out #1193's source memo, superseded by #1181

* ocean: the sea's height for its wind (O2b)

The cascades' sea was about 2.3 times JONSWAP's significant height for
its wind, and lsystem_coast drew it at wave_amp 1.2: 5.7 m Hs at 9 m/s
where JONSWAP gives 2.2 m. Two errors in O2's library:

- h0 was twice its size. A texel's mode is h0(k) e^(iwt) +
  conj h0(-k) e^(-iwt), so its share of the surface's variance is
  E|h0(k)|^2 + E|h0(-k)|^2. With h0 = g sqrt(S) dk and E|g|^2 = 2 that
  is 4 S dk^2. h0 is now g sqrt(S) dk / 2.
- The spread's cos^2 part, (2/pi) cos^2, spanned the whole turn
  (ABYSSAL's), where it integrates to 2, with a lobe upwind. It now
  covers the downwind half, so the spread integrates to 1.

The cascades now hold JONSWAP's Hs within 2 % from 4 to 25 m/s, and
the sea they make is within 5 % over four seeds. lsystem_coast's
wave_amp defaults to 1, and --boat-check sets only the wind (4 m/s,
0.54 m Hs); it also passes at the default 9 m/s now.

New tests OceanH0.TheCascadesHoldTheWindSeasHeight and
OceanSea.TheSeaHasTheWindsHeight; the spread, variance and h0-energy
tests expect the corrected values; five digest pins move with the sea.

* ocean_sea_test: drop the memo test the master merge doubled

* ocean_ewave_test: the basin stability runs take a twentieth of the steps in unoptimized builds

Ewave.WallsAreStable and Ewave.VariableStepsAreStable step a 64^2 basin tens of
thousands of times: 83-129 s and 29-42 s in a Release build, and past ctest's
300 s in the Debug package lanes (package-linux libcvc-debug and -debug-grpc on
#1194), which run these tests about 10 times slower.

As #908 did for the stepped mesher tests, gated on the optimizer rather than
NDEBUG: an unoptimized build divides run_basin's step count and its energy()
sampling interval by kBasinScale (20), so each quarter still averages as many
samples. The printouts report the steps actually run.

Forced to 20 in a Release build, both pass in 4.5 s and 1.7 s: modified energy
within 8.2e-15 (limit 1e-9), last-quarter drift at most 0.0008 (limit 0.005),
damped runs end at 1.6e-6 of their start (limit 0.5). Optimized builds are
unchanged (18/18 ocean_ewave_test, full counts).

* ocean: whitecaps cover Monahan's share for the wind (O5, first part)

On the calibrated sea (O2b) the wave foam's fixed threshold drew nothing: the
least of the cascades' Jacobians over lsystem_coast's tile is 0.49-0.59 at every
wind from 4 to 25 m/s, so foam_bias 0.48 met no water. Whitecaps should cover
W = min(3.84e-6 U^3.41, 0.16) of the sea (Monahan and O'Muircheartaigh 1980):
0.04 % at 4 m/s, 0.69 % at 9, 3.9 % at 15, 16 % at 25.

cvc::ocean::foam_field (inc/cvc/ocean/whitecaps.h) evolves the cascades' h0 on
the CPU as OceanFFT does, takes the least J at the drawn grid's vertices, linear
over its triangles, at two times, weighs each sample by its share of the drawn
surface (|J|), and bisects for the bias whose mean foam is W. monahan_coverage
gives W.

The shader's ramp narrows from 0.85 to 0.1 (coast.water.foam_ramp): the least J
sits only ~0.35 under its mean, so a wide ramp meets W with a faint veil (at
9 m/s, faint foam on 51 % of the sea with 0.85, 14 % with ABYSSAL's 0.3, none of
it half white). Each fragment's J is shifted by fray x (noise - 0.5) on the
water's rest position (coast.water.foam_fray, 0.12), so patches have ragged
edges instead of the straight lines J makes across a 2 m triangle; the bias
models the fray by 16 quantiles of the noise's distribution.

lsystem_coast finds the bias at start-up and again once h0, the chop, the ramp,
the fray or coast.water.whitecaps (a scale on W, the panel's "whitecaps" slider)
has changed and held for 10 frames. coast.water.foam_bias >= 0 still fixes it.
On its sea the bias runs 0.747 / 0.796 / 0.822 / 0.856 at 4 / 9 / 15 / 25 m/s,
with 0.68-0.95 of W at least half white; a field takes 110-250 ms (Release).

Tests (ocean_spectrum_test): OceanWhitecaps.TheFoamFieldsJacobianIsOceanFFTs
(one wave: J = 1 - 2alk cos k.x exactly), MonahansCoverage, and
TheBiasGivesMonahansShareOnTheCoastsSea. Roadmap section 8 E0b has the numbers.
The persistent foam of section 10.2 is still to do.

* cvcGL: the GPU ocean in the library (OceanFFT, its butterflies, EWave, WakeSource)

The ABYSSAL port's sources in src/cvcGL/ocean were compiled straight into
lsystem_coast and the four cvcGL ocean tests, so nothing else could use them.
O15 (OCEAN-AND-WEATHER-ROADMAP.md section 11.2) draws the sea from an Ariadne
node, which lives in cvcGL, so they join the library: a GLOB of ocean/*.cpp,
the directory a private include of cvcGL. The tests and lsystem_coast link
them from cvcGL now and keep the include directory (the headers stay private).
The examples always link the in-tree cvcGL target, the standalone
libcvc-examples recipe included, so the browser gallery is unaffected.

The shaders' namespace-scope strings become const pointers
(const char *const), so the library gains no writable data for the
writable-data scan. clang-format moved each one's first literal onto its own
line; the strings are unchanged.

Checked (MSVC Release, full build): cvcgl_ocean_fft, cvcgl_ocean_band,
cvcgl_ewave and cvcgl_wake pass (none skipped), and lsystem_coast's
--boat-check, --debris-check --wake-check and --shore-check pass.

* ariadne: the water node, terrain_lab.ari's sea, lakes and ponds as the GPU FFT ocean (O15, drawing)

A `water` scene node (src/cvcGL/ariadne/water_node.cpp, registered with the
cvcGL extensions) draws everything below `level` on a ground (`world:` a
generated_world, or `ground:` a height-field node) as lsystem_coast's GPU sea:
three OceanFFT cascades built from cvc::ocean::build_h0 for the wind, each
fading out over `shore_fade` metres of depth toward the shore, and its
Fresnel shading, shallows tinted by depth, and frayed Jacobian whitecaps.

- Meshes of its own, not the world's flat water rungs (5 m cells and coarser,
  longer than the short cascade's waves): a near grid +-192 m around the
  camera, a vertex every 2 m, displaced and faded to flat at its edge, moving
  with the camera by whole cells; and a flat far grid over the ground that gives
  way inside the near one. Dry fragments are discarded against a
  HeightFieldTexture of the ground, sampled per fragment. Both stay out of the
  scene's bounds, so the ground frames the view. terrain_lab's world sets
  `water: 0`.
- Whitecaps cover Monahan's share for the wind: the threshold comes from
  cvc::ocean::foam_field on the near grid's vertices, found again once the
  wind, chop, ramp, fray or water.whitecaps have held for 10 frames
  (water.foam_bias >= 0 fixes it by hand).
- The world's edge: when the ground's whole rim is under water (a
  generated_world with `edge: shore`, an island), the sea goes on `outer` (6 km,
  as world::outer_sea) past it; otherwise both grids clip to the ground's
  rectangle (a wall, or the world falling away). It is checked again after
  every regenerate, so the Edge picker switches it live.
- disableCoordinateShiftScale is set before the meshes' first draw: set after
  it, the far grid kept a shifted buffer and its fragments missed the bed.

Keys water.*: wind_speed, wind_dir, fetch, chop, wave_amp, whitecaps,
foam_bias, foam_ramp, foam_fray, shore_fade. Panel: water_controls.ari (INDEX
entry); terrain_lab.ari includes it (Settings > Water).

Tests: cvcgl_ariadne_realize builds a generated world plus a water node at
level 0 (a rim partly dry: the far grid ends at the ground) and at 500 m (a
rim under water: 6 km past), and checks the meshes, the bounds, the seeded keys
and the flat fallback without a window; ariadne_loader_test checks the new
component (229 pass). Rendered offscreen with arigl: terrain_lab's lakes and
sea (wall edge), and the shore edge merged in locally from feat/world-gym: the
island, the sea out to the horizon, and the near waves fading into it.
Floating bodies are the next part.
transfix added a commit that referenced this pull request Nov 16, 2026
#1255)

* ocean: eWave on the CPU, a deterministic window of waves bodies make (O8a)

cvc::ocean::ewave runs Tessendorf's eWave (roadmap C1, C3, C5) on an
n x n window: h and phi packed as one complex field, one forward and one
inverse FFT a step, each wavenumber moved on exactly for any dt in one
depth, then the mask, the edge sponge and the sources in real space.
det math and fft.h, built without FMA contraction, so a window gives
the same bits on every platform; its digest is pinned.

ocean_ewave_test checks the exact mode oscillation, energy conservation,
the ring's group velocity and isotropy, reflection off a straight wall,
the sponge, shallow-water speed, the Kelvin wake angle at two speeds,
the digest and the refusals, and prints the step's cost.

* physics: the hull model (O11a), forces per triangle against the free surface

A dynamic body may carry a hull (body_desc::hull, cvc/physics/hull.h): a
closed triangle list apart from its collision shape. Fluid fields push on
its triangles in place of the 8-cells-per-side sample: each triangle is
split at the waterline (the free surface's height at its vertices, or the
box top), and its submerged part feels hydrostatic pressure at its centre
of pressure, ITTC-57 friction, pressure drag growing with (v.n)^2, a
bounded added-mass slamming term and the field's damping in heave. The
velocity terms are integrated implicitly in their own linear and rotational
rates. det:: math, a fixed order.

A world with hulls saves a CVCHULL1 section (each hull's digest and its
triangles' last wetted areas), so state_hash covers them and restore
refuses other hulls; a world without hulls saves and hashes as before.
physics_hull_test covers floating, righting, towing resistance, a drop, a
light hull, heave on a swell and the state, and pins a hull scene's hash.

* physics: add_force_at and add_torque on world (O10)

world::add_force_at(id, force, point) applies a world-frame force at a
world-frame point, so off the centre of mass it also torques the body;
world::add_torque(id, torque) applies a world-frame torque. Both check
that every value is finite and otherwise act as add_force does: through
the next step only, waking a sleeping body, refusing an unknown id.
New backend_impl calls carry them to Jolt (AddForce at a point, moved to
the engine's floating-origin frame, and AddTorque) and to the null
backend, which checks the id. pycvc binds both.

Tests in physics_world_test check the spin against r x F dt / I, that a
force at the centre of mass gives add_force's state hash, that a torque
does not translate, that both wake a sleeping body, and the refusals.
This is roadmap item D1 of OCEAN-AND-WEATHER-ROADMAP.md.

* physics: address review of add_force_at and add_torque (O10)

pycvc's add_force_at refuses a point of None instead of reading it as the
world origin. world.h and PHYSICS_API.md say body_state::position is the
body's origin, not its centre of mass, which differs for a hull or a
vehicle chassis; a new test shows a force at a hull's origin torques it.
ForceAtAndTorqueAreChecked now covers a kinematic body, and roadmap 1.2
marks off-centre forces done.

* physics: address review of the hull model (O11a)

The field's damping on a hull now sums to the cells' c V_sub, shared among
the downward faces by the water column over each; upward faces under water
took their column too, so a submerged hull was damped more the deeper it
went. The horizontal drag is scaled in the rate without the damping, so the
damping no longer slows a towed hull. add_body keeps a private copy of the
hull mesh, so the cached normals, wetted areas and digest always describe
what is simulated. The torque's inertia estimate also takes the collision
shape's where that is lower.

New tests: the first-step torque on a heeled box is the wall-sided righting
moment (12 and 432 triangles), a sinking hull keeps its speed at depth, and
changing the caller's mesh after add_body changes nothing. The towing test
now checks the absolute resistance. The hull scene's pinned hash is
re-measured (2f71a1fe229afa75); the docs say CI has yet to confirm it.

* ocean: address review of the CPU eWave (O8a)

- A beach mask value is now a damping rate, beach_rate (1 - m), applied as
  exp(-rate dt) like the sponge, so a beach absorbs the same share per
  second at any step size. Land (m = 0) is still zeroed every step. New
  test: a beach band leaves 68.95 / 68.96 / 68.89 % of a ring's energy
  after 10 s at 30, 60 and 10 Hz. The pinned digest moves to
  0xa4933455f6946eca.
- New test for a wall band with open water behind it: a 3 m band lets
  through 4.6 % of the incident amplitude (held below 6 %), a 6 m band less.
- The standing-mode test computes omega from the dispersion relation
  itself instead of the library's omega().
- The Kelvin test runs the source 140 m in a 512^2 window with an 8 s ramp,
  so the rows it reads are steady wake. It checks the edge at 30, 40 and
  50 % of the row maximum, at 2.5 and 3.0 m/s.
- Roadmap section 6: the as-built block gets the new measurements, a
  labelled diagnostic for the wrap-around share of thin-wall leakage, and a
  note that the update is still unchecked against the eWave paper.

* ocean: eWave on the GPU, the window in cvcGL (O8b)

EWave (src/cvcGL/ocean) runs the CPU eWave's window in float with
fragment passes: z = h + i phi in RG32F, the forward FFT, an update
pass that separates H and PHI at k and -k and applies the exact
per-mode update and damping, the inverse FFT, and a real-space pass
for the normalisation, the mask's beach, the sponge and land. 34
passes a step at 256^2. Sources go into h at once, as on the CPU.

The butterfly LUT, pass and pass setup move from OceanFFT.cpp into
OceanButterfly.{h,cpp}; the forward transform conjugates the twiddle
in the shader. OceanFFT's output is unchanged.

cvcgl_ewave runs one scenario on both windows (GPU vs CPU within
2.3e-5 of the RMS field), the wall test on the GPU, and the passes and
GPU time per step.

* ocean: address review of the GPU eWave (O8b)

Count the passes step() renders instead of adding passesPerStep()'s
formula: OceanButterfly counts its own passes and EWave counts the update,
real-space and source passes, so cvcgl_ewave's 34-pass check (and a new
one-pass check for addDrop) measures something.

Say in EWave.h that only the mask is held before init(); setState, addDrop,
addHeights and step do nothing until init() succeeds.

Name OceanButterfly.{h,cpp} and the cvcgl_ocean_band and cvcgl_ewave tests
in the ABYSSAL notice, and correct roadmap section 6's Cost paragraph: a
cascade is 35 passes, so three are 105 and eWave adds about 32 % by pass
count, not the +60 % the old count of 57 gave.

* physics: boats, a propeller and rudder applied every step (O11b)

world::add_boat adds a hull body with a propeller (thrust falling off
with the inflow, only while under the free surface; an optional outboard
that vectors it) and a rudder (lift to the stall, then a flat plate, and
drag, from the flow past it), driven through first-order actuators by
set_boat_controls. The forces go through add_force_at before each engine
step, in boat id order, with det:: math. A boat's description digest,
controls, actuators and last forces are a CVCBOAT1 save section; a world
without boats saves and hashes as before.

physics_boat_test checks the thrust-resistance balance at terminal
speed, backing, steady turning circles against rudder angle, a dry
propeller, an outboard at low speed, pitching on a swell, the state, and
pins a boat scene's hash (measured on Windows; CI confirms elsewhere).

* physics: address review of O11b

Document boat_state::water_velocity as the water's under or at the centre of mass (0 only where no fluid covers it) and boat_state::inflow as measured along the propeller's ahead direction. Correct the restore() claim: the boat section is checked after the engine is restored, so a refused state leaves the boats unchanged but not the bodies.

* ocean: eWave walls that reflect a crest as a crest (O8c)

O8's mask zeroed h and phi on wall cells each step: a Dirichlet wall,
under which a crest comes back as a trough. A vertical wall or cliff is
no-flux (d phi / dn = 0), about which h and phi are even, so a crest comes
back as a crest. Walls are now no-flux by default, by ghost cells (the
image method), on the CPU and the GPU.

cvc::ocean::ewave_wall_ghosts finds, at set_mask, the nearest water cell q
of each wall cell p within the ghost band (exact integer search, no wrap),
mirrors p across the shore half a cell from q (p' = p + 2 s n), and stores
p' as bilinear corners restricted to water with renormalised weights. Each
step, after the real-space pass, and after each source, the ghost cells
take h and phi from their corners. A straight wall is exact (a no-flux
channel's own mode oscillates at omega to 3e-14); staircase and curved
walls are first order.

ewave_params::walls picks no_flux (the default) or zero (O8a's wall, bit
for bit: the digest leaves both new fields out under zero, so the pin
0xa4933455f6946eca stands). ghost_cells defaults to 16, the knee of the
measured reflection error (the spectral operator is not local, so the
image's cut at the band shows as about 1 / band). A no_flux pin is added,
0xfc278a415ad67d3f, measured on Windows; CI checks Linux and macOS.

EWave (cvcGL) runs the same fill as one more pass when there are ghosts
(35 a step, 34 without), from the CPU's own table uploaded as an RG32F
corner texture and an RGBA32F weight texture, fetching the four corners
itself. On the wall test it gives the even image to 6.7 % and agrees with
the CPU to 6.1e-5 RMS.

ocean_ewave_test: the straight-wall test now checks both kinds (the even
image to 6.8 % RMS under no_flux, the odd one to 18.8 % under zero, the
reflection's sign), plus a no-flux channel mode, lossless closed basins
(straight, 45-degree, disc: no growth over 300 s), the thin-wall leak
under no_flux, and set_mask's cost. AThinWallLeaksLittle and the digest
test pin their O8a claims to walls = zero. Roadmap section 6 gains the
"As built (O8c)" block with the measurements.

* ocean: bodies make waves (O9)

The shared immersion code, cvc/physics/immersion.h: a body's columns of
immersed depth over a grid window from its shape (box, sphere, convex
hull, or its hull mesh), its pose and the water, as the field step
immerses it; standard library, the same bits on every platform (pinned
in physics_immersion_test, measured on Windows; CI checks Linux/macOS).

WakeSource turns it into EWave's sources, -(zeta(t) - zeta(t - dt)),
and EWave gains a one-pass shift so a window can follow something.
cvcgl_wake checks the sources, the shift, a box footprint's Kelvin wake
read from the GPU (19.3-20.0 deg at 2.5 and 3 m/s) and a rock's shadow.

lsystem_coast draws the debris' wakes: a 128 m sea window on the
camera's target (D3) with a mask from the shore, and one on the crater
lake whose banks reflect; height, slope and foam in both water shaders;
--wake-check reports the windows' energy and a lake drop's ring.

* ocean: address review of O9

- A teleported body (the wake check's drop, "drop them again") no
  longer leaves a false ring where it floated: the sources only record
  the columns until the drawn poses are the ones after it.
- The sea sources cut each drawn pose against the sea at that pose's
  field time (one physics step behind the frame), not at the frame's.
- --wake-check now fails (rc 5) when a window with bodies has no waves,
  the drop makes no ring, or the lake keeps no more than its absorbing
  twin.
- add_immersion: a hull mesh in unbounded water is wholly under, not
  NaN read as dry; new test.
- immersion.h and the roadmap no longer claim exact agreement or smooth
  zeta; the roadmap's lake and sea numbers are re-measured.

* ocean: address review of the no-flux walls

The review measured no-flux walls growing without bound in curved and
thin closed basins. Confirmed: overwriting the ghosts with the image is
an oblique projection, and the water's update it gives is not symmetric
where the image is not an exact mirror or is cut off at the band. None
of the stabilisers tried in a scratch probe (a taper, capping each water
cell's ghost weight, no ghosts near a medial axis, k^2 damping, folding
the fill's transpose back as an orthogonal projection, and partial or
first-layer folds) held every basin while keeping the straight wall's
reflection, so:

- walls = zero (O8a, bit for bit) is the default again; no_flux is opt
  in, its stability limits documented in ewave.h with the measured
  growth and the damping (0.004 /s) that held every basin at 1/30 s.
- New WallsStayBounded: broadband noise in closed basins (disc, island,
  breakwater, straight channel, thin wall) at dt 0.1, 0.25 and 1/30 s.
  Zero walls never exceed their start; no_flux growth is printed; the
  straight channel and thin wall stay level at 1/30 s, and 0.004 /s of
  damping holds every basin there.
- NoFluxWallsAreLossless becomes NoFluxWallsAreNearlyLossless and no
  longer claims stability; it adds the whole-wall straight channel and
  checks energy() against the water-only sum.
- energy() counts the water only (mask > 0): the ghosts are left out
  and, with ghosts, the kinetic part is sum phi (K phi) over the water.
  Without ghosts it is unchanged. height(), phi(), at() and
  EWave::heightTexture() are documented to include the ghost image.
- cvcgl_ewave: scenario 1 adds a round island whose ghosts have
  fractional weights with wall corners zeroed, and checks the GPU
  against the CPU within 3 m of it (a swapped weight channel fails it).
- The band sweep covers 1 cell; the roadmap's O8c block is corrected.

* ocean: a drivable boat in lsystem_coast (O11c)

A 5 m skiff with an outboard, a cvc::physics boat in the debris' world,
floated by the hull mesh it is drawn as. I/J/K/L and the panel's Boat
section drive it through coast.boat.* knobs; C toggles a chase camera
that also brings the sea's wake window along. Its columns feed the wake
window like the debris', and the sea's shader discards water inside the
hull (D5).

--boat-check drives a scripted course and reports speed, turning circle,
heave/pitch/roll on the lee and along the reflecting south-west shore,
and the wake's angle at two speeds; --snap writes frames at given times.

* ocean: EWave's finite() helper is finite_value(), clear of glibc's ::finite

GCC's glibc declares ::finite(double), so inside EWave's member functions an unqualified
finite() found both it and the file's own helper and was ambiguous; MSVC has no ::finite,
so only the Linux lanes failed to build cvcgl_ewave. Rename the helper; nothing else
changes.

* ocean: no-flux walls as a symmetric operator with a symplectic step (O8c)

The ghost-cell walls overwrote the wall cells with the water's mirror image
after each exact step: an oblique projection, unstable wherever the image
was not an exact mirror (a disc grew 31x in 2000 s, a thin wall 1e72x).
They are replaced by a scheme that conserves energy by construction, and
no_flux walls are the default again.

The state lives on the water; R extends it over the window (ghost cells
take their mirror image), R^T folds back, S = R^T G R is symmetric positive
semidefinite for any ghosts and weights, and M is the lumped mass (the row
sums of R^T R, ewave_lumped_mass). Stormer-Verlet in substeps that keep
omega_max dt_s <= 1.8 (ewave_substeps): S <= max(G) M bounds every mode
inside the limit, and the step conserves its modified energy exactly, so
nothing can grow at any dt. G is kappa~ = 4 sin^2(omega dt_s / 2) /
(g dt_s^2), so open water keeps eWave's exact dispersion (with kappa a
straight wall's reflection was 55 % off its even image at dt 0.1 s).
damping_k2, the beach and the sponge act on h through M-contractions;
the global damping on both. Windows without ghosts keep the exact step bit
for bit (the zero-walls pin 0xa4933455f6946eca holds).

Accuracy: the fold carries G's response at every ghost back into the water,
so an image cut short (or two shores' images meeting in a thin wall) shows
at the cut's mirror distance. The default band now reaches as far as the
image does (ghost_cells = 4096), and the weights taper to 0 over 8 cells
near the cuts and seams that remain. No water cell is read by more than 12
ghosts (whole ghosts dropped, farthest first, on CPU and GPU alike).

Measured (Windows): a no-flux channel is the exact Neumann operator
(2.9e-15) and its mode matches Stormer-Verlet's discrete solution to
4e-14; broadband noise in seven closed basins for 20000 steps at omega_max
dt 1.8, 0.25 s and 1/30 s keeps the modified energy within 1.3e-14 and
energy() never above its start; the straight wall matches the even image
to 2.9e-14 without the sponge and 2.2 % with it (6.8 % before), gain 1.90,
slope +1.001; rings in closed ponds lose nothing over 300 s; thin walls
leak 10.8 / 5.7 / 3.0 % at 3 / 6 / 12 m. New no_flux pin
0x40cb161804c270ca (Linux and macOS to be confirmed by CI).

EWave runs the same scheme from the same CPU tables: per substep a fill
pass, the forward butterflies, a multiply pass, the inverse butterflies
and a gather pass (readers in six RGBA32F textures, 1 / M in an R32F one):
4 log2 n + 3 = 35 passes at 256^2, plus one real-space pass a step (36 at
1/30 s, against 34 without walls). It agrees with the CPU to 1e-5 RMS,
reflects crest for crest (2.1 % against the even image) and stays bounded
over a long broadband run. Roadmap section 6's O8c block is rewritten.

* ocean: address review of O11c

lsystem_coast draws the D5 hole from the pose present() posed the hull
with (a group of one in the binding), not a second tracker sample that a
threaded physics step could land between. --boat-check prints the wake
window's depth and depth Froude number; the new knob coast.wake.depth
forces the window's depth, and a deep rerun shows the full-throttle
narrowing is the length Froude number's, not the shallow window's.
--snap no longer puts its tag into a dotted directory name. The roadmap
has coast.boat.enabled's sense right and the depth result.

* ocean: sea_surface keeps its last source in the frame, not a thread_local

The writable-data scan (#1152 made its allowlist a ratchet) refuses process-wide state, and
sea_surface::source kept its last source in a thread_local (O7c, #1159), so every PR's
package-linux release-grpc lane now fails on master's code. The memo moves into the time's
frame, under the mutex the frame already has for its lattice: a frame is the surface at one
time, so the point alone is the key, and as a memo of a pure function it changes no value.
ocean_sea_test (19, pins unchanged) and physics_field_test (22, goldens unchanged) pass; the
exact height-and-velocity pair still costs about what it did (3.8 us, 1.76 us on the lattice).

* ocean: address review of the stable no-flux walls

- The symmetric step's substep no longer follows the caller's dt. kappa~
  and Stormer-Verlet's invariant both depend on it, so a dt that changed
  between steps switched between maps with different invariants and grew
  by parametric resonance (the review: a disc 1e103-fold in 4000 steps of
  0.136 and 0.101 s in turn). A window now has one substep,
  ewave_params::substep (default 1/60 s, capped at 1.8 / omega_max):
  step(dt) runs whole substeps (ewave_substep_count) and carries the rest
  in pending(). The beach, sponge, global damping and damping_k2 act every
  substep for dt_s, so every substep is the same linear map whatever the
  dts. Same on the GPU: the count is made on the host in double, and the
  real-space factors move into the gather pass. New tests
  (VariableStepsAreStable on the CPU, jittered dt in cvcgl_ewave): the
  modified energy holds to 6e-15 under alternating and jittered dt.
- A wall one cell thick is a seam: its nearest water lies on opposite
  sides, so its image tapers to almost 0 instead of holding the front
  water beside the water behind. It leaked 87.6 %; now 40.4 % (zero walls
  41.1 %). AThinWallLeaksLittle covers 1, 2 and 4 cells.
- ewave_wall_ghosts finds each wall cell's nearest water with a distance
  transform, O(n^2) whatever the band (1024^2 set_mask: 0.21-0.25 s,
  against 10 s), ties exact within 32 cells of the shore.
- The GPU gather decodes a reader's cell by truncation (int(cell + 0.5)
  rounded odd indices up past 2^23); the header gives the reader
  textures' memory.
- Docs: stability now holds for any sequence of steps; the 2.2 %
  reflection is the best case where the whole image fits; the mean
  potential's drift where S annihilates constants is documented (not
  gauged: the GPU would need a reduction).
- The no_flux pin is re-measured on Windows: 0x9d1fde2b635d7dbf. The
  zero-walls pin 0xa4933455f6946eca holds.

* ocean: no-flux damping_k2 takes what zero walls take

The symmetric step applied damping_k2 as h <- M^-1 R^T F R h. At F = 1 that
is not the identity: M^-1 R^T R averages each water cell a ghost reads with
the corners round the ghost's mirror point, wherever that point falls between
cells. Run once a substep, the smoothing took lsystem_coast's crater lake's
ring faster under no-flux banks than under zero ones (20 % of the energy left
10 s after the drop, against 55 %).

The filter is now h <- h - M^-1 R^T (1 - F) R h (1 - F as -expm1, and as
x (1 - x/2) below 1e-3 in the GPU's float): the same beside a straight wall,
still self-adjoint under M with eigenvalues in (0, 1], and the identity as F
goes to 1. In a disc 36 m across with damping_k2 2e-3, the energy left after
10 s is 75.7 % under no-flux walls against 75.5 % under zero walls (the first
form: 49.3 %); at damping_k2 1e-15 the heights match the undamped run to
1.5e-13 (the first form: 99 % off). New test:
DampingK2TakesTheSameShareWhateverTheWalls. The no-flux digest pin is
re-measured.

lsystem_coast's lake now keeps 48 % after 10 s (13 % with absorbing banks).
The rest of the gap to 55 % is the check's reading, the water's sum of h^2
without M, which sits near 1 / mean(M) of the conserved energy once the ring
reaches the banks. The roadmap's O8c and O9 blocks have the numbers.

* ocean: back out #1193's source memo, superseded by #1181

* ocean: the sea's height for its wind (O2b)

The cascades' sea was about 2.3 times JONSWAP's significant height for
its wind, and lsystem_coast drew it at wave_amp 1.2: 5.7 m Hs at 9 m/s
where JONSWAP gives 2.2 m. Two errors in O2's library:

- h0 was twice its size. A texel's mode is h0(k) e^(iwt) +
  conj h0(-k) e^(-iwt), so its share of the surface's variance is
  E|h0(k)|^2 + E|h0(-k)|^2. With h0 = g sqrt(S) dk and E|g|^2 = 2 that
  is 4 S dk^2. h0 is now g sqrt(S) dk / 2.
- The spread's cos^2 part, (2/pi) cos^2, spanned the whole turn
  (ABYSSAL's), where it integrates to 2, with a lobe upwind. It now
  covers the downwind half, so the spread integrates to 1.

The cascades now hold JONSWAP's Hs within 2 % from 4 to 25 m/s, and
the sea they make is within 5 % over four seeds. lsystem_coast's
wave_amp defaults to 1, and --boat-check sets only the wind (4 m/s,
0.54 m Hs); it also passes at the default 9 m/s now.

New tests OceanH0.TheCascadesHoldTheWindSeasHeight and
OceanSea.TheSeaHasTheWindsHeight; the spread, variance and h0-energy
tests expect the corrected values; five digest pins move with the sea.

* ocean_sea_test: drop the memo test the master merge doubled

* ocean_ewave_test: the basin stability runs take a twentieth of the steps in unoptimized builds

Ewave.WallsAreStable and Ewave.VariableStepsAreStable step a 64^2 basin tens of
thousands of times: 83-129 s and 29-42 s in a Release build, and past ctest's
300 s in the Debug package lanes (package-linux libcvc-debug and -debug-grpc on
#1194), which run these tests about 10 times slower.

As #908 did for the stepped mesher tests, gated on the optimizer rather than
NDEBUG: an unoptimized build divides run_basin's step count and its energy()
sampling interval by kBasinScale (20), so each quarter still averages as many
samples. The printouts report the steps actually run.

Forced to 20 in a Release build, both pass in 4.5 s and 1.7 s: modified energy
within 8.2e-15 (limit 1e-9), last-quarter drift at most 0.0008 (limit 0.005),
damped runs end at 1.6e-6 of their start (limit 0.5). Optimized builds are
unchanged (18/18 ocean_ewave_test, full counts).

* ocean: whitecaps cover Monahan's share for the wind (O5, first part)

On the calibrated sea (O2b) the wave foam's fixed threshold drew nothing: the
least of the cascades' Jacobians over lsystem_coast's tile is 0.49-0.59 at every
wind from 4 to 25 m/s, so foam_bias 0.48 met no water. Whitecaps should cover
W = min(3.84e-6 U^3.41, 0.16) of the sea (Monahan and O'Muircheartaigh 1980):
0.04 % at 4 m/s, 0.69 % at 9, 3.9 % at 15, 16 % at 25.

cvc::ocean::foam_field (inc/cvc/ocean/whitecaps.h) evolves the cascades' h0 on
the CPU as OceanFFT does, takes the least J at the drawn grid's vertices, linear
over its triangles, at two times, weighs each sample by its share of the drawn
surface (|J|), and bisects for the bias whose mean foam is W. monahan_coverage
gives W.

The shader's ramp narrows from 0.85 to 0.1 (coast.water.foam_ramp): the least J
sits only ~0.35 under its mean, so a wide ramp meets W with a faint veil (at
9 m/s, faint foam on 51 % of the sea with 0.85, 14 % with ABYSSAL's 0.3, none of
it half white). Each fragment's J is shifted by fray x (noise - 0.5) on the
water's rest position (coast.water.foam_fray, 0.12), so patches have ragged
edges instead of the straight lines J makes across a 2 m triangle; the bias
models the fray by 16 quantiles of the noise's distribution.

lsystem_coast finds the bias at start-up and again once h0, the chop, the ramp,
the fray or coast.water.whitecaps (a scale on W, the panel's "whitecaps" slider)
has changed and held for 10 frames. coast.water.foam_bias >= 0 still fixes it.
On its sea the bias runs 0.747 / 0.796 / 0.822 / 0.856 at 4 / 9 / 15 / 25 m/s,
with 0.68-0.95 of W at least half white; a field takes 110-250 ms (Release).

Tests (ocean_spectrum_test): OceanWhitecaps.TheFoamFieldsJacobianIsOceanFFTs
(one wave: J = 1 - 2alk cos k.x exactly), MonahansCoverage, and
TheBiasGivesMonahansShareOnTheCoastsSea. Roadmap section 8 E0b has the numbers.
The persistent foam of section 10.2 is still to do.

* cvcGL: the GPU ocean in the library (OceanFFT, its butterflies, EWave, WakeSource)

The ABYSSAL port's sources in src/cvcGL/ocean were compiled straight into
lsystem_coast and the four cvcGL ocean tests, so nothing else could use them.
O15 (OCEAN-AND-WEATHER-ROADMAP.md section 11.2) draws the sea from an Ariadne
node, which lives in cvcGL, so they join the library: a GLOB of ocean/*.cpp,
the directory a private include of cvcGL. The tests and lsystem_coast link
them from cvcGL now and keep the include directory (the headers stay private).
The examples always link the in-tree cvcGL target, the standalone
libcvc-examples recipe included, so the browser gallery is unaffected.

The shaders' namespace-scope strings become const pointers
(const char *const), so the library gains no writable data for the
writable-data scan. clang-format moved each one's first literal onto its own
line; the strings are unchanged.

Checked (MSVC Release, full build): cvcgl_ocean_fft, cvcgl_ocean_band,
cvcgl_ewave and cvcgl_wake pass (none skipped), and lsystem_coast's
--boat-check, --debris-check --wake-check and --shore-check pass.

* ariadne: the water node, terrain_lab.ari's sea, lakes and ponds as the GPU FFT ocean (O15, drawing)

A `water` scene node (src/cvcGL/ariadne/water_node.cpp, registered with the
cvcGL extensions) draws everything below `level` on a ground (`world:` a
generated_world, or `ground:` a height-field node) as lsystem_coast's GPU sea:
three OceanFFT cascades built from cvc::ocean::build_h0 for the wind, each
fading out over `shore_fade` metres of depth toward the shore, and its
Fresnel shading, shallows tinted by depth, and frayed Jacobian whitecaps.

- Meshes of its own, not the world's flat water rungs (5 m cells and coarser,
  longer than the short cascade's waves): a near grid +-192 m around the
  camera, a vertex every 2 m, displaced and faded to flat at its edge, moving
  with the camera by whole cells; and a flat far grid over the ground that gives
  way inside the near one. Dry fragments are discarded against a
  HeightFieldTexture of the ground, sampled per fragment. Both stay out of the
  scene's bounds, so the ground frames the view. terrain_lab's world sets
  `water: 0`.
- Whitecaps cover Monahan's share for the wind: the threshold comes from
  cvc::ocean::foam_field on the near grid's vertices, found again once the
  wind, chop, ramp, fray or water.whitecaps have held for 10 frames
  (water.foam_bias >= 0 fixes it by hand).
- The world's edge: when the ground's whole rim is under water (a
  generated_world with `edge: shore`, an island), the sea goes on `outer` (6 km,
  as world::outer_sea) past it; otherwise both grids clip to the ground's
  rectangle (a wall, or the world falling away). It is checked again after
  every regenerate, so the Edge picker switches it live.
- disableCoordinateShiftScale is set before the meshes' first draw: set after
  it, the far grid kept a shifted buffer and its fragments missed the bed.

Keys water.*: wind_speed, wind_dir, fetch, chop, wave_amp, whitecaps,
foam_bias, foam_ramp, foam_fray, shore_fade. Panel: water_controls.ari (INDEX
entry); terrain_lab.ari includes it (Settings > Water).

Tests: cvcgl_ariadne_realize builds a generated world plus a water node at
level 0 (a rim partly dry: the far grid ends at the ground) and at 500 m (a
rim under water: 6 km past), and checks the meshes, the bounds, the seeded keys
and the flat fallback without a window; ariadne_loader_test checks the new
component (229 pass). Rendered offscreen with arigl: terrain_lab's lakes and
sea (wall edge), and the shore edge merged in locally from feat/world-gym: the
island, the sea out to the horizon, and the near waves fading into it.
Floating bodies are the next part.

* ariadne: the water node floats bodies, drawn and headless (O15, physics)

A water node with `body: {}` is one fluid field in the scene's physics world
(inc/cvc/ariadne/scene_water.h, WaterRuntime). Its volume covers the water's
extent (the ground, and the outer sea when the rim is under water) from below
the deepest ground to 15 m over the level. Its surface is
cvc::physics::ocean_surface over a cvc::ocean::sea_surface built from the same
cascades' h0 the renderer draws (lsystem_coast's tiles and seed), so a body
lighter than water floats on the waves shown and a heavier one sinks. The
field is rebuilt when the wind, chop or wave height change, or the ground
regenerates. The drawn node (water_node.cpp) and SceneWorld::from_scene (no
renderer; the ground followed through its generated world) both run it.

SceneWorld::apply now swaps a tracked node's fields along with its bodies.
Before, a field that came in through a node's colliders was added but never
removed, so every new revision leaked one.

terrain_lab.ari gets `physics: {}`, `body: {}` on the world and the water, and
three wooden crates on the big lake north of the city.

Checked (MSVC Release):
- AriadneSceneWorld.AWaterNodesBodyFloatsWhatIsLighterThanWater: a world flooded
  to 200 m; after 10 s a density-400 raft rides at z 200.31 and a density-3000
  anchor has sunk to 182.2; after a wind change the world still holds one field.
  All 31 scene-world tests pass.
- cvcgl_ariadne_realize passes; ariadne_loader_test 229 pass.
- terrain_lab.ari run headless for 10 s: the crates at z 0.23, -0.12 and 0.98
  over 17-20 m of water.
- A drawn check (arigl snapshot of a small flooded world): a 10 m raft dropped
  from 20 m rides the waves.

Not yet: the physics sea's waves do not fade toward the shore as the drawn ones
do (that needs a shore grid).
transfix added a commit that referenced this pull request Nov 16, 2026
… the water (O17) (#1256)

* ocean: eWave on the CPU, a deterministic window of waves bodies make (O8a)

cvc::ocean::ewave runs Tessendorf's eWave (roadmap C1, C3, C5) on an
n x n window: h and phi packed as one complex field, one forward and one
inverse FFT a step, each wavenumber moved on exactly for any dt in one
depth, then the mask, the edge sponge and the sources in real space.
det math and fft.h, built without FMA contraction, so a window gives
the same bits on every platform; its digest is pinned.

ocean_ewave_test checks the exact mode oscillation, energy conservation,
the ring's group velocity and isotropy, reflection off a straight wall,
the sponge, shallow-water speed, the Kelvin wake angle at two speeds,
the digest and the refusals, and prints the step's cost.

* physics: the hull model (O11a), forces per triangle against the free surface

A dynamic body may carry a hull (body_desc::hull, cvc/physics/hull.h): a
closed triangle list apart from its collision shape. Fluid fields push on
its triangles in place of the 8-cells-per-side sample: each triangle is
split at the waterline (the free surface's height at its vertices, or the
box top), and its submerged part feels hydrostatic pressure at its centre
of pressure, ITTC-57 friction, pressure drag growing with (v.n)^2, a
bounded added-mass slamming term and the field's damping in heave. The
velocity terms are integrated implicitly in their own linear and rotational
rates. det:: math, a fixed order.

A world with hulls saves a CVCHULL1 section (each hull's digest and its
triangles' last wetted areas), so state_hash covers them and restore
refuses other hulls; a world without hulls saves and hashes as before.
physics_hull_test covers floating, righting, towing resistance, a drop, a
light hull, heave on a swell and the state, and pins a hull scene's hash.

* physics: add_force_at and add_torque on world (O10)

world::add_force_at(id, force, point) applies a world-frame force at a
world-frame point, so off the centre of mass it also torques the body;
world::add_torque(id, torque) applies a world-frame torque. Both check
that every value is finite and otherwise act as add_force does: through
the next step only, waking a sleeping body, refusing an unknown id.
New backend_impl calls carry them to Jolt (AddForce at a point, moved to
the engine's floating-origin frame, and AddTorque) and to the null
backend, which checks the id. pycvc binds both.

Tests in physics_world_test check the spin against r x F dt / I, that a
force at the centre of mass gives add_force's state hash, that a torque
does not translate, that both wake a sleeping body, and the refusals.
This is roadmap item D1 of OCEAN-AND-WEATHER-ROADMAP.md.

* physics: address review of add_force_at and add_torque (O10)

pycvc's add_force_at refuses a point of None instead of reading it as the
world origin. world.h and PHYSICS_API.md say body_state::position is the
body's origin, not its centre of mass, which differs for a hull or a
vehicle chassis; a new test shows a force at a hull's origin torques it.
ForceAtAndTorqueAreChecked now covers a kinematic body, and roadmap 1.2
marks off-centre forces done.

* physics: address review of the hull model (O11a)

The field's damping on a hull now sums to the cells' c V_sub, shared among
the downward faces by the water column over each; upward faces under water
took their column too, so a submerged hull was damped more the deeper it
went. The horizontal drag is scaled in the rate without the damping, so the
damping no longer slows a towed hull. add_body keeps a private copy of the
hull mesh, so the cached normals, wetted areas and digest always describe
what is simulated. The torque's inertia estimate also takes the collision
shape's where that is lower.

New tests: the first-step torque on a heeled box is the wall-sided righting
moment (12 and 432 triangles), a sinking hull keeps its speed at depth, and
changing the caller's mesh after add_body changes nothing. The towing test
now checks the absolute resistance. The hull scene's pinned hash is
re-measured (2f71a1fe229afa75); the docs say CI has yet to confirm it.

* ocean: address review of the CPU eWave (O8a)

- A beach mask value is now a damping rate, beach_rate (1 - m), applied as
  exp(-rate dt) like the sponge, so a beach absorbs the same share per
  second at any step size. Land (m = 0) is still zeroed every step. New
  test: a beach band leaves 68.95 / 68.96 / 68.89 % of a ring's energy
  after 10 s at 30, 60 and 10 Hz. The pinned digest moves to
  0xa4933455f6946eca.
- New test for a wall band with open water behind it: a 3 m band lets
  through 4.6 % of the incident amplitude (held below 6 %), a 6 m band less.
- The standing-mode test computes omega from the dispersion relation
  itself instead of the library's omega().
- The Kelvin test runs the source 140 m in a 512^2 window with an 8 s ramp,
  so the rows it reads are steady wake. It checks the edge at 30, 40 and
  50 % of the row maximum, at 2.5 and 3.0 m/s.
- Roadmap section 6: the as-built block gets the new measurements, a
  labelled diagnostic for the wrap-around share of thin-wall leakage, and a
  note that the update is still unchecked against the eWave paper.

* ocean: eWave on the GPU, the window in cvcGL (O8b)

EWave (src/cvcGL/ocean) runs the CPU eWave's window in float with
fragment passes: z = h + i phi in RG32F, the forward FFT, an update
pass that separates H and PHI at k and -k and applies the exact
per-mode update and damping, the inverse FFT, and a real-space pass
for the normalisation, the mask's beach, the sponge and land. 34
passes a step at 256^2. Sources go into h at once, as on the CPU.

The butterfly LUT, pass and pass setup move from OceanFFT.cpp into
OceanButterfly.{h,cpp}; the forward transform conjugates the twiddle
in the shader. OceanFFT's output is unchanged.

cvcgl_ewave runs one scenario on both windows (GPU vs CPU within
2.3e-5 of the RMS field), the wall test on the GPU, and the passes and
GPU time per step.

* ocean: address review of the GPU eWave (O8b)

Count the passes step() renders instead of adding passesPerStep()'s
formula: OceanButterfly counts its own passes and EWave counts the update,
real-space and source passes, so cvcgl_ewave's 34-pass check (and a new
one-pass check for addDrop) measures something.

Say in EWave.h that only the mask is held before init(); setState, addDrop,
addHeights and step do nothing until init() succeeds.

Name OceanButterfly.{h,cpp} and the cvcgl_ocean_band and cvcgl_ewave tests
in the ABYSSAL notice, and correct roadmap section 6's Cost paragraph: a
cascade is 35 passes, so three are 105 and eWave adds about 32 % by pass
count, not the +60 % the old count of 57 gave.

* physics: boats, a propeller and rudder applied every step (O11b)

world::add_boat adds a hull body with a propeller (thrust falling off
with the inflow, only while under the free surface; an optional outboard
that vectors it) and a rudder (lift to the stall, then a flat plate, and
drag, from the flow past it), driven through first-order actuators by
set_boat_controls. The forces go through add_force_at before each engine
step, in boat id order, with det:: math. A boat's description digest,
controls, actuators and last forces are a CVCBOAT1 save section; a world
without boats saves and hashes as before.

physics_boat_test checks the thrust-resistance balance at terminal
speed, backing, steady turning circles against rudder angle, a dry
propeller, an outboard at low speed, pitching on a swell, the state, and
pins a boat scene's hash (measured on Windows; CI confirms elsewhere).

* physics: address review of O11b

Document boat_state::water_velocity as the water's under or at the centre of mass (0 only where no fluid covers it) and boat_state::inflow as measured along the propeller's ahead direction. Correct the restore() claim: the boat section is checked after the engine is restored, so a refused state leaves the boats unchanged but not the bodies.

* ocean: eWave walls that reflect a crest as a crest (O8c)

O8's mask zeroed h and phi on wall cells each step: a Dirichlet wall,
under which a crest comes back as a trough. A vertical wall or cliff is
no-flux (d phi / dn = 0), about which h and phi are even, so a crest comes
back as a crest. Walls are now no-flux by default, by ghost cells (the
image method), on the CPU and the GPU.

cvc::ocean::ewave_wall_ghosts finds, at set_mask, the nearest water cell q
of each wall cell p within the ghost band (exact integer search, no wrap),
mirrors p across the shore half a cell from q (p' = p + 2 s n), and stores
p' as bilinear corners restricted to water with renormalised weights. Each
step, after the real-space pass, and after each source, the ghost cells
take h and phi from their corners. A straight wall is exact (a no-flux
channel's own mode oscillates at omega to 3e-14); staircase and curved
walls are first order.

ewave_params::walls picks no_flux (the default) or zero (O8a's wall, bit
for bit: the digest leaves both new fields out under zero, so the pin
0xa4933455f6946eca stands). ghost_cells defaults to 16, the knee of the
measured reflection error (the spectral operator is not local, so the
image's cut at the band shows as about 1 / band). A no_flux pin is added,
0xfc278a415ad67d3f, measured on Windows; CI checks Linux and macOS.

EWave (cvcGL) runs the same fill as one more pass when there are ghosts
(35 a step, 34 without), from the CPU's own table uploaded as an RG32F
corner texture and an RGBA32F weight texture, fetching the four corners
itself. On the wall test it gives the even image to 6.7 % and agrees with
the CPU to 6.1e-5 RMS.

ocean_ewave_test: the straight-wall test now checks both kinds (the even
image to 6.8 % RMS under no_flux, the odd one to 18.8 % under zero, the
reflection's sign), plus a no-flux channel mode, lossless closed basins
(straight, 45-degree, disc: no growth over 300 s), the thin-wall leak
under no_flux, and set_mask's cost. AThinWallLeaksLittle and the digest
test pin their O8a claims to walls = zero. Roadmap section 6 gains the
"As built (O8c)" block with the measurements.

* ocean: bodies make waves (O9)

The shared immersion code, cvc/physics/immersion.h: a body's columns of
immersed depth over a grid window from its shape (box, sphere, convex
hull, or its hull mesh), its pose and the water, as the field step
immerses it; standard library, the same bits on every platform (pinned
in physics_immersion_test, measured on Windows; CI checks Linux/macOS).

WakeSource turns it into EWave's sources, -(zeta(t) - zeta(t - dt)),
and EWave gains a one-pass shift so a window can follow something.
cvcgl_wake checks the sources, the shift, a box footprint's Kelvin wake
read from the GPU (19.3-20.0 deg at 2.5 and 3 m/s) and a rock's shadow.

lsystem_coast draws the debris' wakes: a 128 m sea window on the
camera's target (D3) with a mask from the shore, and one on the crater
lake whose banks reflect; height, slope and foam in both water shaders;
--wake-check reports the windows' energy and a lake drop's ring.

* ocean: address review of O9

- A teleported body (the wake check's drop, "drop them again") no
  longer leaves a false ring where it floated: the sources only record
  the columns until the drawn poses are the ones after it.
- The sea sources cut each drawn pose against the sea at that pose's
  field time (one physics step behind the frame), not at the frame's.
- --wake-check now fails (rc 5) when a window with bodies has no waves,
  the drop makes no ring, or the lake keeps no more than its absorbing
  twin.
- add_immersion: a hull mesh in unbounded water is wholly under, not
  NaN read as dry; new test.
- immersion.h and the roadmap no longer claim exact agreement or smooth
  zeta; the roadmap's lake and sea numbers are re-measured.

* ocean: address review of the no-flux walls

The review measured no-flux walls growing without bound in curved and
thin closed basins. Confirmed: overwriting the ghosts with the image is
an oblique projection, and the water's update it gives is not symmetric
where the image is not an exact mirror or is cut off at the band. None
of the stabilisers tried in a scratch probe (a taper, capping each water
cell's ghost weight, no ghosts near a medial axis, k^2 damping, folding
the fill's transpose back as an orthogonal projection, and partial or
first-layer folds) held every basin while keeping the straight wall's
reflection, so:

- walls = zero (O8a, bit for bit) is the default again; no_flux is opt
  in, its stability limits documented in ewave.h with the measured
  growth and the damping (0.004 /s) that held every basin at 1/30 s.
- New WallsStayBounded: broadband noise in closed basins (disc, island,
  breakwater, straight channel, thin wall) at dt 0.1, 0.25 and 1/30 s.
  Zero walls never exceed their start; no_flux growth is printed; the
  straight channel and thin wall stay level at 1/30 s, and 0.004 /s of
  damping holds every basin there.
- NoFluxWallsAreLossless becomes NoFluxWallsAreNearlyLossless and no
  longer claims stability; it adds the whole-wall straight channel and
  checks energy() against the water-only sum.
- energy() counts the water only (mask > 0): the ghosts are left out
  and, with ghosts, the kinetic part is sum phi (K phi) over the water.
  Without ghosts it is unchanged. height(), phi(), at() and
  EWave::heightTexture() are documented to include the ghost image.
- cvcgl_ewave: scenario 1 adds a round island whose ghosts have
  fractional weights with wall corners zeroed, and checks the GPU
  against the CPU within 3 m of it (a swapped weight channel fails it).
- The band sweep covers 1 cell; the roadmap's O8c block is corrected.

* ocean: a drivable boat in lsystem_coast (O11c)

A 5 m skiff with an outboard, a cvc::physics boat in the debris' world,
floated by the hull mesh it is drawn as. I/J/K/L and the panel's Boat
section drive it through coast.boat.* knobs; C toggles a chase camera
that also brings the sea's wake window along. Its columns feed the wake
window like the debris', and the sea's shader discards water inside the
hull (D5).

--boat-check drives a scripted course and reports speed, turning circle,
heave/pitch/roll on the lee and along the reflecting south-west shore,
and the wake's angle at two speeds; --snap writes frames at given times.

* ocean: EWave's finite() helper is finite_value(), clear of glibc's ::finite

GCC's glibc declares ::finite(double), so inside EWave's member functions an unqualified
finite() found both it and the file's own helper and was ambiguous; MSVC has no ::finite,
so only the Linux lanes failed to build cvcgl_ewave. Rename the helper; nothing else
changes.

* ocean: no-flux walls as a symmetric operator with a symplectic step (O8c)

The ghost-cell walls overwrote the wall cells with the water's mirror image
after each exact step: an oblique projection, unstable wherever the image
was not an exact mirror (a disc grew 31x in 2000 s, a thin wall 1e72x).
They are replaced by a scheme that conserves energy by construction, and
no_flux walls are the default again.

The state lives on the water; R extends it over the window (ghost cells
take their mirror image), R^T folds back, S = R^T G R is symmetric positive
semidefinite for any ghosts and weights, and M is the lumped mass (the row
sums of R^T R, ewave_lumped_mass). Stormer-Verlet in substeps that keep
omega_max dt_s <= 1.8 (ewave_substeps): S <= max(G) M bounds every mode
inside the limit, and the step conserves its modified energy exactly, so
nothing can grow at any dt. G is kappa~ = 4 sin^2(omega dt_s / 2) /
(g dt_s^2), so open water keeps eWave's exact dispersion (with kappa a
straight wall's reflection was 55 % off its even image at dt 0.1 s).
damping_k2, the beach and the sponge act on h through M-contractions;
the global damping on both. Windows without ghosts keep the exact step bit
for bit (the zero-walls pin 0xa4933455f6946eca holds).

Accuracy: the fold carries G's response at every ghost back into the water,
so an image cut short (or two shores' images meeting in a thin wall) shows
at the cut's mirror distance. The default band now reaches as far as the
image does (ghost_cells = 4096), and the weights taper to 0 over 8 cells
near the cuts and seams that remain. No water cell is read by more than 12
ghosts (whole ghosts dropped, farthest first, on CPU and GPU alike).

Measured (Windows): a no-flux channel is the exact Neumann operator
(2.9e-15) and its mode matches Stormer-Verlet's discrete solution to
4e-14; broadband noise in seven closed basins for 20000 steps at omega_max
dt 1.8, 0.25 s and 1/30 s keeps the modified energy within 1.3e-14 and
energy() never above its start; the straight wall matches the even image
to 2.9e-14 without the sponge and 2.2 % with it (6.8 % before), gain 1.90,
slope +1.001; rings in closed ponds lose nothing over 300 s; thin walls
leak 10.8 / 5.7 / 3.0 % at 3 / 6 / 12 m. New no_flux pin
0x40cb161804c270ca (Linux and macOS to be confirmed by CI).

EWave runs the same scheme from the same CPU tables: per substep a fill
pass, the forward butterflies, a multiply pass, the inverse butterflies
and a gather pass (readers in six RGBA32F textures, 1 / M in an R32F one):
4 log2 n + 3 = 35 passes at 256^2, plus one real-space pass a step (36 at
1/30 s, against 34 without walls). It agrees with the CPU to 1e-5 RMS,
reflects crest for crest (2.1 % against the even image) and stays bounded
over a long broadband run. Roadmap section 6's O8c block is rewritten.

* ocean: address review of O11c

lsystem_coast draws the D5 hole from the pose present() posed the hull
with (a group of one in the binding), not a second tracker sample that a
threaded physics step could land between. --boat-check prints the wake
window's depth and depth Froude number; the new knob coast.wake.depth
forces the window's depth, and a deep rerun shows the full-throttle
narrowing is the length Froude number's, not the shallow window's.
--snap no longer puts its tag into a dotted directory name. The roadmap
has coast.boat.enabled's sense right and the depth result.

* ocean: sea_surface keeps its last source in the frame, not a thread_local

The writable-data scan (#1152 made its allowlist a ratchet) refuses process-wide state, and
sea_surface::source kept its last source in a thread_local (O7c, #1159), so every PR's
package-linux release-grpc lane now fails on master's code. The memo moves into the time's
frame, under the mutex the frame already has for its lattice: a frame is the surface at one
time, so the point alone is the key, and as a memo of a pure function it changes no value.
ocean_sea_test (19, pins unchanged) and physics_field_test (22, goldens unchanged) pass; the
exact height-and-velocity pair still costs about what it did (3.8 us, 1.76 us on the lattice).

* ocean: address review of the stable no-flux walls

- The symmetric step's substep no longer follows the caller's dt. kappa~
  and Stormer-Verlet's invariant both depend on it, so a dt that changed
  between steps switched between maps with different invariants and grew
  by parametric resonance (the review: a disc 1e103-fold in 4000 steps of
  0.136 and 0.101 s in turn). A window now has one substep,
  ewave_params::substep (default 1/60 s, capped at 1.8 / omega_max):
  step(dt) runs whole substeps (ewave_substep_count) and carries the rest
  in pending(). The beach, sponge, global damping and damping_k2 act every
  substep for dt_s, so every substep is the same linear map whatever the
  dts. Same on the GPU: the count is made on the host in double, and the
  real-space factors move into the gather pass. New tests
  (VariableStepsAreStable on the CPU, jittered dt in cvcgl_ewave): the
  modified energy holds to 6e-15 under alternating and jittered dt.
- A wall one cell thick is a seam: its nearest water lies on opposite
  sides, so its image tapers to almost 0 instead of holding the front
  water beside the water behind. It leaked 87.6 %; now 40.4 % (zero walls
  41.1 %). AThinWallLeaksLittle covers 1, 2 and 4 cells.
- ewave_wall_ghosts finds each wall cell's nearest water with a distance
  transform, O(n^2) whatever the band (1024^2 set_mask: 0.21-0.25 s,
  against 10 s), ties exact within 32 cells of the shore.
- The GPU gather decodes a reader's cell by truncation (int(cell + 0.5)
  rounded odd indices up past 2^23); the header gives the reader
  textures' memory.
- Docs: stability now holds for any sequence of steps; the 2.2 %
  reflection is the best case where the whole image fits; the mean
  potential's drift where S annihilates constants is documented (not
  gauged: the GPU would need a reduction).
- The no_flux pin is re-measured on Windows: 0x9d1fde2b635d7dbf. The
  zero-walls pin 0xa4933455f6946eca holds.

* ocean: no-flux damping_k2 takes what zero walls take

The symmetric step applied damping_k2 as h <- M^-1 R^T F R h. At F = 1 that
is not the identity: M^-1 R^T R averages each water cell a ghost reads with
the corners round the ghost's mirror point, wherever that point falls between
cells. Run once a substep, the smoothing took lsystem_coast's crater lake's
ring faster under no-flux banks than under zero ones (20 % of the energy left
10 s after the drop, against 55 %).

The filter is now h <- h - M^-1 R^T (1 - F) R h (1 - F as -expm1, and as
x (1 - x/2) below 1e-3 in the GPU's float): the same beside a straight wall,
still self-adjoint under M with eigenvalues in (0, 1], and the identity as F
goes to 1. In a disc 36 m across with damping_k2 2e-3, the energy left after
10 s is 75.7 % under no-flux walls against 75.5 % under zero walls (the first
form: 49.3 %); at damping_k2 1e-15 the heights match the undamped run to
1.5e-13 (the first form: 99 % off). New test:
DampingK2TakesTheSameShareWhateverTheWalls. The no-flux digest pin is
re-measured.

lsystem_coast's lake now keeps 48 % after 10 s (13 % with absorbing banks).
The rest of the gap to 55 % is the check's reading, the water's sum of h^2
without M, which sits near 1 / mean(M) of the conserved energy once the ring
reaches the banks. The roadmap's O8c and O9 blocks have the numbers.

* ocean: back out #1193's source memo, superseded by #1181

* ocean: the sea's height for its wind (O2b)

The cascades' sea was about 2.3 times JONSWAP's significant height for
its wind, and lsystem_coast drew it at wave_amp 1.2: 5.7 m Hs at 9 m/s
where JONSWAP gives 2.2 m. Two errors in O2's library:

- h0 was twice its size. A texel's mode is h0(k) e^(iwt) +
  conj h0(-k) e^(-iwt), so its share of the surface's variance is
  E|h0(k)|^2 + E|h0(-k)|^2. With h0 = g sqrt(S) dk and E|g|^2 = 2 that
  is 4 S dk^2. h0 is now g sqrt(S) dk / 2.
- The spread's cos^2 part, (2/pi) cos^2, spanned the whole turn
  (ABYSSAL's), where it integrates to 2, with a lobe upwind. It now
  covers the downwind half, so the spread integrates to 1.

The cascades now hold JONSWAP's Hs within 2 % from 4 to 25 m/s, and
the sea they make is within 5 % over four seeds. lsystem_coast's
wave_amp defaults to 1, and --boat-check sets only the wind (4 m/s,
0.54 m Hs); it also passes at the default 9 m/s now.

New tests OceanH0.TheCascadesHoldTheWindSeasHeight and
OceanSea.TheSeaHasTheWindsHeight; the spread, variance and h0-energy
tests expect the corrected values; five digest pins move with the sea.

* ocean_sea_test: drop the memo test the master merge doubled

* ocean_ewave_test: the basin stability runs take a twentieth of the steps in unoptimized builds

Ewave.WallsAreStable and Ewave.VariableStepsAreStable step a 64^2 basin tens of
thousands of times: 83-129 s and 29-42 s in a Release build, and past ctest's
300 s in the Debug package lanes (package-linux libcvc-debug and -debug-grpc on
#1194), which run these tests about 10 times slower.

As #908 did for the stepped mesher tests, gated on the optimizer rather than
NDEBUG: an unoptimized build divides run_basin's step count and its energy()
sampling interval by kBasinScale (20), so each quarter still averages as many
samples. The printouts report the steps actually run.

Forced to 20 in a Release build, both pass in 4.5 s and 1.7 s: modified energy
within 8.2e-15 (limit 1e-9), last-quarter drift at most 0.0008 (limit 0.005),
damped runs end at 1.6e-6 of their start (limit 0.5). Optimized builds are
unchanged (18/18 ocean_ewave_test, full counts).

* ocean: whitecaps cover Monahan's share for the wind (O5, first part)

On the calibrated sea (O2b) the wave foam's fixed threshold drew nothing: the
least of the cascades' Jacobians over lsystem_coast's tile is 0.49-0.59 at every
wind from 4 to 25 m/s, so foam_bias 0.48 met no water. Whitecaps should cover
W = min(3.84e-6 U^3.41, 0.16) of the sea (Monahan and O'Muircheartaigh 1980):
0.04 % at 4 m/s, 0.69 % at 9, 3.9 % at 15, 16 % at 25.

cvc::ocean::foam_field (inc/cvc/ocean/whitecaps.h) evolves the cascades' h0 on
the CPU as OceanFFT does, takes the least J at the drawn grid's vertices, linear
over its triangles, at two times, weighs each sample by its share of the drawn
surface (|J|), and bisects for the bias whose mean foam is W. monahan_coverage
gives W.

The shader's ramp narrows from 0.85 to 0.1 (coast.water.foam_ramp): the least J
sits only ~0.35 under its mean, so a wide ramp meets W with a faint veil (at
9 m/s, faint foam on 51 % of the sea with 0.85, 14 % with ABYSSAL's 0.3, none of
it half white). Each fragment's J is shifted by fray x (noise - 0.5) on the
water's rest position (coast.water.foam_fray, 0.12), so patches have ragged
edges instead of the straight lines J makes across a 2 m triangle; the bias
models the fray by 16 quantiles of the noise's distribution.

lsystem_coast finds the bias at start-up and again once h0, the chop, the ramp,
the fray or coast.water.whitecaps (a scale on W, the panel's "whitecaps" slider)
has changed and held for 10 frames. coast.water.foam_bias >= 0 still fixes it.
On its sea the bias runs 0.747 / 0.796 / 0.822 / 0.856 at 4 / 9 / 15 / 25 m/s,
with 0.68-0.95 of W at least half white; a field takes 110-250 ms (Release).

Tests (ocean_spectrum_test): OceanWhitecaps.TheFoamFieldsJacobianIsOceanFFTs
(one wave: J = 1 - 2alk cos k.x exactly), MonahansCoverage, and
TheBiasGivesMonahansShareOnTheCoastsSea. Roadmap section 8 E0b has the numbers.
The persistent foam of section 10.2 is still to do.

* cvcGL: the GPU ocean in the library (OceanFFT, its butterflies, EWave, WakeSource)

The ABYSSAL port's sources in src/cvcGL/ocean were compiled straight into
lsystem_coast and the four cvcGL ocean tests, so nothing else could use them.
O15 (OCEAN-AND-WEATHER-ROADMAP.md section 11.2) draws the sea from an Ariadne
node, which lives in cvcGL, so they join the library: a GLOB of ocean/*.cpp,
the directory a private include of cvcGL. The tests and lsystem_coast link
them from cvcGL now and keep the include directory (the headers stay private).
The examples always link the in-tree cvcGL target, the standalone
libcvc-examples recipe included, so the browser gallery is unaffected.

The shaders' namespace-scope strings become const pointers
(const char *const), so the library gains no writable data for the
writable-data scan. clang-format moved each one's first literal onto its own
line; the strings are unchanged.

Checked (MSVC Release, full build): cvcgl_ocean_fft, cvcgl_ocean_band,
cvcgl_ewave and cvcgl_wake pass (none skipped), and lsystem_coast's
--boat-check, --debris-check --wake-check and --shore-check pass.

* ariadne: the water node, terrain_lab.ari's sea, lakes and ponds as the GPU FFT ocean (O15, drawing)

A `water` scene node (src/cvcGL/ariadne/water_node.cpp, registered with the
cvcGL extensions) draws everything below `level` on a ground (`world:` a
generated_world, or `ground:` a height-field node) as lsystem_coast's GPU sea:
three OceanFFT cascades built from cvc::ocean::build_h0 for the wind, each
fading out over `shore_fade` metres of depth toward the shore, and its
Fresnel shading, shallows tinted by depth, and frayed Jacobian whitecaps.

- Meshes of its own, not the world's flat water rungs (5 m cells and coarser,
  longer than the short cascade's waves): a near grid +-192 m around the
  camera, a vertex every 2 m, displaced and faded to flat at its edge, moving
  with the camera by whole cells; and a flat far grid over the ground that gives
  way inside the near one. Dry fragments are discarded against a
  HeightFieldTexture of the ground, sampled per fragment. Both stay out of the
  scene's bounds, so the ground frames the view. terrain_lab's world sets
  `water: 0`.
- Whitecaps cover Monahan's share for the wind: the threshold comes from
  cvc::ocean::foam_field on the near grid's vertices, found again once the
  wind, chop, ramp, fray or water.whitecaps have held for 10 frames
  (water.foam_bias >= 0 fixes it by hand).
- The world's edge: when the ground's whole rim is under water (a
  generated_world with `edge: shore`, an island), the sea goes on `outer` (6 km,
  as world::outer_sea) past it; otherwise both grids clip to the ground's
  rectangle (a wall, or the world falling away). It is checked again after
  every regenerate, so the Edge picker switches it live.
- disableCoordinateShiftScale is set before the meshes' first draw: set after
  it, the far grid kept a shifted buffer and its fragments missed the bed.

Keys water.*: wind_speed, wind_dir, fetch, chop, wave_amp, whitecaps,
foam_bias, foam_ramp, foam_fray, shore_fade. Panel: water_controls.ari (INDEX
entry); terrain_lab.ari includes it (Settings > Water).

Tests: cvcgl_ariadne_realize builds a generated world plus a water node at
level 0 (a rim partly dry: the far grid ends at the ground) and at 500 m (a
rim under water: 6 km past), and checks the meshes, the bounds, the seeded keys
and the flat fallback without a window; ariadne_loader_test checks the new
component (229 pass). Rendered offscreen with arigl: terrain_lab's lakes and
sea (wall edge), and the shore edge merged in locally from feat/world-gym: the
island, the sea out to the horizon, and the near waves fading into it.
Floating bodies are the next part.

* ariadne: the water node floats bodies, drawn and headless (O15, physics)

A water node with `body: {}` is one fluid field in the scene's physics world
(inc/cvc/ariadne/scene_water.h, WaterRuntime). Its volume covers the water's
extent (the ground, and the outer sea when the rim is under water) from below
the deepest ground to 15 m over the level. Its surface is
cvc::physics::ocean_surface over a cvc::ocean::sea_surface built from the same
cascades' h0 the renderer draws (lsystem_coast's tiles and seed), so a body
lighter than water floats on the waves shown and a heavier one sinks. The
field is rebuilt when the wind, chop or wave height change, or the ground
regenerates. The drawn node (water_node.cpp) and SceneWorld::from_scene (no
renderer; the ground followed through its generated world) both run it.

SceneWorld::apply now swaps a tracked node's fields along with its bodies.
Before, a field that came in through a node's colliders was added but never
removed, so every new revision leaked one.

terrain_lab.ari gets `physics: {}`, `body: {}` on the world and the water, and
three wooden crates on the big lake north of the city.

Checked (MSVC Release):
- AriadneSceneWorld.AWaterNodesBodyFloatsWhatIsLighterThanWater: a world flooded
  to 200 m; after 10 s a density-400 raft rides at z 200.31 and a density-3000
  anchor has sunk to 182.2; after a wind change the world still holds one field.
  All 31 scene-world tests pass.
- cvcgl_ariadne_realize passes; ariadne_loader_test 229 pass.
- terrain_lab.ari run headless for 10 s: the crates at z 0.23, -0.12 and 0.98
  over 17-20 m of water.
- A drawn check (arigl snapshot of a small flooded world): a 10 m raft dropped
  from 20 m rides the waves.

Not yet: the physics sea's waves do not fade toward the shore as the drawn ones
do (that needs a shore grid).

* sky: a live sky, the sun from the light rig, and the clouds' shade on the water (O17)

O17 of OCEAN-AND-WEATHER-ROADMAP.md (F1 and A4's cloud shade on the water):

- cloud_layer::set_coverage ranks the cells' targets again at once, and the
  clouds fade in or out to them over fade_s. The automaton is untouched.
- cloud_layer::set_sun makes the maps again (the grammar bakes a little
  top-light into its field), then their self-shade, shadow patches and far
  opacity. The cells, morphs and automaton are kept, so the clouds do not
  jump. The constructor's map loop moved into make_maps().
- cloud_sky reads sky.coverage and sky.wind_az every frame (seeded from its
  props; two more sliders on sky_controls.ari). Its sun is the light rig's key,
  lighting.key_azimuth / key_elevation, when the scene has a rig; a change
  relights the deck and re-composites the shade and the far clouds at once.
  sun_az / sun_el are used only without a rig, and terrain_lab.ari drops its
  copy of the rig's angles.
- The water as a shade receiver. The water node replaces VTK's lighting, so
  the deck's rewrite of the lighting sum finds nothing in it. Once the sky has
  wired its inputs into a water mesh, the water switches that mesh to lighting
  that multiplies its sun and glints by the deck's cloudShade().
  terrain_lab.ari lists `water` among the sky's receivers.

Checked (MSVC Release):
- WorldCloudLayer.CoverageAndSunChangeLive: coverage 0.3 / 1.5 / 0.6 gives
  11 / 36 / 22 of 36 cells; a deck relit with set_sun shades and draws exactly
  as one built under that sun. 17 cloud tests pass.
- cvcgl_ariadne_realize: the seeded keys; the shade wired into both water
  meshes; cloudSunR at the props' elevation 28 until the rig's keys move it to
  elevation 50. The test passes; ariadne_loader_test 229 pass.
- terrain_lab renders without warnings.

Not done: base / top live (a new deck and new nodes) and a darkness key. Both
belong with F2's storm decks.

* Run llm-gate on the merged head
transfix added a commit that referenced this pull request Nov 16, 2026
…normals past the near grid (O15) (#1264)

* ocean: eWave on the CPU, a deterministic window of waves bodies make (O8a)

cvc::ocean::ewave runs Tessendorf's eWave (roadmap C1, C3, C5) on an
n x n window: h and phi packed as one complex field, one forward and one
inverse FFT a step, each wavenumber moved on exactly for any dt in one
depth, then the mask, the edge sponge and the sources in real space.
det math and fft.h, built without FMA contraction, so a window gives
the same bits on every platform; its digest is pinned.

ocean_ewave_test checks the exact mode oscillation, energy conservation,
the ring's group velocity and isotropy, reflection off a straight wall,
the sponge, shallow-water speed, the Kelvin wake angle at two speeds,
the digest and the refusals, and prints the step's cost.

* physics: the hull model (O11a), forces per triangle against the free surface

A dynamic body may carry a hull (body_desc::hull, cvc/physics/hull.h): a
closed triangle list apart from its collision shape. Fluid fields push on
its triangles in place of the 8-cells-per-side sample: each triangle is
split at the waterline (the free surface's height at its vertices, or the
box top), and its submerged part feels hydrostatic pressure at its centre
of pressure, ITTC-57 friction, pressure drag growing with (v.n)^2, a
bounded added-mass slamming term and the field's damping in heave. The
velocity terms are integrated implicitly in their own linear and rotational
rates. det:: math, a fixed order.

A world with hulls saves a CVCHULL1 section (each hull's digest and its
triangles' last wetted areas), so state_hash covers them and restore
refuses other hulls; a world without hulls saves and hashes as before.
physics_hull_test covers floating, righting, towing resistance, a drop, a
light hull, heave on a swell and the state, and pins a hull scene's hash.

* physics: add_force_at and add_torque on world (O10)

world::add_force_at(id, force, point) applies a world-frame force at a
world-frame point, so off the centre of mass it also torques the body;
world::add_torque(id, torque) applies a world-frame torque. Both check
that every value is finite and otherwise act as add_force does: through
the next step only, waking a sleeping body, refusing an unknown id.
New backend_impl calls carry them to Jolt (AddForce at a point, moved to
the engine's floating-origin frame, and AddTorque) and to the null
backend, which checks the id. pycvc binds both.

Tests in physics_world_test check the spin against r x F dt / I, that a
force at the centre of mass gives add_force's state hash, that a torque
does not translate, that both wake a sleeping body, and the refusals.
This is roadmap item D1 of OCEAN-AND-WEATHER-ROADMAP.md.

* physics: address review of add_force_at and add_torque (O10)

pycvc's add_force_at refuses a point of None instead of reading it as the
world origin. world.h and PHYSICS_API.md say body_state::position is the
body's origin, not its centre of mass, which differs for a hull or a
vehicle chassis; a new test shows a force at a hull's origin torques it.
ForceAtAndTorqueAreChecked now covers a kinematic body, and roadmap 1.2
marks off-centre forces done.

* physics: address review of the hull model (O11a)

The field's damping on a hull now sums to the cells' c V_sub, shared among
the downward faces by the water column over each; upward faces under water
took their column too, so a submerged hull was damped more the deeper it
went. The horizontal drag is scaled in the rate without the damping, so the
damping no longer slows a towed hull. add_body keeps a private copy of the
hull mesh, so the cached normals, wetted areas and digest always describe
what is simulated. The torque's inertia estimate also takes the collision
shape's where that is lower.

New tests: the first-step torque on a heeled box is the wall-sided righting
moment (12 and 432 triangles), a sinking hull keeps its speed at depth, and
changing the caller's mesh after add_body changes nothing. The towing test
now checks the absolute resistance. The hull scene's pinned hash is
re-measured (2f71a1fe229afa75); the docs say CI has yet to confirm it.

* ocean: address review of the CPU eWave (O8a)

- A beach mask value is now a damping rate, beach_rate (1 - m), applied as
  exp(-rate dt) like the sponge, so a beach absorbs the same share per
  second at any step size. Land (m = 0) is still zeroed every step. New
  test: a beach band leaves 68.95 / 68.96 / 68.89 % of a ring's energy
  after 10 s at 30, 60 and 10 Hz. The pinned digest moves to
  0xa4933455f6946eca.
- New test for a wall band with open water behind it: a 3 m band lets
  through 4.6 % of the incident amplitude (held below 6 %), a 6 m band less.
- The standing-mode test computes omega from the dispersion relation
  itself instead of the library's omega().
- The Kelvin test runs the source 140 m in a 512^2 window with an 8 s ramp,
  so the rows it reads are steady wake. It checks the edge at 30, 40 and
  50 % of the row maximum, at 2.5 and 3.0 m/s.
- Roadmap section 6: the as-built block gets the new measurements, a
  labelled diagnostic for the wrap-around share of thin-wall leakage, and a
  note that the update is still unchecked against the eWave paper.

* ocean: eWave on the GPU, the window in cvcGL (O8b)

EWave (src/cvcGL/ocean) runs the CPU eWave's window in float with
fragment passes: z = h + i phi in RG32F, the forward FFT, an update
pass that separates H and PHI at k and -k and applies the exact
per-mode update and damping, the inverse FFT, and a real-space pass
for the normalisation, the mask's beach, the sponge and land. 34
passes a step at 256^2. Sources go into h at once, as on the CPU.

The butterfly LUT, pass and pass setup move from OceanFFT.cpp into
OceanButterfly.{h,cpp}; the forward transform conjugates the twiddle
in the shader. OceanFFT's output is unchanged.

cvcgl_ewave runs one scenario on both windows (GPU vs CPU within
2.3e-5 of the RMS field), the wall test on the GPU, and the passes and
GPU time per step.

* ocean: address review of the GPU eWave (O8b)

Count the passes step() renders instead of adding passesPerStep()'s
formula: OceanButterfly counts its own passes and EWave counts the update,
real-space and source passes, so cvcgl_ewave's 34-pass check (and a new
one-pass check for addDrop) measures something.

Say in EWave.h that only the mask is held before init(); setState, addDrop,
addHeights and step do nothing until init() succeeds.

Name OceanButterfly.{h,cpp} and the cvcgl_ocean_band and cvcgl_ewave tests
in the ABYSSAL notice, and correct roadmap section 6's Cost paragraph: a
cascade is 35 passes, so three are 105 and eWave adds about 32 % by pass
count, not the +60 % the old count of 57 gave.

* physics: boats, a propeller and rudder applied every step (O11b)

world::add_boat adds a hull body with a propeller (thrust falling off
with the inflow, only while under the free surface; an optional outboard
that vectors it) and a rudder (lift to the stall, then a flat plate, and
drag, from the flow past it), driven through first-order actuators by
set_boat_controls. The forces go through add_force_at before each engine
step, in boat id order, with det:: math. A boat's description digest,
controls, actuators and last forces are a CVCBOAT1 save section; a world
without boats saves and hashes as before.

physics_boat_test checks the thrust-resistance balance at terminal
speed, backing, steady turning circles against rudder angle, a dry
propeller, an outboard at low speed, pitching on a swell, the state, and
pins a boat scene's hash (measured on Windows; CI confirms elsewhere).

* physics: address review of O11b

Document boat_state::water_velocity as the water's under or at the centre of mass (0 only where no fluid covers it) and boat_state::inflow as measured along the propeller's ahead direction. Correct the restore() claim: the boat section is checked after the engine is restored, so a refused state leaves the boats unchanged but not the bodies.

* ocean: eWave walls that reflect a crest as a crest (O8c)

O8's mask zeroed h and phi on wall cells each step: a Dirichlet wall,
under which a crest comes back as a trough. A vertical wall or cliff is
no-flux (d phi / dn = 0), about which h and phi are even, so a crest comes
back as a crest. Walls are now no-flux by default, by ghost cells (the
image method), on the CPU and the GPU.

cvc::ocean::ewave_wall_ghosts finds, at set_mask, the nearest water cell q
of each wall cell p within the ghost band (exact integer search, no wrap),
mirrors p across the shore half a cell from q (p' = p + 2 s n), and stores
p' as bilinear corners restricted to water with renormalised weights. Each
step, after the real-space pass, and after each source, the ghost cells
take h and phi from their corners. A straight wall is exact (a no-flux
channel's own mode oscillates at omega to 3e-14); staircase and curved
walls are first order.

ewave_params::walls picks no_flux (the default) or zero (O8a's wall, bit
for bit: the digest leaves both new fields out under zero, so the pin
0xa4933455f6946eca stands). ghost_cells defaults to 16, the knee of the
measured reflection error (the spectral operator is not local, so the
image's cut at the band shows as about 1 / band). A no_flux pin is added,
0xfc278a415ad67d3f, measured on Windows; CI checks Linux and macOS.

EWave (cvcGL) runs the same fill as one more pass when there are ghosts
(35 a step, 34 without), from the CPU's own table uploaded as an RG32F
corner texture and an RGBA32F weight texture, fetching the four corners
itself. On the wall test it gives the even image to 6.7 % and agrees with
the CPU to 6.1e-5 RMS.

ocean_ewave_test: the straight-wall test now checks both kinds (the even
image to 6.8 % RMS under no_flux, the odd one to 18.8 % under zero, the
reflection's sign), plus a no-flux channel mode, lossless closed basins
(straight, 45-degree, disc: no growth over 300 s), the thin-wall leak
under no_flux, and set_mask's cost. AThinWallLeaksLittle and the digest
test pin their O8a claims to walls = zero. Roadmap section 6 gains the
"As built (O8c)" block with the measurements.

* ocean: bodies make waves (O9)

The shared immersion code, cvc/physics/immersion.h: a body's columns of
immersed depth over a grid window from its shape (box, sphere, convex
hull, or its hull mesh), its pose and the water, as the field step
immerses it; standard library, the same bits on every platform (pinned
in physics_immersion_test, measured on Windows; CI checks Linux/macOS).

WakeSource turns it into EWave's sources, -(zeta(t) - zeta(t - dt)),
and EWave gains a one-pass shift so a window can follow something.
cvcgl_wake checks the sources, the shift, a box footprint's Kelvin wake
read from the GPU (19.3-20.0 deg at 2.5 and 3 m/s) and a rock's shadow.

lsystem_coast draws the debris' wakes: a 128 m sea window on the
camera's target (D3) with a mask from the shore, and one on the crater
lake whose banks reflect; height, slope and foam in both water shaders;
--wake-check reports the windows' energy and a lake drop's ring.

* ocean: address review of O9

- A teleported body (the wake check's drop, "drop them again") no
  longer leaves a false ring where it floated: the sources only record
  the columns until the drawn poses are the ones after it.
- The sea sources cut each drawn pose against the sea at that pose's
  field time (one physics step behind the frame), not at the frame's.
- --wake-check now fails (rc 5) when a window with bodies has no waves,
  the drop makes no ring, or the lake keeps no more than its absorbing
  twin.
- add_immersion: a hull mesh in unbounded water is wholly under, not
  NaN read as dry; new test.
- immersion.h and the roadmap no longer claim exact agreement or smooth
  zeta; the roadmap's lake and sea numbers are re-measured.

* ocean: address review of the no-flux walls

The review measured no-flux walls growing without bound in curved and
thin closed basins. Confirmed: overwriting the ghosts with the image is
an oblique projection, and the water's update it gives is not symmetric
where the image is not an exact mirror or is cut off at the band. None
of the stabilisers tried in a scratch probe (a taper, capping each water
cell's ghost weight, no ghosts near a medial axis, k^2 damping, folding
the fill's transpose back as an orthogonal projection, and partial or
first-layer folds) held every basin while keeping the straight wall's
reflection, so:

- walls = zero (O8a, bit for bit) is the default again; no_flux is opt
  in, its stability limits documented in ewave.h with the measured
  growth and the damping (0.004 /s) that held every basin at 1/30 s.
- New WallsStayBounded: broadband noise in closed basins (disc, island,
  breakwater, straight channel, thin wall) at dt 0.1, 0.25 and 1/30 s.
  Zero walls never exceed their start; no_flux growth is printed; the
  straight channel and thin wall stay level at 1/30 s, and 0.004 /s of
  damping holds every basin there.
- NoFluxWallsAreLossless becomes NoFluxWallsAreNearlyLossless and no
  longer claims stability; it adds the whole-wall straight channel and
  checks energy() against the water-only sum.
- energy() counts the water only (mask > 0): the ghosts are left out
  and, with ghosts, the kinetic part is sum phi (K phi) over the water.
  Without ghosts it is unchanged. height(), phi(), at() and
  EWave::heightTexture() are documented to include the ghost image.
- cvcgl_ewave: scenario 1 adds a round island whose ghosts have
  fractional weights with wall corners zeroed, and checks the GPU
  against the CPU within 3 m of it (a swapped weight channel fails it).
- The band sweep covers 1 cell; the roadmap's O8c block is corrected.

* ocean: a drivable boat in lsystem_coast (O11c)

A 5 m skiff with an outboard, a cvc::physics boat in the debris' world,
floated by the hull mesh it is drawn as. I/J/K/L and the panel's Boat
section drive it through coast.boat.* knobs; C toggles a chase camera
that also brings the sea's wake window along. Its columns feed the wake
window like the debris', and the sea's shader discards water inside the
hull (D5).

--boat-check drives a scripted course and reports speed, turning circle,
heave/pitch/roll on the lee and along the reflecting south-west shore,
and the wake's angle at two speeds; --snap writes frames at given times.

* ocean: EWave's finite() helper is finite_value(), clear of glibc's ::finite

GCC's glibc declares ::finite(double), so inside EWave's member functions an unqualified
finite() found both it and the file's own helper and was ambiguous; MSVC has no ::finite,
so only the Linux lanes failed to build cvcgl_ewave. Rename the helper; nothing else
changes.

* ocean: no-flux walls as a symmetric operator with a symplectic step (O8c)

The ghost-cell walls overwrote the wall cells with the water's mirror image
after each exact step: an oblique projection, unstable wherever the image
was not an exact mirror (a disc grew 31x in 2000 s, a thin wall 1e72x).
They are replaced by a scheme that conserves energy by construction, and
no_flux walls are the default again.

The state lives on the water; R extends it over the window (ghost cells
take their mirror image), R^T folds back, S = R^T G R is symmetric positive
semidefinite for any ghosts and weights, and M is the lumped mass (the row
sums of R^T R, ewave_lumped_mass). Stormer-Verlet in substeps that keep
omega_max dt_s <= 1.8 (ewave_substeps): S <= max(G) M bounds every mode
inside the limit, and the step conserves its modified energy exactly, so
nothing can grow at any dt. G is kappa~ = 4 sin^2(omega dt_s / 2) /
(g dt_s^2), so open water keeps eWave's exact dispersion (with kappa a
straight wall's reflection was 55 % off its even image at dt 0.1 s).
damping_k2, the beach and the sponge act on h through M-contractions;
the global damping on both. Windows without ghosts keep the exact step bit
for bit (the zero-walls pin 0xa4933455f6946eca holds).

Accuracy: the fold carries G's response at every ghost back into the water,
so an image cut short (or two shores' images meeting in a thin wall) shows
at the cut's mirror distance. The default band now reaches as far as the
image does (ghost_cells = 4096), and the weights taper to 0 over 8 cells
near the cuts and seams that remain. No water cell is read by more than 12
ghosts (whole ghosts dropped, farthest first, on CPU and GPU alike).

Measured (Windows): a no-flux channel is the exact Neumann operator
(2.9e-15) and its mode matches Stormer-Verlet's discrete solution to
4e-14; broadband noise in seven closed basins for 20000 steps at omega_max
dt 1.8, 0.25 s and 1/30 s keeps the modified energy within 1.3e-14 and
energy() never above its start; the straight wall matches the even image
to 2.9e-14 without the sponge and 2.2 % with it (6.8 % before), gain 1.90,
slope +1.001; rings in closed ponds lose nothing over 300 s; thin walls
leak 10.8 / 5.7 / 3.0 % at 3 / 6 / 12 m. New no_flux pin
0x40cb161804c270ca (Linux and macOS to be confirmed by CI).

EWave runs the same scheme from the same CPU tables: per substep a fill
pass, the forward butterflies, a multiply pass, the inverse butterflies
and a gather pass (readers in six RGBA32F textures, 1 / M in an R32F one):
4 log2 n + 3 = 35 passes at 256^2, plus one real-space pass a step (36 at
1/30 s, against 34 without walls). It agrees with the CPU to 1e-5 RMS,
reflects crest for crest (2.1 % against the even image) and stays bounded
over a long broadband run. Roadmap section 6's O8c block is rewritten.

* ocean: address review of O11c

lsystem_coast draws the D5 hole from the pose present() posed the hull
with (a group of one in the binding), not a second tracker sample that a
threaded physics step could land between. --boat-check prints the wake
window's depth and depth Froude number; the new knob coast.wake.depth
forces the window's depth, and a deep rerun shows the full-throttle
narrowing is the length Froude number's, not the shallow window's.
--snap no longer puts its tag into a dotted directory name. The roadmap
has coast.boat.enabled's sense right and the depth result.

* ocean: sea_surface keeps its last source in the frame, not a thread_local

The writable-data scan (#1152 made its allowlist a ratchet) refuses process-wide state, and
sea_surface::source kept its last source in a thread_local (O7c, #1159), so every PR's
package-linux release-grpc lane now fails on master's code. The memo moves into the time's
frame, under the mutex the frame already has for its lattice: a frame is the surface at one
time, so the point alone is the key, and as a memo of a pure function it changes no value.
ocean_sea_test (19, pins unchanged) and physics_field_test (22, goldens unchanged) pass; the
exact height-and-velocity pair still costs about what it did (3.8 us, 1.76 us on the lattice).

* ocean: address review of the stable no-flux walls

- The symmetric step's substep no longer follows the caller's dt. kappa~
  and Stormer-Verlet's invariant both depend on it, so a dt that changed
  between steps switched between maps with different invariants and grew
  by parametric resonance (the review: a disc 1e103-fold in 4000 steps of
  0.136 and 0.101 s in turn). A window now has one substep,
  ewave_params::substep (default 1/60 s, capped at 1.8 / omega_max):
  step(dt) runs whole substeps (ewave_substep_count) and carries the rest
  in pending(). The beach, sponge, global damping and damping_k2 act every
  substep for dt_s, so every substep is the same linear map whatever the
  dts. Same on the GPU: the count is made on the host in double, and the
  real-space factors move into the gather pass. New tests
  (VariableStepsAreStable on the CPU, jittered dt in cvcgl_ewave): the
  modified energy holds to 6e-15 under alternating and jittered dt.
- A wall one cell thick is a seam: its nearest water lies on opposite
  sides, so its image tapers to almost 0 instead of holding the front
  water beside the water behind. It leaked 87.6 %; now 40.4 % (zero walls
  41.1 %). AThinWallLeaksLittle covers 1, 2 and 4 cells.
- ewave_wall_ghosts finds each wall cell's nearest water with a distance
  transform, O(n^2) whatever the band (1024^2 set_mask: 0.21-0.25 s,
  against 10 s), ties exact within 32 cells of the shore.
- The GPU gather decodes a reader's cell by truncation (int(cell + 0.5)
  rounded odd indices up past 2^23); the header gives the reader
  textures' memory.
- Docs: stability now holds for any sequence of steps; the 2.2 %
  reflection is the best case where the whole image fits; the mean
  potential's drift where S annihilates constants is documented (not
  gauged: the GPU would need a reduction).
- The no_flux pin is re-measured on Windows: 0x9d1fde2b635d7dbf. The
  zero-walls pin 0xa4933455f6946eca holds.

* ocean: no-flux damping_k2 takes what zero walls take

The symmetric step applied damping_k2 as h <- M^-1 R^T F R h. At F = 1 that
is not the identity: M^-1 R^T R averages each water cell a ghost reads with
the corners round the ghost's mirror point, wherever that point falls between
cells. Run once a substep, the smoothing took lsystem_coast's crater lake's
ring faster under no-flux banks than under zero ones (20 % of the energy left
10 s after the drop, against 55 %).

The filter is now h <- h - M^-1 R^T (1 - F) R h (1 - F as -expm1, and as
x (1 - x/2) below 1e-3 in the GPU's float): the same beside a straight wall,
still self-adjoint under M with eigenvalues in (0, 1], and the identity as F
goes to 1. In a disc 36 m across with damping_k2 2e-3, the energy left after
10 s is 75.7 % under no-flux walls against 75.5 % under zero walls (the first
form: 49.3 %); at damping_k2 1e-15 the heights match the undamped run to
1.5e-13 (the first form: 99 % off). New test:
DampingK2TakesTheSameShareWhateverTheWalls. The no-flux digest pin is
re-measured.

lsystem_coast's lake now keeps 48 % after 10 s (13 % with absorbing banks).
The rest of the gap to 55 % is the check's reading, the water's sum of h^2
without M, which sits near 1 / mean(M) of the conserved energy once the ring
reaches the banks. The roadmap's O8c and O9 blocks have the numbers.

* ocean: back out #1193's source memo, superseded by #1181

* ocean: the sea's height for its wind (O2b)

The cascades' sea was about 2.3 times JONSWAP's significant height for
its wind, and lsystem_coast drew it at wave_amp 1.2: 5.7 m Hs at 9 m/s
where JONSWAP gives 2.2 m. Two errors in O2's library:

- h0 was twice its size. A texel's mode is h0(k) e^(iwt) +
  conj h0(-k) e^(-iwt), so its share of the surface's variance is
  E|h0(k)|^2 + E|h0(-k)|^2. With h0 = g sqrt(S) dk and E|g|^2 = 2 that
  is 4 S dk^2. h0 is now g sqrt(S) dk / 2.
- The spread's cos^2 part, (2/pi) cos^2, spanned the whole turn
  (ABYSSAL's), where it integrates to 2, with a lobe upwind. It now
  covers the downwind half, so the spread integrates to 1.

The cascades now hold JONSWAP's Hs within 2 % from 4 to 25 m/s, and
the sea they make is within 5 % over four seeds. lsystem_coast's
wave_amp defaults to 1, and --boat-check sets only the wind (4 m/s,
0.54 m Hs); it also passes at the default 9 m/s now.

New tests OceanH0.TheCascadesHoldTheWindSeasHeight and
OceanSea.TheSeaHasTheWindsHeight; the spread, variance and h0-energy
tests expect the corrected values; five digest pins move with the sea.

* ocean_sea_test: drop the memo test the master merge doubled

* ocean_ewave_test: the basin stability runs take a twentieth of the steps in unoptimized builds

Ewave.WallsAreStable and Ewave.VariableStepsAreStable step a 64^2 basin tens of
thousands of times: 83-129 s and 29-42 s in a Release build, and past ctest's
300 s in the Debug package lanes (package-linux libcvc-debug and -debug-grpc on
#1194), which run these tests about 10 times slower.

As #908 did for the stepped mesher tests, gated on the optimizer rather than
NDEBUG: an unoptimized build divides run_basin's step count and its energy()
sampling interval by kBasinScale (20), so each quarter still averages as many
samples. The printouts report the steps actually run.

Forced to 20 in a Release build, both pass in 4.5 s and 1.7 s: modified energy
within 8.2e-15 (limit 1e-9), last-quarter drift at most 0.0008 (limit 0.005),
damped runs end at 1.6e-6 of their start (limit 0.5). Optimized builds are
unchanged (18/18 ocean_ewave_test, full counts).

* ocean: whitecaps cover Monahan's share for the wind (O5, first part)

On the calibrated sea (O2b) the wave foam's fixed threshold drew nothing: the
least of the cascades' Jacobians over lsystem_coast's tile is 0.49-0.59 at every
wind from 4 to 25 m/s, so foam_bias 0.48 met no water. Whitecaps should cover
W = min(3.84e-6 U^3.41, 0.16) of the sea (Monahan and O'Muircheartaigh 1980):
0.04 % at 4 m/s, 0.69 % at 9, 3.9 % at 15, 16 % at 25.

cvc::ocean::foam_field (inc/cvc/ocean/whitecaps.h) evolves the cascades' h0 on
the CPU as OceanFFT does, takes the least J at the drawn grid's vertices, linear
over its triangles, at two times, weighs each sample by its share of the drawn
surface (|J|), and bisects for the bias whose mean foam is W. monahan_coverage
gives W.

The shader's ramp narrows from 0.85 to 0.1 (coast.water.foam_ramp): the least J
sits only ~0.35 under its mean, so a wide ramp meets W with a faint veil (at
9 m/s, faint foam on 51 % of the sea with 0.85, 14 % with ABYSSAL's 0.3, none of
it half white). Each fragment's J is shifted by fray x (noise - 0.5) on the
water's rest position (coast.water.foam_fray, 0.12), so patches have ragged
edges instead of the straight lines J makes across a 2 m triangle; the bias
models the fray by 16 quantiles of the noise's distribution.

lsystem_coast finds the bias at start-up and again once h0, the chop, the ramp,
the fray or coast.water.whitecaps (a scale on W, the panel's "whitecaps" slider)
has changed and held for 10 frames. coast.water.foam_bias >= 0 still fixes it.
On its sea the bias runs 0.747 / 0.796 / 0.822 / 0.856 at 4 / 9 / 15 / 25 m/s,
with 0.68-0.95 of W at least half white; a field takes 110-250 ms (Release).

Tests (ocean_spectrum_test): OceanWhitecaps.TheFoamFieldsJacobianIsOceanFFTs
(one wave: J = 1 - 2alk cos k.x exactly), MonahansCoverage, and
TheBiasGivesMonahansShareOnTheCoastsSea. Roadmap section 8 E0b has the numbers.
The persistent foam of section 10.2 is still to do.

* cvcGL: the GPU ocean in the library (OceanFFT, its butterflies, EWave, WakeSource)

The ABYSSAL port's sources in src/cvcGL/ocean were compiled straight into
lsystem_coast and the four cvcGL ocean tests, so nothing else could use them.
O15 (OCEAN-AND-WEATHER-ROADMAP.md section 11.2) draws the sea from an Ariadne
node, which lives in cvcGL, so they join the library: a GLOB of ocean/*.cpp,
the directory a private include of cvcGL. The tests and lsystem_coast link
them from cvcGL now and keep the include directory (the headers stay private).
The examples always link the in-tree cvcGL target, the standalone
libcvc-examples recipe included, so the browser gallery is unaffected.

The shaders' namespace-scope strings become const pointers
(const char *const), so the library gains no writable data for the
writable-data scan. clang-format moved each one's first literal onto its own
line; the strings are unchanged.

Checked (MSVC Release, full build): cvcgl_ocean_fft, cvcgl_ocean_band,
cvcgl_ewave and cvcgl_wake pass (none skipped), and lsystem_coast's
--boat-check, --debris-check --wake-check and --shore-check pass.

* ariadne: the water node, terrain_lab.ari's sea, lakes and ponds as the GPU FFT ocean (O15, drawing)

A `water` scene node (src/cvcGL/ariadne/water_node.cpp, registered with the
cvcGL extensions) draws everything below `level` on a ground (`world:` a
generated_world, or `ground:` a height-field node) as lsystem_coast's GPU sea:
three OceanFFT cascades built from cvc::ocean::build_h0 for the wind, each
fading out over `shore_fade` metres of depth toward the shore, and its
Fresnel shading, shallows tinted by depth, and frayed Jacobian whitecaps.

- Meshes of its own, not the world's flat water rungs (5 m cells and coarser,
  longer than the short cascade's waves): a near grid +-192 m around the
  camera, a vertex every 2 m, displaced and faded to flat at its edge, moving
  with the camera by whole cells; and a flat far grid over the ground that gives
  way inside the near one. Dry fragments are discarded against a
  HeightFieldTexture of the ground, sampled per fragment. Both stay out of the
  scene's bounds, so the ground frames the view. terrain_lab's world sets
  `water: 0`.
- Whitecaps cover Monahan's share for the wind: the threshold comes from
  cvc::ocean::foam_field on the near grid's vertices, found again once the
  wind, chop, ramp, fray or water.whitecaps have held for 10 frames
  (water.foam_bias >= 0 fixes it by hand).
- The world's edge: when the ground's whole rim is under water (a
  generated_world with `edge: shore`, an island), the sea goes on `outer` (6 km,
  as world::outer_sea) past it; otherwise both grids clip to the ground's
  rectangle (a wall, or the world falling away). It is checked again after
  every regenerate, so the Edge picker switches it live.
- disableCoordinateShiftScale is set before the meshes' first draw: set after
  it, the far grid kept a shifted buffer and its fragments missed the bed.

Keys water.*: wind_speed, wind_dir, fetch, chop, wave_amp, whitecaps,
foam_bias, foam_ramp, foam_fray, shore_fade. Panel: water_controls.ari (INDEX
entry); terrain_lab.ari includes it (Settings > Water).

Tests: cvcgl_ariadne_realize builds a generated world plus a water node at
level 0 (a rim partly dry: the far grid ends at the ground) and at 500 m (a
rim under water: 6 km past), and checks the meshes, the bounds, the seeded keys
and the flat fallback without a window; ariadne_loader_test checks the new
component (229 pass). Rendered offscreen with arigl: terrain_lab's lakes and
sea (wall edge), and the shore edge merged in locally from feat/world-gym: the
island, the sea out to the horizon, and the near waves fading into it.
Floating bodies are the next part.

* ariadne: the water node floats bodies, drawn and headless (O15, physics)

A water node with `body: {}` is one fluid field in the scene's physics world
(inc/cvc/ariadne/scene_water.h, WaterRuntime). Its volume covers the water's
extent (the ground, and the outer sea when the rim is under water) from below
the deepest ground to 15 m over the level. Its surface is
cvc::physics::ocean_surface over a cvc::ocean::sea_surface built from the same
cascades' h0 the renderer draws (lsystem_coast's tiles and seed), so a body
lighter than water floats on the waves shown and a heavier one sinks. The
field is rebuilt when the wind, chop or wave height change, or the ground
regenerates. The drawn node (water_node.cpp) and SceneWorld::from_scene (no
renderer; the ground followed through its generated world) both run it.

SceneWorld::apply now swaps a tracked node's fields along with its bodies.
Before, a field that came in through a node's colliders was added but never
removed, so every new revision leaked one.

terrain_lab.ari gets `physics: {}`, `body: {}` on the world and the water, and
three wooden crates on the big lake north of the city.

Checked (MSVC Release):
- AriadneSceneWorld.AWaterNodesBodyFloatsWhatIsLighterThanWater: a world flooded
  to 200 m; after 10 s a density-400 raft rides at z 200.31 and a density-3000
  anchor has sunk to 182.2; after a wind change the world still holds one field.
  All 31 scene-world tests pass.
- cvcgl_ariadne_realize passes; ariadne_loader_test 229 pass.
- terrain_lab.ari run headless for 10 s: the crates at z 0.23, -0.12 and 0.98
  over 17-20 m of water.
- A drawn check (arigl snapshot of a small flooded world): a 10 m raft dropped
  from 20 m rides the waves.

Not yet: the physics sea's waves do not fade toward the shore as the drawn ones
do (that needs a shore grid).

* sky: a live sky, the sun from the light rig, and the clouds' shade on the water (O17)

O17 of OCEAN-AND-WEATHER-ROADMAP.md (F1 and A4's cloud shade on the water):

- cloud_layer::set_coverage ranks the cells' targets again at once, and the
  clouds fade in or out to them over fade_s. The automaton is untouched.
- cloud_layer::set_sun makes the maps again (the grammar bakes a little
  top-light into its field), then their self-shade, shadow patches and far
  opacity. The cells, morphs and automaton are kept, so the clouds do not
  jump. The constructor's map loop moved into make_maps().
- cloud_sky reads sky.coverage and sky.wind_az every frame (seeded from its
  props; two more sliders on sky_controls.ari). Its sun is the light rig's key,
  lighting.key_azimuth / key_elevation, when the scene has a rig; a change
  relights the deck and re-composites the shade and the far clouds at once.
  sun_az / sun_el are used only without a rig, and terrain_lab.ari drops its
  copy of the rig's angles.
- The water as a shade receiver. The water node replaces VTK's lighting, so
  the deck's rewrite of the lighting sum finds nothing in it. Once the sky has
  wired its inputs into a water mesh, the water switches that mesh to lighting
  that multiplies its sun and glints by the deck's cloudShade().
  terrain_lab.ari lists `water` among the sky's receivers.

Checked (MSVC Release):
- WorldCloudLayer.CoverageAndSunChangeLive: coverage 0.3 / 1.5 / 0.6 gives
  11 / 36 / 22 of 36 cells; a deck relit with set_sun shades and draws exactly
  as one built under that sun. 17 cloud tests pass.
- cvcgl_ariadne_realize: the seeded keys; the shade wired into both water
  meshes; cloudSunR at the props' elevation 28 until the rig's keys move it to
  elevation 50. The test passes; ariadne_loader_test 229 pass.
- terrain_lab renders without warnings.

Not done: base / top live (a new deck and new nodes) and a darkness key. Both
belong with F2's storm decks.

* water: the coast and the swell in both seas, bodies make waves, wave normals past the near grid (O15)

The water node's open items, as listed in OCEAN-AND-WEATHER-ROADMAP.md §11.2:

- The coast (scene_water.h, scene_water_shore): a shore grid over the ground (cvc::world::water_bodies,
  at most 1025 a side) and, with water.swell_height > 0, the swell's shore layer on it. The drawn
  water and the physics sea both read it: each cascade fades out as the water shoals (half its
  band's peak wavelength, at most shore_fade), sideways moves stay under 0.8 of the way to the
  shore, and the swell refracts, shoals and breaks on the beaches facing it. When the rim is sea
  and there is a swell, the grid goes one deep-water wavelength past it. The physics sea leaves out
  the swash, which the beach does not draw.
- The wake window: with body:, an eWave window (256^2 cells of 0.5 m) around the camera's target
  takes each moving body's immersed columns as its source (WakeSource), steps by the world's time,
  and moves the near grid and shades both grids; beaches absorb, steep shores reflect.
  SceneWorldBody::desc keeps a node's body description (the outline), and
  RealizedScene::scene_ticks runs closures with the realized scene and the frame's clock step.
- The far grid's normal: the long and middle cascades and the swell per fragment, fading with
  distance.
- New keys: swell_height, swell_period, swell_dir, shore_foam, wake, wake_foam; the Water panel
  has their controls. terrain_lab.ari has a 0.8 m, 9 s swell.

Test: AWaterNodesSeaFadesAtTheShoreAndCarriesTheSwell (over a beach: the wind sea 0.794 m RMS in
15 m of water, 0.011 m in 0.3 m; a 1 m swell 0.245 m RMS offshore, 0.076 m where it breaks).

* water: the swash on the beach, drawn on the ground and in the physics sea (O15)

With a swell, the water node draws lsystem_coast's swash in the fragment shader of every mesh
under its ground node (the world: / ground: node; regenerated chunks and late LOD rungs are wired
when the scene's tree changes, as the cloud deck wires its receivers): each wave's front runs up
to the shore layer's runup and drains back, a film with a lace of foam, the sand dark and glossy
behind it until it dries. The physics sea carries the same swash (sea_params::swash); swash: 0
leaves it out of both.

- The fragment's world position is its view position times the inverse model-view (as the
  cloud deck's shade finds it). The code runs at //VTK::Picking::Impl, after VTK's texture (at
  //VTK::TCoord::Impl VTK stopped applying the ground's texture), and reads its own RG32F texture
  (phase, runup).
- GeometryNode::ShaderInputs::skip_shadow_bake (new): a shared set left out of a shadow map's
  bake. There the fragment's colour is the occluder's depth, and the swash rewrote it (with the
  light's view position against the main camera's matrix), so the map was wrong and the whole
  ground fell into shade; never set in the bake's program, uSwashOn reads 0.

Tests: AWaterNodesSeaFadesAtTheShoreAndCarriesTheSwell (sand 0.3 m over the level under the swash
78 % of the time, 0 % with swash: 0); cvcgl_ariadne_realize (a swell puts the swash on the 21
ground meshes, out of the bake).

* docs(roadmap): the bay sliver is fixed in the world builder (#1271)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant