Repository navigation
cvc::ocean: the sea a floating body feels, and physics floats bodies on it (O7a) - #1142
Merged
Merged
Conversation
…on it (O7a) cvc/ocean/fft.h: a deterministic radix-2 FFT (det:: twiddles, no FMA contraction). cvc/ocean/sea_surface.h: lsystem_coast's water vertex shader on the CPU, without the waves too short to move a body. Each cascade keeps its lowest band.modes^2 wavenumbers, evolved as OceanFFT evolves them and transformed onto a band.grid^2 lattice (height + i w, D_x + i D_y, u + i v); the cascades fade with the still depth, the sideways move is capped at 0.8 of the way to the shore, and the shore layer and the swash join them. The height over a point is its source's (B3, by Broyden's method: 3 cm worst after 4 steps on a steep sea where the fixed point misses by 58 cm); the velocity is the cascades' time derivatives decaying with depth, the shore layer's finite-depth orbital motion (shore_layer::velocity, new) with breakers' bores, and the swash's run up and down the slope (swash_sample::rate, new). cvc/physics/ocean_surface.h: a sea_surface behind fluid_surface. A slab rides the open sea in step with the surface at its centre (correlation > 0.95). ocean_sea_test (16) and PhysicsOceanSurface (3) cover it; OceanSea.IsTheSameOnEveryPlatform and PhysicsOceanSurface.CrossPlatformGoldenHash pin values measured on Windows.
…/ocean-sea-surface # Conflicts: # src/cvc/tests/physics_field_test.cpp
transfix
enabled auto-merge (squash)
November 11, 2026 04:12
transfix
added a commit
that referenced
this pull request
Nov 11, 2026
OceanSea.IsTheSameOnEveryPlatform (#1142) fails on both macOS arm64 recipe lanes (digest 0x1966448ffbcd6035, not 0x21bcce29d45653a8); #1142 merged with its macOS lanes cancelled, so this is the first time they ran it. cvc::ocean's sources are built with -ffp-contract=off, but the test computes the sea's sample points itself (x = 5.0 + 2.6 * i, y = 0.5 + 0.13 * i), and clang contracts those into FMAs on aarch64. With one rounding instead of two, x differs at i = 23 and y at i = 29 and 58, so the sea is sampled elsewhere and the digest moves. x86_64 Linux and MSVC do not contract here, so they agree with the Windows value. Build ocean_sea_test.cpp with -ffp-contract=off (/fp:precise on MSVC), as nav_potential_test and the dyn plant tests are for the same reason.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O7a in
docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md(B2–B4): the sea a floating body feels is the sea lsystem_coast draws, computed on the CPU and deterministic.cvc::physicsfloats bodies on it.O7 is split in three, as O4 was:
cvc/ocean/fft.hA radix-2 FFT. Its twiddles come from
det::and it is built without FMA contraction, so it gives the same bits on every platform.cvc/ocean/sea_surface.hThis is lsystem_coast's water vertex shader on the CPU, without the waves too short to move a body.
B2, the physics band.
Each cascade keeps its lowest
band.modes² wavenumbers, with |m| < modes/2. That set is closed under k → −k, so every field it packs is real.The modes evolve as OceanFFT evolves them:
h0 e^{iωt} + conj h0(−k) e^{−iωt}, with OceanFFT's dispersion.Three complex FFTs onto a
band.grid² lattice give the height + i w, D_x + i D_y and u + i v. Catmull-Rom splines read the lattice between its points.h0 is band-limited per cascade. lsystem_coast's 251 m and 83 m cascades have no modes past |m| = 12, so 32 modes keep them whole, bit for bit. Only the 29 m cascade loses waves to the band: those under 1.8 m.
The default is 32 modes on a 64 lattice. O7b chooses M against the residual.
Measured cost per step, three cascades, MSVC Release:
The shader's composition. Each cascade fades with the still depth. The sideways move is capped at 0.8 of the way to the shore. The shore layer adds its swell, and on the beach the swash adds the run-up.
wave_ampandchopwork like the shader's uniforms.B3, the height over a point. The surface over (x, y) is the point x₀ that the shader moves there: x₀ + D(x₀) = (x, y).
B4, the velocity.
shore_layer::velocity). At the surface its vertical velocity is dη/dt.bores, a breaking crest also carries the water near the surface shoreward at the phase speed, scaled by its breaking (the surf zone's roller). Linear waves carry nothing over a period; the bore is what carries floating things in.swash_sample::rate), at most √(2gR).Determinism and threads.
det::and the FFT.digest()covers every input: the parameters, each h0 texel, the grid's depth and shore planes, and the shore layer.cvc/physics/ocean_surface.hocean_surfaceputs asea_surfacebehindfluid_surface, so a fluid field's free surface can be the sea.Tests
ocean_sea_test, 16 tests.OceanSea.IsTheSameOnEveryPlatform.physics_field_test, new testsPhysicsOceanSurface.*.PhysicsOceanSurface.CrossPlatformGoldenHash(315e7d5f0aed8af0).Both pins were measured on Windows. This PR's Linux and macOS jobs are their first cross-platform check.
Checked locally (Windows Release, GL build)
ocean_sea_test16,ocean_shore_test16 (its pinned digest is unchanged),ocean_spectrum_test.physics_field_test21, everyPhysics*gtest (136, 2 skipped by design),physics_replay_test(unchanged),pycvc_physics,cvcgl_physics_scene_binding,cvcgl_ocean_fft.git clang-formatis clean.Next