Skip to content

physics: land vehicles wade in water (opt-in vehicle_desc::wading) - #1348

Merged
transfix merged 1 commit into
masterfrom
feat/vehicle-wading
Nov 18, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/vehicle-wading

Conversation

@transfix

Copy link
Copy Markdown
Owner

A land vehicle in water was a sealed buoyant box: a Humvee's 9.5 m^3 chassis floated it off its wheels in about 0.8 m of water, and nothing below the box (tires, axles) felt the water at all. This adds wading, opt-in per vehicle (vehicle_desc::wading), with the presets set from published figures.

What it does

With wading.enabled (the Humvee and RoboRacer presets turn it on; a description you build is off):

  • The body floods. The field step scales a wading chassis's cells' buoyancy by wading.displacement (the body's solid and sealed parts): the Humvee keeps 0.12 of its box, so it stays on its wheels as it wades and sits on the bottom rather than floating.
  • Tires and underbody are dragged by the water, 1/2 rho C_d A |u| u, u the water's velocity (a current, a free surface's orbital motion) less the part's. A tire along its travel takes AMC 25.1591's displacement drag (C_d 0.75 on width x immersed height); across it, its immersed side. The underbody is a slab underbody_depth under the box. Integrated implicitly in its own rate, as the fields' drag is.
  • Tires float by wheel_displacement of their immersed cylinder.
  • Grip. Water over a tire's contact runs its mu to the material's new wet_friction by 3 mm (AMC 25.1591's standing water). add_world_geometry fills wet_friction from surface_class::mu_wet, the value apply_wetness uses, so rain and water agree (a rain-soaked road is no slicker under water). With a tire_pressure, standing water aquaplanes the tire: mu falls as 1 - (v/v_p)^2 to 0.05 at v_p = 0.85 x 9 sqrt(p psi) kt (AMC 25.1591, 7.1.1). Applied through a per-wheel factor in Jolt's friction combine.
  • The engine floods for good when the water over the ground at the front axle passes fording_depth: no throttle, Jolt's idle speed set to 0 so its friction stops it, no fuel in the ledger, the transmission in neutral (an automatic without line pressure). Brakes still work.
  • The water's work on tires and underbody goes to the ledger's fields. A vehicle in flowing water is kept awake, since the water keeps pushing it.
  • Readbacks: wheel_state::water_depth, water_drag; vehicle_state::water_force, engine_flooded; the snapshot JSON carries them, the wading description and material::wet_friction.

Presets: the M1097A2 fords 0.76 m (1.52 m with the deep-water kit), from AM General's M1097A2 spec sheet; tire drag from EASA AMC 25.1591; underbody depth from the spec's 16 in ground clearance and the twin's ride height; the body's displacement (0.12), the underbody's C_d and the tire pressure (Goodyear's 38 psi cross-country figure) are marked [est]. The RoboRacer's values are all [est].

Hashes

Nothing changes for a dry vehicle, wading or not: no force is added, the grip factor is 1, and the flooded engine is saved in a spare bit of the byte that already holds raw (set_controls), so an unflooded vehicle saves the same bytes. A non-vehicle body's buoyancy is multiplied by 1.0. material::wet_friction is not in the save (materials never were). All goldens unchanged: physics_world_test and physics_field_test (their cross-platform golden hashes), and the replay trace (physics_replay_test, 1240 steps; its RoboRacer drives nowhere near the pool) all match master.

Tests (Windows MSVC Release)

New in physics_vehicle_test:

  • AHumveeWadingHalfAMetreSlowsButKeepsItsTraction: in 0.5 m its tires float 3733 N (model 3738 N); 3 s at full throttle reaches 5.67 m/s against 5.44 m/s from its dry traction at each speed less the water's drag (8.94 m/s on land); coasting at 3.2 m/s it decelerates at 1.137 m/s^2 against 1.143 from the drag model; a tire's drag reads 757 N against AMC's 760 N; ledger residual 41 J with -16.0 kJ of field work.
  • InDeepWaterAHumveeStaysOnTheBottomAndItsEngineFloods: in 1.2 m it floods, its tires still carry 12.5 of 26.2 kN, the engine stops (0 rpm, no fuel), the drive command does nothing; with wading off the sealed box floats it (tires carry 0 N).
  • PastItsFordingDepthTheEngineFloodsAndAKitFordsDeeper: 0.5 m then 0.9 m: floods as the front axle crosses into the deep half (40.06 m), stops at 45 m; with fording_depth 1.52 it drives through.
  • ACurrentPushesAWadingHumvee: a 1.5 m/s current pushes 833 N along (model 833 N) and drifts it in neutral; across, 1994 N (model 2001 N), held by its tires.
  • AWadingHumveeRocksWithTheSwell: a 0.15 m, 5 s swell over 0.6 m pushes it both ways and rocks it 2.7 cm.
  • StandingWaterSoaksTheTiresGripAndItAquaplanes: mu 0.543 in 2 cm at 2 m/s (soaked 0.55), 0.780 in 1 mm, the same on a road the rain soaked, 0.202 at 14 m/s with 20 psi tires (model 0.202), 0.9 dry.
  • WadingIsStateAndItsValuesAreChecked: save after flooding, restore into a fresh world, same hash; refusals.

