Skip to content

Water node: the drawn wake window's mask from shore_grid_mask (stacked on #1532) - #1540

Merged
transfix merged 4 commits into
masterfrom
feat/drawn-wake-shore-mask
Nov 26, 2026
Merged

transfix merged 4 commits into
masterfrom
feat/drawn-wake-shore-mask

Conversation

@transfix

Copy link
Copy Markdown
Owner

Stacked on #1532. The base is feat/wake-shores-depth, so the diff shows only this change. Once #1532 merges, I'll merge master into this branch and retarget it to master.

The drawn wake window in the water node now builds its mask with cvc::physics::shore_grid_mask, the class the physics wake uses since #1532. Before this, src/cvcGL/ariadne/water_node.cpp kept its own copy of the formula (grid_sample + wake_mask), because the #1532 session could not build cvcGL. That copy is gone, so the drawn and physics masks can no longer drift apart. Every cell's value is unchanged.

What changed

  • place_wake makes one shore_grid_mask per coast (coast_mask, from the coast's grid, its slope when it has one per sample, and its shore layer). It reads the mask at each window cell.
  • The window's mean water depth over its wet cells stays in water_node.cpp, in wake_mask. It samples grid->depth with shore_grid_mask::sample, which is now public (inc/cvc/physics/shore_mask.h). That is the same bilinear read the copy did.
  • WaterRT::wakeShore is now a shared_ptr, so a new coast allocated at a freed one's address can't be taken for the old one and keep its mask.
  • OCEAN-AND-WEATHER-ROADMAP.md: the "Not in C5" entry no longer lists the formula copy. The drawn window still keeps its own sources; it does not draw the physics states.

Checks run locally

Windows, MSVC Release, Ninja, CVC_BUILD_CVCGL=ON. The checks ran on master 014eef2 with #1532's first head (87198ea) merged in locally. This branch is #1532's head (af27e62, which changes only field_step.h) plus the same commit, with the same changed lines. Master's newer water_node.cpp differs from #1532's only outside the wake code. I haven't built this exact branch locally; CI builds it.

  • Old against new, standalone. Master's wake_mask, copied verbatim, against the new coast_mask + wake_mask, compared bit for bit:
    • 33,856 windows (128 and 256 cells of 0.5 m), placed over each grid and past its edges, on whole cells and off them.
    • 1,386,741,760 cells: 0 differ, and 0 mean depths differ.
    • Grids: terrain_lab's world (wall edge and shore edge, swell 0, 0.8 and 2.5 m, each with and without the slope), a beach ramp with a cliff and a swell, and a synthetic bay, island and pond. The synthetic grid has NaN and inf in the shore distance, slope and K_r, K_r from -0.2 to 1.5, its layer on another grid, a slope of the wrong size and an empty layer.
  • Old against new, in the water node. place_wake was instrumented temporarily (not in this PR) to compute master's formula beside the new path on every placement. A rendered water node with body: and a launch, with the camera circling 15 to 65 m round the middle (900 frames):
    • Over the boat test's lake: 83 placements, 5,439,488 cells. 0 differ, and the same mean depth every time.
    • Over an island with a swell (so the coast has a shore layer): 83 placements, 5,439,488 cells. 0 differ, and the same mean depth every time.
  • Tests: cvcgl_ewave PASS (0 checks failed), cvcgl_wake PASS (0 failed), cvcgl_ariadne_physics OK, cvcgl_ariadne_realize PASSED (0 failures). None of these reaches place_wake: the wake window needs a rendered water node with body:, which is why the instrumented scene above was needed.
  • Goldens: no golden has a water node. cvcgl_ari_golden gives the same verdicts on this branch and on its base, with the same pixel counts beyond tolerance. The 10 failures on this box are volume, skeleton and contour scenes, against goldens made under Mesa llvmpipe; they fail the same way on the base. Two volume scenes' sub-tolerance counts move by a few pixels between runs, on the base too.
  • git-clang-format HEAD~1: no changes.

Not checked

  • Linux, macOS and wasm: CI runs these. shore_mask.cpp is built with -ffp-contract=off and water_node.cpp is not. Where Clang contracts by default (macOS arm64), the old copy may have differed from the physics mask in the last bits. The drawn mask now equals the physics mask there too.

Fill the open gaps in the opt-in physics wake (wake_push), the "Not in C5"
list of OCEAN-AND-WEATHER-ROADMAP.md:

- Shores (C6). field_wake::shore (a wake_shore, field.h) masks the window
  from the coast wherever it goes, each cell from its world cell. With a mask
  the window steps by ewave's no-flux step in whole substeps of the wave
  step, sources go in times the mask, and reads beside a wall are one-sided.
  shore_grid_mask (shore_mask.h) is the drawn window's mask over a
  water_bodies shore grid: 0 on land, a 3 m beach ramp to 0.5, 1 to the
  waterline where steep. The water node's wake_push takes its coast's mask.
- Depth. Each wave state keeps its motion at 1-5 depths below the top (per
  mode e^{-kd}, or cosh/sinh over the window's depth; extended past walls by
  the ghosts), as deep as the bodies in the window reach. Cells' drag, hull
  triangles' velocity terms and the Froude-Krylov push (at the displaced
  water's centroid depth) read it at their depth.
- water_at. world::water_at(p) adds every body's waves; water_at(p, self)
  the others'. A boat's propeller and rudder read the others' waves (in
  boat.cpp only the hull body is passed to its two water reads), and
  dyn_boat_plant's books read them at the same points.

