Repository navigation
cvc::physics: a fluid field's free surface, read at a pinned field time (O6a) - #1139
Merged
Merged
Conversation
…the same on every platform Before O6 puts the sea into the physics state_hash, h0 and the shore layer must give the same bits on every platform; they called libm, whose transcendentals each platform rounds its own way (docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md, B1's open item). - cvc::physics's private det_math moves to cvc::algo as cvc/algo/det_math.h (standard library only), and gains exp, log, pow, sinh, cosh, acos and hypot. pow carries log x as a double-double and multiplies it by y exactly, so it stays within 3 ULP of libm even where y log x is large; y = 1, 2, -1 and 0.5 are one correctly rounded operation each. physics/det_math.h is now a namespace alias, so the physics step is unchanged (its bit pins and physics_replay_test hold). - cvc::ocean's spectrum, h0 and shore layer call det:: in place of std::, and are built without FMA contraction. cvc::ocean may now include cvc::algo (which depends on nothing). - algo_det_math_test (was physics_det_math_test) measures each new function against libm over the ranges the ocean uses, checks libm's special cases (pow's C99 Annex F table), and pins bits. ocean_spectrum_test and ocean_shore_test pin digests of the spectrum, h0 and the shore layer's planes, evaluate() and swash(), measured on Windows, for CI to check elsewhere.
…me (O6a) O6 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md, its B5 hook (decision D2, a virtual interface) and B6's tests. - cvc/physics/fluid_surface.h: fluid_surface (level, height, velocity, digest), still_surface (a level and a uniform current) and wave_train_surface (linear Airy trains, finite-depth dispersion, cosh/sinh decay, det_math throughout so it is the same on every platform). - field::surface, on a fluid only: field_set::apply clips each cell's top to the surface's height over its clipped centre, and drag and damping use the surface's velocity in place of the velocity volumes. - world::field_time(): t0 + (tick - tick0) dt. follow()'s first call anchors it to the clock's t(), so physics reads the surface at the time a renderer draws it; set_field_time sets it. - With a free surface, save() appends a section with the field-time anchor and each surface's digest, so state_hash() covers them and restore() refuses other surfaces. Without one the format is unchanged: every existing hash and the replay trace hold. - physics_field_test: half draft on calm water at two levels; heave in a 4 s swell in phase with the surface (correlation > 0.97), about as high, at the swell's period; the field time follows the clock; hashes agree for one surface and differ for another amplitude or field time; a save restores the field time and refuses another surface.
transfix
enabled auto-merge (squash)
November 10, 2026 22:31
…rface # Conflicts: # src/cvc/CMakeLists.txt
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.
O6a in
docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md: B5's hook oncvc::physics::fieldand B6's tests. A fluid field gets a free surface, so a floating body rides the waves a renderer draws.wave_train_surfaceusesdet::exp,coshandsinhfrom #1138 (merged), and master is merged in, so the diff is O6a alone.cvc/physics/fluid_surface.h(decision D2: a virtual interface)fluid_surfacehaslevel(x, y),height(x, y, t),velocity(p, t)anddigest(). A surface must be deterministic, the same on every platform and immutable while a field holds it. Lakes, streams and the sea are all one type.still_surfaceis a level with an optional uniform current.wave_train_surfaceis linear Airy trains on water of one depth (or deep water):det::throughout.The cvc::ocean-backed sea (the physics band's FFT and the shore layer) is O7, as the roadmap's §12 has it.
The field step
field::surfaceis allowed on a fluid only. A medium or a flow with one is refused.In
field_set::apply:min(box top, height(x, y, t))over its clipped centre;velocity(p, t)in place of the velocity volumes.Nothing else in the loop changed.
The time base, pinned
The roadmap flagged this:
world::time()is not the clock's time, sincefollow()anchors at the clock's tick.world::field_time()ist0 + (tick − tick0)·dt.follow()'s first call setst0to the clock'st(). Physics then reads the surface at the time a renderer drawing it at the clock's time uses.set_field_time(t)sets it explicitly. Before either, it equalstime().State
save()appends a section (CVCSURF1) with the field-time anchor and each surface's digest, sostate_hash()covers both.restore()restores the anchor and refuses a world whose surfaces differ.physics_replay_test's trace still hold.Tests (
physics_field_test,PhysicsFluidSurface.*, 7 new)still_surfaceandwave_train_surfaceas Airy says:set_field_timesets it.Still to come:
Checked locally (Windows Release, GL build)
physics_field_test17, and every otherphysics_*test.physics_replay_test(the recorded trace) andcvcgl_physics_scene_binding.git clang-format18.1.8 is clean on the changed lines.Next
fluid_surfaceand the field time.