Suites run locally on this branch, all passing: physics_world_test (47), physics_field_test (30), physics_vehicle_test (33), physics_energy_test (11), physics_dyn_bike_plant_test (11), physics_dyn_4w_plant_test (8), physics_codec_test, world_geometry_test, physics_plant_host_test, physics_jolt_rollout_test, physics_plant_log_test, physics_boat_test, physics_dyn_boat_plant_test, physics_parity_test, physics_hull_test, physics_immersion_test, physics_pose_tracker_test, nav_plant_test (28, 5 opt-in heavy ones skipped as on master), nav_vehicle_route_test, ariadne_scene_world_test (68), and physics_replay_test against the checked-in trace. Unverified: Linux, macOS, the wasm replay lane (CI).

Docs

docs/PHYSICS_API.md ("Wading", the presets, materials, the ledger's fields, tuning) and docs/roadmap/NAV-VEHICLE-PHYSICS-ROADMAP.md (P2, Wading follow-up).

Not done

  • Water flooding in over time (a sealed car floats for a while before it sinks): displacement is fixed.
  • The wading values as world_binding knobs and in pycvc's vehicle_desc.
  • nav's spawn rules reading a vehicle's own fording_depth instead of spawn_rules::ford_depth.
  • Found on the way, not fixed here: in vehicle_set::pre_step the loop's const double t = det::tan(v.steer) shadows the field time, so a vehicle's aero reads a flow field's flow_velocity at time tan(steer) rather than the field time (master vehicle.cpp:633 and :737). Steady winds are unaffected; gusts are read at the wrong time. Fixing it changes hashes of vehicles in time-varying wind, so it is its own PR.

A vehicle's chassis met water as a sealed box: a Humvee floated off its
wheels in about 0.8 m, and nothing below the box felt the water.
vehicle_desc::wading (off by default; the Humvee and RoboRacer presets
turn it on):

- the body floods to `displacement` of the box (the field step scales a
  wading chassis's buoyancy), so it stays on its wheels and sinks;
- the water drags the tires (AMC 25.1591's displacement drag) and the
  underbody against its velocity (a current, a swell), and floats the
  tires by `wheel_displacement`;
- water over a tire's contact soaks it to material::wet_friction (new;
  add_world_geometry fills it from surface_class::mu_wet, as the rain's
  apply_wetness uses) by 3 mm, and standing water aquaplanes a tire
  with a `tire_pressure` at 0.85 x 9 sqrt(p) kt;
- past `fording_depth` at the front axle the engine floods for good:
  no throttle, no idle, no fuel, the transmission in neutral.

The M1097A2 fords 0.76 m (1.52 m with the kit) per AM General's sheet.
A dry vehicle steps as before; the flooded engine rides in a spare bit
of an existing saved byte, so every golden hash is unchanged.
@transfix
transfix enabled auto-merge (squash) November 18, 2026 09:18
@transfix
transfix merged commit 1bb0ab0 into master Nov 18, 2026
51 of 52 checks passed
@transfix
transfix deleted the feat/vehicle-wading branch November 18, 2026 09:24
transfix added a commit that referenced this pull request Nov 26, 2026
…ke-bed friction (#1542)

Fills the three gaps left after wading (#1348).

Flooding over time (vehicle.h, wading_desc::flood_area, opt-in). With an area,
the cabin and engine bay take the water in through openings at the chassis
box's bottom at an orifice's rate, Q = C_d A sqrt(2 g dh), C_d 0.6. The box
floats sealed in the field step and the water inside adds its weight at its
centroid; out of the water it drains through the same openings. Each step is
exact for the outside level at its start, so the level never overshoots. The
water inside is state, saved only while there is any (bit 2 of the mode
byte), so a vehicle that never holds water saves the bytes it always has.
0 (the default, and both presets) floods at once, as before.

The world's vehicles (GB2 open item). Jolt fleets and Ariadne's Jolt vehicles
use presets with wading on, so they waded already. The dynamic plants'
chassis boxes do take the fluids' sealed-box push in the world, but each
substep puts them back at the model's pose, so nothing floated them: they
drove through water as on dry ground. dyn_bike_plant and dyn_4w_plant now
wade from world::water_at at their tires (dyn_wading.h): drag in the model's
drag term, grip lowered by the lifted load and soaked to the material's wet
friction, aquaplaning, and the engine flooding past fording_depth (kept in
their saves). A vehicle that waded in a tick is not `exact` in entity_plant.

Lake beds (GB2 open item). water_deep's mu 0.10 stands for the water where no
fluid covers the class; under a fluid the tire is on the bed. The water
classes' mu_wet is now their bed's, soaked: water_shallow 0.45 (sand and
gravel), water_deep 0.20 (mud). A wading tire runs to wet_friction whether it
is below or above friction; physics::wet_friction (rain) never raises a class
above its dry mu. scene_world.cpp, set_water and the nav rasters are
unchanged.

No pinned hash changes: with wading off, or on with no flood_area and no
water-class ground, every vehicle saves and steps as before.

Tests: PhysicsVehicle.AHardDooredHumveeFloodsOverSecondsAndDrainsOnTheWayOut,
PhysicsVehicle.OnALakeBedItBrakesWithTheBedsWetFriction,
Dyn4wPlant.DrivesIntoALakeAndWades, DynBikePlant.DrivesIntoALakeAndWades.
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