Skip to content

Storm wind: gust fronts in the scene's wind, and the wind on MuJoCo robots (O20, part 2: F4, F6's gusts) - #1345

Merged
transfix merged 3 commits into
masterfrom
feat/storm-wind
Nov 18, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/storm-wind

Conversation

@transfix

@transfix transfix commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

The storm wind from the water/weather roadmap (docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md §9 F4, and F6's "gusts push light bodies"), plus the open item from #1317: the scene's wind on MuJoCo robots as xfrc_applied.

What it does

  • The gust front (cvc::world::weather::gust_front, weather.h) is a function of the weather's cells at a time t. Nothing is stepped. Each cell's outflow:

    • rises from 0 at the cell's centre to front_speed (12 m/s for a full cell) at the front's edge;
    • the edge sits front_ahead (1.5) radii ahead of the cell along its motion and front_behind (0.9) behind it, and the outflow is weaker behind;
    • past the edge it dies away over front_width (0.6), and it is exactly 0 beyond that;
    • its strength grows with the cell's intensity from rain_onset.

    Ahead of a storm the wind rises, beside it the wind veers, and behind it the wind drops. The weather node's props are gust_front, front_ahead, front_behind and front_width.

  • Physics. With a scene wind and a weather node, the world's flow field is a StormWindFlow (scene_weather.h): the wind with every front in it, a pure function of point and time.

    • Each body reads it at the step's own time, and the storms are read at the clock's time (an offset from where the world anchored). The fronts sweep over the bodies as the storm walks, the same at every frame rate and headless.
    • The field is set again only when a weather's events or area change.
    • Where no front reaches, the velocity is wind_flow's bit for bit.
    • Vehicles and avatars read the same air. SceneWorld::wind() hands it out.
  • The water and the trees read one wind for everything they draw. Each sync(), the scene's world writes the front at the weather's centre to wind.front ("x y" m/s) before the water reads its wind, and scene_wind_now adds it.

    • The sea builds toward it through sea_lag, and its whitecaps follow the keyframe's wind.
    • A generated world's trees and the pines lean harder and turn.
    • The gusts' pattern keeps drifting with the wind as authored. Otherwise a front would race it across the water.
  • The rain's slant is the wind at the camera, including the front there.

  • Steering. steeringWind() reads the scene wind when there is one (scene_weather_steering): its heading, at its speed at the deck's base as authored, times sky.drift. Otherwise it reads sky.wind_az as before. The weather also starts from this steering, drawn and headless (WeatherFriction), so terrain_lab's storms steer the same in both.

  • MuJoCo (mujoco_robot::set_wind(air, time_offset, C_d, rho)). At each step's start, every collision geom of a moving body takes ½ ρ C_d A |u| u on its bounding box. That goes into xfrc_applied for the step, on top of apply_wrench's pushes (which are put back after the step), and the books count it as external work.

    • The poses come from mj_kinematics/mj_comPos/mj_comVel before mj_step, so with no air or no drag the robot steps to the same bits.
    • The time is the robot's plus an offset (the scene's clock when the robot started).
  • Decision: the fronts ride on the scene's wind. A scene with storms but no wind: has no fronts.

  • Scenes without a weather node step as before, bit for bit. The field is unchanged, nothing writes wind.front, and the water's spec is unchanged.

