Repository navigation
Water node: the drawn wake window's mask from shore_grid_mask (stacked on #1532) - #1540
Merged
Merged
Conversation
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.
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.
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.cppkept 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_wakemakes oneshore_grid_maskper 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.water_node.cpp, inwake_mask. It samplesgrid->depthwithshore_grid_mask::sample, which is now public (inc/cvc/physics/shore_mask.h). That is the same bilinear read the copy did.WaterRT::wakeShoreis now ashared_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 onlyfield_step.h) plus the same commit, with the same changed lines. Master's newerwater_node.cppdiffers from #1532's only outside the wake code. I haven't built this exact branch locally; CI builds it.wake_mask, copied verbatim, against the newcoast_mask+wake_mask, compared bit for bit:place_wakewas instrumented temporarily (not in this PR) to compute master's formula beside the new path on every placement. A rendered water node withbody:and a launch, with the camera circling 15 to 65 m round the middle (900 frames):cvcgl_ewavePASS (0 checks failed),cvcgl_wakePASS (0 failed),cvcgl_ariadne_physicsOK,cvcgl_ariadne_realizePASSED (0 failures). None of these reachesplace_wake: the wake window needs a rendered water node withbody:, which is why the instrumented scene above was needed.cvcgl_ari_goldengives 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
shore_mask.cppis built with-ffp-contract=offandwater_node.cppis 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.