The wake section is CVCWAKE2 (each wake's shore digest and the depths kept);
CVCWAKE1 states restore as wakes without shores.

With wake_push off nothing new runs: physics_replay's trace and every other
golden stand. PhysicsFieldWake.CrossPlatformGoldenHash is re-pinned from
0x7a5a40b81d1d2433 to 0xc72e26b4ef0f764a because depth decay is on for every
wake: the crates' and the boat's reads of the others' waves now decay below
the top (without a shore the wave step itself is unchanged). The new
PhysicsFieldWakeShore.CrossPlatformGoldenHash pins a wake with a coast at
0x89789ba92fbd1853. Both measured on Windows; CI checks Linux, macOS and wasm.

ADroppedCratesRingRocksItsNeighbour now asks that both crates made waves
during the run, not that both hold a slot at the last step: the dropped crate
is put to sleep and woken again and again by its neighbour's waves, and with
depth it happens to be asleep at step 900. AWindowOutOfRangeIsRefused follows
the CVCWAKE2 layout.
GCC and Clang refuse a default argument `= {}` of a class nested in the
class whose member function declares it, when that nested class has default
member initializers ("default member initializer for 'on' needed within
definition of enclosing class"); MSVC takes it. Every Linux and wasm job of
#1532 failed on it in field_step.h. The struct is now
detail::water_wake_read, declared before field_set, with
field_set::wake_read kept as an alias, so boat.cpp is unchanged.

Checked with clang-cl 19 (/Zs) over every file the PR touches, which
reproduces the CI error on the old form.
The GPU wake window in src/cvcGL/ariadne/water_node.cpp built its mask
with its own copy of the formula that cvc::physics::shore_grid_mask
(#1532) uses for the physics wake: 0 on land, a 3 m beach ramp from 1
down to 0.5, 1 up to the waterline where the shore layer's K_r or the
ground's slope says it is steep. place_wake now makes one
shore_grid_mask per coast and reads it at each window cell. The copy
and its grid_sample are gone, so the drawn mask and the physics mask
can't drift apart.

The window's mean water depth over its wet cells stays in
water_node.cpp. It samples the grid's depth with
shore_grid_mask::sample, which is now public. The window holds the
coast it took its mask from as a shared_ptr, so a new coast at a freed
one's address can't be taken for it.

The old formula and the new path match bit for bit at every window
cell and in the mean depth. That covers 1.39e9 cells over 33,856
windows on terrain_lab's coasts, a beach with a cliff and synthetic
grids with NaN, inf and K_r above 1, and 166 window placements in a
rendered water node with body: over a lake and an island with a swell.
Base automatically changed from feat/wake-shores-depth to master November 26, 2026 06:15
#1532 squash-merged as dcc3c57. Conflicts only where this branch edits #1532's lines (shore_mask.h's header comment and sample(), two roadmap lines); kept this branch's side, the rest is master's.
@transfix
transfix enabled auto-merge (squash) November 26, 2026 07:03
@transfix
transfix merged commit ee2c02d into master Nov 26, 2026
30 checks passed
@transfix
transfix deleted the feat/drawn-wake-shore-mask branch November 26, 2026 09:10
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