Measured (Windows 11, MSVC 2022 Release)

  • Gust front shape (WorldWeather.AGustFrontRunsAheadOfACell), ahead of a mature 1000 m cell: 0, 5.25, 9.00, 11.25, 12.00 m/s at 0/375/750/1125/1500 m (the edge), then 10.84, 5.74, 0.53 m/s at 1700/2000/2300 m, and 0 from 2400 m on. A 9 m/s wind is 21.0 m/s at the front's edge and veers 46.8° beside the cell.
  • A light body pushed by a gust (AriadneSceneWeather.AStormsGustFrontPushesALightBody): a 1 kg, 1 m ball in a 6 m/s wind. Ahead of a storm it moves at 16.6 m/s, beside the storm at (5.1, 5.3) m/s. With the storm out of reach, or no storm, it moves at 6 m/s, the same bits both ways.
  • Frame pacing (TheGustFrontIsInTheStepOnTheClocksTime): one run at one frame per clock quantum (720 frames), one at 0.137 s frames (90). The ball and the world's state hash are equal at every tick both runs looked at, while the front swept the ball up to 16.3 m/s.
  • Water (TheWaterReadsTheGustFrontThroughItsLag): a 12 m/s front over the centre makes the spec's wind 18 m/s, and the sea's wind is 8.65 m/s after 6 s and 18.0 m/s after 60 s. That took 11 keyframes, about 1 s of h0 builds in all, 113 ms at most.
  • Physics cost of the storms (TheStormWindIsCheap), one step on 100 bodies with 6 storms alive: 13.9 µs against 6.0 µs for the plain wind, about 0.1 µs per body per step.
  • Frame cost: no sampler, uniform or shader change. Each frame adds one weather::at (2.2 µs) and a key write. The real cost is the water's keyframes while a front ramps in: at most one per 4 s crossfade in each sea, 100–250 ms each, on the frame's thread, the same as dragging the wind slider. arigl frame time with a front passing was not measured; the machine was shared with other builds.
  • MuJoCo (MujocoRobotWind.*, on a model the test writes itself):
    • the drag on a box at rest matches ½ ρ C_d A u² to 1e-9 (83.94 N at 20 m/s);
    • at 12 m/s for 2 s the crate slides 3.79 m and the vane swings to −1.18 rad; in still air neither moves;
    • the books close (16.4 J external, residual 9.7e-4 J);
    • gusts at 10 m/s push between 5.3 and 15.3 N;
    • with no air, or no drag, the run is the same bits.

Tests run (all pass)

world_weather_test (13), ariadne_scene_world_test (72), physics_field_test (30), physics_world_test (47), physics_vehicle_test (26), physics_boat_test, physics_hull_test, physics_immersion_test, physics_energy_test, physics_parity_test, physics_replay_test (ctest), cvcgl_ariadne_physics, cvcgl_ariadne_realize (adds: with a scene wind the storms steer by it), and physics_mujoco_robot_test's MujocoRobotWind.* with CVC_WITH_MUJOCO on (MuJoCo 4.0.0+cvc.3 from cvcpkg).

Not verified

  • The Go2 MuJoCo tests: this machine has no mujoco-menagerie. The CI MuJoCo lane (Linux) runs them and the new wind tests.
  • Linux and macOS builds (CI), the browser (WebGL2), and arigl frame timing with a front passing.

Not done

  • The water and the trees take the front at one point, the weather's centre, not where each tree or wave is.
  • The water's keyframes are built on the frame's thread (a sliced task would move them off it).
  • A headless run logs no steer events, as before.
  • pycvc does not bind set_wind, and MuJoCo robots are not in Ariadne scenes yet.
  • Spray (the C5 work).

