Repository navigation
physics, ariadne: the waves floating bodies make push the others, opt-in (C5, D6) - #1344
Merged
Merged
Conversation
…-in (C5, D6) A fluid with a free surface may keep a wake (cvc::physics::field_wake, field::wake; off by default): a window of cvc::ocean::ewave cells around the bodies in its water, its boats first, and one wave state in it per body that makes waves, its source the body's immersed columns' change (add_immersion). The states step by ewave's exact step inside the physics step, every period in whole steps, and every body reads the sum of the others' waves, never its own: their height under its cells and hull, their velocity for its drag and damping, their acceleration for an inertial fluid's Froude-Krylov push. A body's own waves read back would cancel its heave's restoring force as it moves and price its wave-making twice. A sleeping body the others' waves reach is woken. The window and the states are world state: a save() section after the boats', so state_hash() covers them and restore() brings them back. set_field with the same wake keeps the waves. With no wake the step and the state are unchanged, so every pinned hash stands. Ariadne: a water node's wake_push key (and wake_push_cells, wake_push_cell, wake_push_depth props) gives its field a wake; SceneWorld sets such a field in place when the sea takes a new keyframe, so the waves survive it. water_controls.ari gets a "Wakes push bodies" checkbox. Tests: PhysicsFieldWake.* (a body alone floats bit for bit as without a wake; a crate dropped 5 m off rocks a sleeping one only with a wake; save/restore, field workers, set_field and the window following its bodies); AriadneBoatNode.WakePushLetsOneBoatsWakeMoveAnother and TheWakesPushIsTheSameAtAnyFramePacing. Docs: the roadmap's C5 "as built", D6 and status line, ARIADNE.md's water node and PHYSICS_API.md.
Fixes the review of the opt-in wake on a fluid field (C5, decision D6 (b)): - Restore is all or nothing: every wake's section is parsed into a saved state first (fluid_wake::parse), then committed (commit) once all parse. A failed restore left a wake pointing at freed outlines; now it leaves the wake as it was. - A state saved by another wake is refused: the section carries every parameter (cells, cell, depth, period, damping, sponge, samples, sources), not only the id, cells and cell. - The surface the waves are cut against is the step's held surface (one per field per step, its frame worked out on the field workers), read through height_with; the first build read height() on the stepping thread, which worked the sea's frame out serially. While every body sleeps and no wave is left, nothing is read at all. - The window sits where it holds the most floating bodies (a boat counting as four), recentred by whole cells; bodies outside it make and feel none (wake_info::outside). Before, it could hold no body at all. - A body's immersion is cut against the sea plus the other bodies' waves, so a body riding another's wave does not re-radiate it, and a sleeping body makes no source. - Limits: cells 8..128 (a power of two), cell 0.05..100 m, depth finite and at most 1e4 m, period (0, 10], samples 1..8, sources 1..16; at most sources + 4 states; memory and cost documented in field.h. - Smaller: set_field with the same wake keeps it (no discarded fluid_wake); the cut shape is kept only for convex hulls; llround and cell indices are guarded; the cross-platform golden is pinned; the docs say the section is versioned by its magic alone; water_controls.ari's header is under 100 columns. Tests (physics_field_test, ariadne_scene_world_test): a failed restore leaves the wake as it was; another wake's state is refused; the window holds the bodies; packed crates stay bounded and sleep; a sleeping world reads no surface (812 reads in 100 steps before, 0 after); the wake's cost on a three-cascade sea; the pinned golden; the same push at uneven frame pacing (frames of 1, 3, 2, 5, 7 quanta); the wake's waves survive a new sea keyframe. Each behaviour test fails on the first build. Docs: ARIADNE.md, PHYSICS_API.md and the roadmap's C5 "as built" (with the measurements; the serial frame's cost is not established on this machine).
The re-review of the opt-in wake (C5): - A body that falls asleep gives its slot up, as one that leaves the window or the world does: its state fades on, and woken it takes a free slot again (its columns then its last). A free slot goes to an awake boat first, then to the body nearest the window's centre, id order breaking ties. Before, sleepers kept their slots, so crates that settled held them all and a boat that came later made no waves. The rest flag is gone with it, and the docs' "at most sources awake bodies" now holds. - Placing the window weighs at most 64 proposals a wave step: every boat, then the first body (by id) in each occupied square of a grid as wide as the window's inner square. Before, every body proposed and each scanned every body. - The saved section keeps the count of bodies outside the window, so wake_info::outside reads after a restore what it read before; a saved window over 2e12 cells off is refused (moving it would overflow), and a saved state with more sources than the wake allows is refused. - Small: the uneven-pacing test's comment and the roadmap say the waves' period is 4 steps at the clock's 120 Hz; the vacuous asleep check in PackedBodiesStayBoundedAndSleep is dropped; the docs say only the wakes' section is read whole before any wake takes it; physics_field_test gets a 1200 s ctest timeout for its long runs, as ocean_ewave_test has; the roadmap notes that a hand-set wind change takes its sea keyframe at a frame's time. Tests: SleepingBodiesLeaveTheirSlotsToABoat (six crates asleep, four slots: the boat takes one, its waves wake all six and move the farthest 0.64 m; before: no slot, none woken, none moved), AWindowOutOfRangeIsRefused and TheWindowHoldsTheBodies' restored outside count fail before the fix. ABodyNeverFeelsItsOwnWaves checks the crate's source while it bobs (asleep, it now has none). PackedBodiesStayBoundedAndSleep's die-down is measured against the early peak: more crates make waves now, and the last tenth's peak is 0.0058 m (0.0006 before). The golden is re-pinned to 0x7a5a40b81d1d2433 (the save gained the outside count and lost the rest flag).
…/wake-coupling # Conflicts: # docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md # inc/cvc/ariadne/scene_water.h # src/cvc/CMakeLists.txt
transfix
enabled auto-merge (squash)
November 18, 2026 10:10
transfix
added a commit
that referenced
this pull request
Nov 27, 2026
…cally, same bits) (#1562) PhysicsFieldWake.PackedBodiesStayBoundedAndSleep took 581-747 s of its 1200 s ctest budget on package-linux / libcvc-debug and timed out three times on a slow runner (#1550's). It took 269 s there on #1344; #1532 made every wake test 2.5-2.8x slower in Debug (the ring 3.0 to 8.2 s, the golden 2.4 to 5.8 s, this one 269 to 702 s). The test itself is as #1344 wrote it. Profiled locally (Debug, MSVC /Od): the calm run with a wake is 62% of the test, and 87% of that is the wake's wave step: deepen, the motion below the top that #1532 added (2 forward and ~3 inverse 64 x 64 FFTs a state a wave step), 51%; the ewave step 21%; sum, which now adds the depths, 9%. In an unoptimized build std::vector's operator[] is a call per element, and these passes made ~400k of them a state a wave step. And once every crate sleeps (~90 s into the calm run) the wake made depths for ~30 s more, while its waves died away, with nothing reading them. - fluid_wake::ready_depths: the depths are made at the first read after a wave step (in field_set::apply before the field workers' reads, when an awake body is in the wake's field, and in field_set::water_at), not at every wave step. The same inputs in the same order: the same bits. motion() reads only the layers that were made. - The wake's per-cell passes (deepen, derive, sum, the wave step's dh/dt) and fft_plan::run_2d's gather and scatter index through raw pointers: the same operations in the same order. On their own, 28% off a 20 s calm run with a wake in Debug (37.5 s to 27.1 s, three interleaved runs, the same peaks to 17 digits). - The test is two: the calm half keeps its name (and #1557's 3600 s), the swell's half is PackedBodiesStayBoundedInASwell, so each has its own ctest budget and ctest runs them side by side. What the comments claimed is now asserted too: every crate sleeps on calm water (9 of 9) and none in the swell (0 and 0). "Without one they sleep within 40" is 3 (2.55 s). Measured locally, Debug, the old and new builds run side by side on one loaded box: 283.6 s before; after, the calm half 72.5 s and the swell's 87.8 s (160.3 s). Every value the test prints is the same to the digit. No pinned hash moves: the wake golden 0xc72e26b4ef0f764a, the shore golden 0x89789ba92fbd1853, the swell and ocean scenes.
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.
The roadmap's C5 ("bodies are not pushed by wakes") and decision D6's option (b): an opt-in, deterministic CPU eWave inside the physics step, so boats feel each other's wakes and the debris' rings.
What it is
cvc::physics::field_wake/field::wake(inc/cvc/physics/field.h, privatesrc/cvc/physics/field_wake.{h,cpp}). Off by default (cells = 0). A fluid with a free surface may keep a window ofcells² cells ofcellm (64 of 1 m from the water node) on the world's whole-cell grid, centred on the boats in its water (bodies with a hull), else on all its floating bodies, moved by whole cells once their middle iscells/8off.sources, 8): its source is its immersed columns' change over the window (add_immersion, against the surface), smoothed [1 2 1]/4. The states step byewave's exact step (no walls) everyperiod(1/30 s) in whole physics steps, through one sharedewave.save()section after the boats' (CVCWAKE1), sostate_hash()covers it andrestore()restores it; other wakes or none refuse the state.set_fieldwith the same wake keeps the waves.world::field_wake_info/field_wake_heightfor renderers and tests.wake_pushkey (propswake_push_cells,wake_push_cell,wake_push_depth) sets the field's wake;SceneWorldsets such a field in place on a new sea keyframe (it removed and re-added it before, which would drop the waves; without a wake nothing changes).water_controls.ari: "Wakes push bodies".Measured (Windows, MSVC Release, Jolt)
wake_pushthe moored launch does not move at all; with it, 0.036 m heave, 0.131 m drift, 0.046 rad roll.wake_push, at a frame per clock quantum and at 0.137 s frames (which the clock caps at 8 quanta an advance): identical state hashes at every shared tick; and at frames of 1, 3, 2, 5, 7 quanta (see the review fixes).Tests run locally (all pass):
physics_field_test(36, incl. the 6 newPhysicsFieldWake.*and the golden hashes),ariadne_scene_world_test(70, incl. the 2 new boat tests),physics_boat_test,physics_dyn_boat_plant_test,physics_world_test,physics_vehicle_test,physics_hull_test,physics_immersion_test,physics_energy_test,physics_codec_test,physics_parity_test,physics_plant_host_test,physics_plant_log_test,physics_pose_tracker_test,physics_jolt_rollout_test,physics_dyn_{4w,bike}_plant_test,physics_dyn_contact_test,physics_mujoco_robot_test,physics_replay_test(checked-in trace),ocean_ewave_test,cvcgl_ewave,cvcgl_wake,cvcgl_ariadne_physics,cvcgl_ariadne_realize.Not verified / not done: Linux, macOS and the wasm replay lane (CI); the browser. The physics wake has no shores (no coast mask: it runs over land and does not reflect);
water_at(a propeller and rudder) reads the water without it; the waves' velocity is not decayed with depth; the drawn wake is unchanged and separate (not drawn from the physics states); pycvc does not bindfield::wakeyet.Docs: the roadmap's C5 "As built", D6, the boats' notes and its status line; ARIADNE.md's water node; PHYSICS_API.md.
Review fixes (eb63283)
AFailedRestoreLeavesTheWakeAsItWas(fails on the first build).AStateFromAnotherWakeIsRefused.height_with; the first build calledheight()on the stepping thread, which worked out the sea's frame serially. While every body sleeps and no wave is left nothing is read:ASleepingWorldReadsNoSurface, 812 reads in 100 steps before, 0 after. Cost on a three-cascade sea (64 modes each, 3 field workers, six crates and a boat;TheWakesCostOnTheSea, medians of three interleaved runs): 8.04 ms a step without a wake (7.24–8.45), 8.30 ms with (7.23–8.80); the first build measured the same way 7.40 vs 7.69 ms, also inside the spread, so the serial frame's cost is not established on this machine.world_clock), so it is reworded as such; newTheWakesPushIsTheSameAtUnevenFrames(frames of 1, 3, 2, 5, 7 quanta) andTheWakesWavesSurviveANewSea(a wind change makes a new sea keyframe; the wake keeps its field, window, sources and heights; fails withoutset_in_place: "unknown or removed field id 0").wake_info::outside). TestTheWindowHoldsTheBodies.PackedBodiesStayBoundedAndSleep: nine crates packed 2.2 m apart on calm water all sleep by 120 s with and without a wake, and the wake's peak falls from 0.35 m to under 0.001 m; in a 0.25 m, 5 s swell no crate sleeps with or without a wake (0 / 0), the wake's peak at most 0.18 m. The first build also stayed bounded and slept, but scattered more (swell peak 0.32 m, calm 0.82 m); the bounds the test asserts fail on it.field.h: cells 8..128 (a power of two), cell 0.05..100 m, depth finite and at most 1e4 m, period (0, 10], samples 1..8, sources 1..16; at most sources + 4 states of 80 cells² bytes each.set_fieldwith the same wake keeps it (no discardedfluid_wake); the cut shape is kept only for convex hulls;llroundand cell indices guarded;CrossPlatformGoldenHashpinned (0x8052b235300e8e23); the docs say the section is versioned by its magic alone;water_controls.ari's header under 100 columns.Tests (pass, Windows Release):
physics_field_test(43),ariadne_scene_world_test(72), the physics suites,ocean_ewave_test,physics_replay_testwith the trace,cvcgl_ewave,cvcgl_wake,cvcgl_ariadne_physics,cvcgl_ariadne_realize. Unverified: Linux, macOS, the wasm replay lane (CI), the browser.Re-review fixes (fb35d6d), then master merged (2512084)
SleepingBodiesLeaveTheirSlotsToABoat: six crates asleep and still, four slots, a boat arriving later takes a slot, its waves wake all six and move the farthest 0.64 m. Before: no slot for the boat, nothing woken or moved (fails).AWindowOutOfRangeIsRefused, fails before) or more sources than allowed. Golden re-pinned to 0x7a5a40b81d1d2433 (format change).PackedBodiesStayBoundedAndSleep: more crates now make waves (the ninth gets a freed slot); the last tenth's wave peak is 0.0058 m (0.0006 before), so its die-down bound is now 5 % of the early peak.