Review fixes (a2a9233)

  1. The physics sea, when a front reaches the water, no longer depends on frame pacing.
    • wind.front now holds the front at the start of each 0.5 s clock period, not at each frame's time.
    • While the scene has storms, WaterRuntime steps its sea once per period: in period k it steps to the start of period k+1, with period k's wind.
    • A sea keyframe's field goes into the physics world at the first step past that tick (SceneColliders::from_tick, applied in follow()'s step loop), not at the next sync.
    • New test TheFrontsSeaFloatsBodiesAlikeAtEveryFrameRate floats a crate on a lake while a front arrives (2 keyframes after the first). Runs at 1080 frames and at 135 frames of 0.137 s agree on the crate and on the state hash at every shared tick. With the per-frame sea it fails (checked).
    • Scenes without storms keep the per-frame sea.
  2. A front now wakes sleeping bodies. On the first step of each period, every moving scene body asleep where a front blows over 0.5 m/s is woken. In AFrontWakesASleepingBody, a 10 kg crate that slept in a 6 m/s wind is pushed 6.8 m; without the wake it does not move (checked). Vehicles and boats are not woken.
  3. MuJoCo time offset. For a scene's air, pass the world's field time at the robot's start (world().field_time()); the docs said the clock's time, which counts the clock offset twice.
    • A test now reads the air at field time against the clock's storms after a late anchor: 4.610168 m/s for both, against 5.109 m/s when read at the clock's time.
  4. MuJoCo pushes are restored even on a throw. A scope guard puts the pushes back however the step ends (unless MuJoCo reset the state).
    • The pushes are now saved before the air's wrench is computed.
    • New test TheWindsPushEndsWithItsStep fails without the restore (9.25 m against 0.5 mm, checked).
  5. Docs corrected. The ball goes 16.6 m/s (the air there is 18 m/s); arisrv avatars keep the room rules' plain wind. In code, bodies welded to the world and mocap bodies now take no drag (covered by the drag test's model).
  6. Drawn and headless steering use the same deck base. The drawn node reads it at its first tick from its sky's key. The headless world reads the base prop of the cloud_sky the weather's sky: names (scene_weather_deck_base).
  7. wind.front is cleared when the scene's world goes away, when physics stops, and in a scene with no storms.
  8. The MuJoCo test model file is named per test, so ctest -j runs never share it.

Re-run: world_weather, ariadne_scene_world (74), physics_field, physics_world, physics_vehicle, physics_parity, physics_boat, physics_hull, physics_immersion, physics_energy, physics_replay (ctest), holon, cvcgl_ariadne_physics, cvcgl_ariadne_realize, MujocoRobotWind.* (5). All pass.

Re-review items (b249df9)

A. The storm wind's peak is now a setting.

  • The live key is weather.gust_front: m/s, under the weather node's key root, seeded from the gust_front prop (default 12). 0 turns the fronts off.
  • The Weather panel has a new Storm wind slider (0–30 m/s).
  • The drawn node applies a change at once (it only affects the rain's slant).
  • The physics applies it at the first step past the start of the clock period after the one in which the scene's world read it (WeatherFriction::switch_gust). The air (StormWindFlow), wind.front and the woken bodies follow at that step.
  • Test TheStormWindsPeakIsALiveKeySwitchedOnTheClock: the key goes from 12 to 24, set mid-frame for the 0.137 s run and read at tick 267 (280 in that run).
    • Both runs switch at tick 301 (the period starts at 300) and agree on the ball and the hash at all 60 shared ticks.
    • Without the period rule they switch 6 steps apart and differ at 27 of the 60 ticks (checked).
    • With the key at 0, the air at the ball equals the plain wind exactly.
  • Test WeatherControlsBindTheStormWind checks the slider's bind, range and tooltip.

B. The low items.

  1. Short crossfade. With storms, the sea's crossfade is now held to at least two clock periods (1 s).
    • New test ARendersSeaAndAHeadlessOneFloatAlikeWithAShortCrossfade builds the world in a renderer's order (SceneWorld::build, with the water runtime ticked after each follow) and compares it against from_scene. The lake has sea_fade 0.2 and sea_lag 1, run at 0.137 s frames.
    • The two orders agree at all 135 ticks.
    • Without the clamp they differ at 98 of 135 (checked).
    • At 1/60 s frames, period starts fall exactly on frame ticks, so both orders drop the keyframe the same way; the test therefore uses 0.137 s frames.
  2. One sync per period. This is now documented. A follow that runs the clock past more than one period start warns once. Live hosts are covered by the clock's cap of 8 quanta per frame.
  3. Clock stepping needs a scene wind. The water steps on the clock's periods only with a scene wind and a weather node. It does not also require a front to be blowing, because the live key can switch fronts on and off mid-run and the sea must stay on the clock while it settles. Without the wind check, the new test fails (checked).
  4. Deck base. Headless steering reads the sky's <sky>.base key first, then the document's cloud_sky base. With sky.base set to 600 the storms steer at 10.49 m/s; without the key-first read they steer at 9.75 (checked).
  5. Order within a step. The timed field change and the gust switch now go in before the vehicles' and boats' before_step. No test covers this: both orders are deterministic, so frame pacing can't show the difference. It was checked by reading the code.
  6. Docs. scene_water.h now describes the period stepping, and scene_wind.h points to WaterRuntime. A MuJoCo test is renamed to GustsReachTheRobotAtItsTimeOffset.

Re-run, all passing: world_weather (13), ariadne_scene_world (77), ariadne_loader (242), physics_field (30), physics_world, physics_vehicle, physics_parity, physics_boat, physics_hull, physics_immersion, physics_energy, physics_replay (ctest), holon (46), cvcgl_ariadne_physics, cvcgl_ariadne_realize, and MujocoRobotWind.* (5).

…obots (O20, part 2: F4, F6's gusts)

- cvc::world::weather::gust_front: each storm cell's outflow, a function of the
  weather's cells at t. It rises to front_speed (12 m/s) at the front's edge,
  front_ahead radii ahead of the cell along its motion (front_behind behind,
  weaker there), and dies away to exactly 0 past its reach. Ahead of a storm the
  wind rises, beside it it veers, behind it it drops. Props: gust_front,
  front_ahead, front_behind, front_width.
- The physics: in a scene with a wind and a weather node, the world's air is a
  StormWindFlow (scene_weather.h), the wind with every front in it as a pure
  function of the point and time. Bodies read it at the step's own time, and the
  storms at the clock's (the offset where the world anchored). Light bodies under
  a front are pushed harder and turned, the same at every frame rate.
- One wind for the water and the trees: the scene's world writes the front at
  the weather's centre to wind.front before the water reads its wind, and
  scene_wind_now adds it. The sea builds toward it through its lag. The gusts'
  pattern still drifts with the wind as authored.
- steeringWind() and the weather's start steer by the scene's wind as authored
  (scene_weather_steering), drawn and headless alike. The rain's slant is the
  wind at the camera with the front there.
- mujoco_robot::set_wind: the drag on each collision geom's box, as
  xfrc_applied for the step beside apply_wrench's pushes, booked as external
  work. SceneWorld::wind() hands the scene's air out.
- Scenes without a weather node step as before, bit for bit.
…eepers, MuJoCo fixes

- The water's physics sea no longer depends on frame pacing in a scene with
  storms. The scene's world publishes wind.front as the front at the start
  of each 0.5 s clock period (kSceneWindFrontPeriod). While the scene has
  storms, WaterRuntime steps its sea once per period, to the next period's
  start (SceneColliders::clock_period). A keyframe's field then goes in at
  the first physics step past that tick (SceneColliders::from_tick, applied
  in follow's step loop). A scene without storms is unchanged.
- Sleeping bodies under a front wake: on the first step of each period,
  each moving scene body asleep where a front blows over 0.5 m/s gets a
  zero force before the step.
- MuJoCo: set_wind's time offset for a scene's air is the world's field
  time at the robot's start, not the clock's (docs, plus a test that reads
  the air at field time against the clock's storms). The pushes are put
  back by a scope guard, also on a throw, unless MuJoCo reset the state.
  Bodies welded to the world and mocap bodies take no drag.
- Drawn and headless steering read the same deck base: the drawn node reads
  it at its first tick from its sky's key, and the headless world from the
  matching cloud_sky's base prop (scene_weather_deck_base).
- wind.front is cleared when the scene's world goes, when the physics
  stops, and when a scene has no storms.
- Docs: the ball's 16.6 m/s, avatars keep the room's plain wind.
- The MuJoCo test model is written per test (named after it), so ctest -j
  runs cannot share the file.
- SceneWorld::water(node) exposes a from_scene water runtime.
- New tests: TheFrontsSeaFloatsBodiesAlikeAtEveryFrameRate,
  AFrontWakesASleepingBody, MujocoRobotWind.TheWindsPushEndsWithItsStep,
  and the field-time read in TheGustFrontIsInTheStepOnTheClocksTime.
- weather.gust_front is now a live key (m/s, under the weather node's key
  root, seeded from the gust_front prop, default 12; 0 turns the fronts
  off). The Weather panel has a Storm wind slider (0 to 30).
  - The drawn node takes a change at once, for the rain's slant.
  - WeatherFriction reads the key at sync and switches its model at the
    first step past the start of the next clock period
    (WeatherFriction::switch_gust, before the plants' before_step). The
    scene's world then rebuilds its air, so wind.front and the woken
    bodies follow on the clock.
- While the scene has storms, the sea's crossfade is at least two clock
  periods. Otherwise a short sea_fade lets the sea keyframe in back-to-back
  periods, and the world's own water runtime (ticked before the steps) and
  a renderer's (ticked after them) would put in different fields.
- A follow that runs the clock over more than one period start warns once.
  The docs say determinism needs a sync each period.
- Water stepping on the clock now requires a scene wind as well as a
  weather node. It does not depend on whether a front blows, since the
  live key can turn the fronts off mid-run.
- Headless steering reads the sky's <sky>.base key first, as the drawn
  node does, and falls back to the document's cloud_sky base.
- The timed field change goes in before the vehicles' and boats'
  before_step.
- Docs: WaterRuntime's period stepping is described in scene_water.h.
  GustsAndTheScenesClockReachTheRobot is renamed
  GustsReachTheRobotAtItsTimeOffset.
- New tests: TheStormWindsPeakIsALiveKeySwitchedOnTheClock,
  ARendersSeaAndAHeadlessOneFloatAlikeWithAShortCrossfade (a renderer's
  order through SceneWorld::build against from_scene),
  TheSeaStepsOnTheClockOnlyWithAWindAndSteersAtTheSkysKey, and
  AriadneComponents.WeatherControlsBindTheStormWind.
@transfix
transfix enabled auto-merge (squash) November 18, 2026 04:20
@transfix
transfix merged commit d7a6c97 into master Nov 18, 2026
30 checks passed
@transfix
transfix deleted the feat/storm-wind branch November 18, 2026 06:45
transfix added a commit that referenced this pull request Nov 26, 2026
… is, headless steering (#1551)

The ocean roadmap's F4/F6 "Not done" list after the storm wind (#1345).

- Sea keyframes off the frame: while a scene has storms, a keyframe's h0
  and fetch maps (100-250 ms) are a sliced job on the app's scheduler
  (SceneWaterSeaClock::begin, cvc::ocean::h0_builder), adopted once done
  or finished at the tick its field goes in after (WaterRuntime::tick,
  SceneColliders::settle from the world's sync). The same keyframe,
  field and tick, to the bit; `sea_threading: frame` keeps the old way.
  The drawn sea now shows the old keyframe until a clocked keyframe's
  crossfade starts (it popped to the new h0 up to 0.5 s early).
- Fronts where each thing is: one front shape (cvc::algo::add_gust_front)
  for the weather, the sea and the shaders. The water's ripples and
  roughness scale by the wind there over the centre's (drawn per vertex
  through StormFrontGLSL's uniforms; the physics sea through
  sea_forcing::fronts and SceneColliders::air); the generated world's
  trees lean per vertex and the pines per tree.
- Headless steering: WeatherFriction logs steer and rate events on the
  clock, drawn or headless (switch_steering); the drawn node reads them.
- Front gustiness: decided, not built (roadmap section 15, D14).

No pinned hash moved. New tests: OceanH0.ABuilderStepByStepIsBuildH0,
OceanSea.AGustFrontRaisesTheRipplesWhereItBlows,
AriadneSceneWeather.TheSeasKeyframesAreBuiltOffTheFrameAndGoInAtTheSameTick,
AriadneSceneWeather.AFrontAtOneEndOfTheWorldReachesTheWavesAndBodiesThereFirst,
cvcgl_ariadne_physics test_steering_headless_and_drawn, and the realize
test's "the storms' fronts where each tree and wave is".
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