Skip to content

nav_city_swarm and nav_city_drive as Ariadne documents (nav_swarm, swarm_layer) - #1358

Merged
transfix merged 1 commit into
masterfrom
feat/ariadne-nav-city
Nov 19, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ariadne-nav-city

Conversation

@transfix

Copy link
Copy Markdown
Owner

examples/nav's nav_city_swarm.cpp and nav_city_drive.cpp, ported to pure Ariadne documents that arigl runs with no program of their own: nav_city_swarm.ari (800 vehicles, 16 targets) and nav_city_drive.ari (60 Humvees on Jolt, 6 convoys).

The documents declare:

  • the city: a data: block for the scene-austin-south package, or --bundle DIR; the synthetic city when it can't load;
  • the scene: a sun with camera-focused shadow maps, the clock at 3.6x;
  • the swarm, and each thing it draws as a swarm_layer node with its own visible:, tags: and material: { opacity };
  • the panels, menus and keys;
  • the chase camera, the 2-D map and the orbit/fly capture cameras (the document's on_tick);
  • the programs' options as args: (--agents, --belief, --no-fog, --plant, --seed, --hz, --follow, --capture, --map, --no-shadows, --no-ui, --no-pip, --bench).

Host pieces

  • cvc::ariadne::SceneSwarm (scene_swarm.h, core): the demos' simulation as a scene runtime. The city rasterized from a dataset's world (or city_scene), sim_world with the trained CoefMLP, belief planes, fog, separation and opposed spawns, latitude-banded colour-coded targets, plant_host, a sim_thread on the app's world clock, an async rebuild, and the fog coverage and sensed walls read on the worker. Its knobs and telemetry are keys under swarm.*.
  • type: nav_swarm and type: swarm_layer (swarm_nodes.h, cvcGL): layers agents (a model with four LOD rungs, or arrows), flags, goals, trails, path, belief, dots, targets, city, follow (a track camera's target).
  • sim_thread::post: an edit or a read run on the worker. The demos changed the world (separation, retargets) and read its belief planes from the render thread.
  • tint: satellite on a data node: the buildings coloured by the aerial image, as the demos tinted Austin.
  • Components swarm_controls.ari and swarm_minimap.ari (a map viewport: drag a rally point, click to follow a vehicle).

Faster than the programs

Laptop RTX 3050 Ti, 1280 x 720, the full Austin bundle; the navigator holds 60 steps a second in every run:

program document
swarm: 800 vehicles, fog, grouped belief 17 fps (19 without the PiP) 45 fps (50 without the minimap)
drive: 60 Humvees on Jolt 29 fps 55 fps
  • The coarse vehicle rungs are decimated from the model welded at its texture seams, keeping only the points their triangles use: the programs' far rung streamed 262 points a vehicle, the document's 115, and the middle rungs a third as many.
  • A rung takes only vehicles big enough on screen for it (lod_px), so an overview streams no full-detail Humvees.
  • An empty rung, and a slot whose vehicle has not changed, are not re-sent.
  • The trails stream every third frame; the minimap redraws at 5 Hz (every frame while you drag in it).

Not ported / not verified

  • --lite (buildings_flat.glb) and --building-lod (the clustered far skyline), both opt-in perf switches in the programs.
  • The minimap's drag and click were not tried with a real mouse: the pick program loads and its event fields match SceneViews', but native arigl has no input automation here.
  • Lighting: a sun with camera-focused shadows and the programs' key angles, in place of their aimed spot rig.
  • Not in the browser gallery yet (it needs the Austin bundle preloaded and thumbnails).

Tests

  • ariadne_scene_swarm_test (6): the runtime headless: props, the synthetic city, a build and its targets, stepping on the clock with fog, moving a target and follow-at through keys, a reseeded restart.
  • cvcgl_ariadne_swarm (25 checks, offscreen): every layer's meshes, streaming, the model's welded LOD rungs, the follow node a track camera finds, visible: binds, a moved target's beacons, and the warnings.
  • ariadne_loader_test (241) passes locally, including ShippedComponentsLoadClean and ShippedExamplesDeclareWhatTheyNeed.

Docs: ARIADNE.md §5.4 "Swarms", §5.17 tint:, §6.5; NAV_DEMOS.md.

… and swarm_layer nodes

examples/nav's nav_city_swarm.cpp and nav_city_drive.cpp, ported to pure .ari documents that arigl
runs (examples/ariadne/documents/nav_city_swarm.ari, nav_city_drive.ari). The documents declare the
city (a data: block: the scene-austin-south package, or --bundle DIR), the scene (a sun with
camera-focused shadow maps, the clock at 3.6x), the swarm and each thing it draws, the panels, the
chase camera, the 2-D map and the capture cameras; the programs' options are their args:.

The host pieces they needed:
- cvc::ariadne::SceneSwarm (scene_swarm.h, core): the demos' simulation as a scene runtime: the
  city rasterized from a dataset's world (or the synthetic city_scene), sim_world with the trained
  CoefMLP, belief planes, fog, separation and opposed spawns, latitude-banded colour-coded targets,
  plant_host, a sim_thread on the app's world clock, an async rebuild, the fog coverage and the
  sensed walls read on the worker; its knobs and telemetry are keys under swarm.*.
- type: nav_swarm and type: swarm_layer (cvcGL swarm_nodes.h): each layer (agents, flags, goals,
  trails, path, belief, dots, targets, city, follow) a scene node with its own visible:, tags: and
  material: { opacity }.
- sim_thread::post: an edit or a read on the worker (the demos poked the world from the render
  thread).
- tint: satellite on a data node: the buildings coloured by the aerial image, as the demos did.
- components swarm_controls.ari and swarm_minimap.ari (a map viewport: drag a rally point, click to
  follow a vehicle).

Faster than the programs on the same machine (RTX 3050 Ti laptop, 1280x720, full Austin): the swarm
45 fps against 17, the drive 55 against 29. The vehicles' coarse LOD rungs are decimated from the
model welded at its texture seams and keep only the points their triangles use; a rung takes only
vehicles big enough on screen for it; empty rungs and unchanged colours are not re-sent; the trails
stream every third frame; the minimap redraws at 5 Hz.

Tests: ariadne_scene_swarm_test (the runtime, headless) and cvcgl_ariadne_swarm (every layer,
offscreen). Docs: ARIADNE.md §5.4 "Swarms", §5.17 tint, §6.5; NAV_DEMOS.md.
@transfix
transfix merged commit fb25ec4 into master Nov 19, 2026
29 checks passed
@transfix
transfix deleted the feat/ariadne-nav-city branch November 19, 2026 08:17
transfix added a commit that referenced this pull request Nov 19, 2026
…Integration), which PRs skip

#1356 put TilerBunny on every PR. That's about 13 s in Release, but a
Debug build runs the bunny's SDF and the tiling many times slower.
package-linux's libcvc-debug took about 450 s on a quiet runner (#1357,
#1358). On a loaded one it ran past its 900 s timeout three times over
(#1296, #1360), and failed that required job for every PR.

So in a Debug build the suite is TilerBunnyIntegration. ci.yml's
STRESS_REGEX takes Integration as a heavy suite, which no PR or Debug job
runs; Release pushes still do. A Release build keeps the name TilerBunny,
so every PR's Release lanes still run it.

The tests' CMakeLists comment and the VolumeRover ports roadmap say the
same.
transfix added a commit that referenced this pull request Nov 20, 2026
…onents (§20) (#1382)

Two plans, docs only.

- **`docs/roadmap/FLEETS_AND_NIGHT_ROADMAP.md`** (new). It reworks #1358's swarm into world vehicles and adds lights after dark. The parts:
  - a fleet is a `world: vehicles: fleets:` block of `WorldVehicles` entities (FL0-FL4);
  - its plant is any world plant, Jolt included, mixed per team, and switched live;
  - its policy is `trained` (downloads `cvcpkg://cvc/grl-snam-weights` by default), `builtin`, or other weights by cvcpkg package, URL or `data:` entry, with a visible fallback;
  - `entity_layer` draws entities at scale, promoting a few to full nodes;
  - fleets on the relay;
  - lights: per-light shadows, range and attachment, a shadow budget, a shader-injected lamp field, archetype headlights, and time of day (NL1-NL6).
  
  D8 and D9 are settled; D1-D7 are open.
- **`CVCGL-UI-DSL-ROADMAP.md` §20** (planned): the activity components. `processes` lists the DSL processes by document and sub-document (`ps` gains owner, kind and waiting-on). `downloads` lists the transfers, from a per-app registry the data store, cvcpkg, the HTTP cache and the rest report into, with a tray icon (AC1-AC5).
transfix added a commit that referenced this pull request Nov 23, 2026
…1489)

Each world entity was a scene node of its own: a box look is six boxes and
a group, so 200 vehicles were 1400 actors. On arigl, 200 kinematic vehicles
at 3.6x took 61 ms a frame (19 of runtime, 42 to 46 of drawing), and 800
took seconds.

cvc::gl::ariadne::entity_view (entity_view.h) is the view of a set of
entities, whatever feeds it:
- set_entities (who each is: archetype, fleet, team, colours, look, size);
- promote, from the camera and the ids followed;
- then pose and draw each frame.

Its bodies layer draws the entities it takes as one mesh per archetype and
LOD rung:
- a fitted model gets four rungs (#1358's swarm rungs; decimate_mesh moves
  to mesh_lod.h and the swarm uses it there), a box look one;
- each copy is posed in 3-D, normals too, and culled on the frustum's
  sides. Near and far are left out: the renderer fits them to what it
  draws, and an unposed rung is a point, so a far plane fitted to it cut
  away the entities about to be drawn.

Promotion and layers:
- promote (8) are drawn as their own nodes by vehicle_view: the followed
  (a camera's track.target, vehicles.watch, the vehicle a client drives),
  then the nearest. An incumbent keeps its node until another is a fifth
  nearer.
- a layer of at most threshold (32) promotes them all, so small worlds
  look as before;
- type: entity_layer (of: all | { fleet } | { archetype } | { team }, lod:,
  promote:, threshold:) declares a layer. With none, an implicit layer
  covers every entity.

Two feeds, the local and the server-side holon:
- a scene's own world: update_entity_view in tick_scene. Poses come from the
  physics binding's group of the chassis bodies (bind_group), between steps,
  whether the frame steps the world or #1475's world_worker holon does;
- a relay's entities on a client: room_view::update_entities, from the
  entities section and the client's entity_playout poses.

sync_vehicle_markers draws only the promoted, and adds or removes nodes as
promotion changes. A boat, a mesh file look without fit, or an entity no
layer takes keeps its own node.

Test cvcgl_ariadne_entities (37 checks, 5 repeats): the implicit layer,
follow, keep, the threshold, of:, the world on a worker, and the room.
Locally, cvcgl_ariadne_labels, _scenes, _realize, _swarm, _physics and
cvcgl_room_view also pass.

arigl, 200 kinematic at 3.6x with --world-thread, alternating runs:
- 8 ms a frame (2.4 runtime, 5.4 to 6.6 drawing), against 61 with
  threshold: 100000 (each its own node);
- 800 take 8 ms of drawing. Their world, at 16 to 18 ms a frame, is now the
  cost.

Not yet: the other layers (flags, goals, trails, path, belief, dots,
targets, follow, headlights), of: { fleet } on a client (the room's
identities carry no fleet), and swarm_layer moving here (FL3).
transfix added a commit that referenced this pull request Nov 24, 2026
…rld on a worker), and FL2's first part (a world's vehicles drawn at scale) (#1475)

* Fleets: a placed vehicle keeps its fleet and its index in that fleet's navigator

A tick at 2000 kinematic vehicles with summary keys looked a vehicle's fleet up 28,000 times
(14 a vehicle), each a search of the fleets by the key's parts, about twice FL1a's plain find
(#1449 left it), and searched its navigator's ids for its index about as often.

- fleet_of(): a placed entity's fleet is set and cleared with its navigator id (place,
  remove_from_fleet, a failed placing, the world gone). A fleet outlives its vehicles in it, and
  an entity's key doesn't change while it is placed. An entity not placed is searched for as
  before.
- index(): kept on the entity until an agent comes or goes in that fleet (a fleet's agents_rev,
  bumped at each add_agent and remove_agent; an index past a removed one drops by one).
- Debug builds assert both against the search. The scene world, holon, holon sync and server
  document suites pass with the asserts on in a Release build.

Timed in one process on a busy machine (a whole tick's A/B was lost in its noise): a search took
124 to 141 ns and the kept fleet 3 to 6 ns; an index 102 to 122 ns and kept 5 to 8 ns. The
roadmap's 3.1 has it.

* Fleets' D3 as OW7's first part: a drawn host's world steps on a worker, in a local holon

A drawn host stepped its scene world (physics and the fleets' navigators) on the frame's
thread: at 3.6x 60 Jolt vehicles took two thirds of a core, 800 kinematic ones all of it. D3
(FLEETS_AND_NIGHT_ROADMAP.md) moves it off; Joe chose to build it as OW7's first part, the
world in a local server-role holon (ARIADNE_WORLDS.md 18.2). A holon has no thread of its own,
so the worker is new:

- cvc::ariadne::world_worker attaches a SceneWorld to a server-role holon of its own (physics
  on, holon_config_at the world's rate) and runs a thread that keeps the holon's lockstep clock
  tick for tick behind the host's, one quantum at a time, so the world takes the steps the
  host's own follow() would. The host holds lock() for its frame; the worker takes it per step
  and lets a waiting host go first. A step that throws stops it (error()); lag()/behind() say
  how far it is behind; wait_caught_up() is for tests and captures.
- SceneWorld::set_deferred: follow() then only steps. It runs no sync() and writes no key (a
  state subscriber runs on the thread that writes) and calls the worker's capture after each
  step; the host calls publish_due() (sync and the telemetry) under the lock. A restart anchors
  the world on the holon's clock again at once, since the host's clock may be back past where
  it was before the worker looks (the test caught that).
- SceneClockDriver::hold(): a world more than max_lag (0.25 s) behind holds the clock, so it
  runs slower than its speed, as on the frame's thread, rather than further behind.
- cvcGL: AriRuntime::set_world_thread starts a worker for the main scene's world at the next
  frame and holds its lock through frame() (input, pump, tick_scene); tick_scene publishes what
  the worker ran and draws from the poses it captured. The adapter owns the worker and stops it
  before a reload or clear replaces the world. arigl run --world-thread turns it on; snapshots,
  --terminal, wasm, the headless hosts, the gym and arisrv are unchanged.

No holon.h change (coordinated with the One World session, #1444, on dev.tx.wtf).

Tests: AriadneWorldWorker.StepsTheWorldAsTheHostsFollowWould (24 kinematic + 4 Jolt vehicles
through a restart: the same poses bit for bit as the host's follow, the keys written on the
host's thread; 30 repeats), cvcGL test_world_worker_drawn (bodies and their drawn pose as the
frame's own follow leaves them). The scene world (114), holon, holon sync, server document and
cvcGL physics suites pass. On arigl with 200 kinematic vehicles at 3.6x, alternating runs:
58.3 ms a frame against 66.4 on the frame's thread, the world at 3.6x both ways; the rest of
the frame is drawing 200 vehicles (FL2).

* D3: how far a world may lag its clock is a setting, the same on every host

A scene's clock: { max_lag: <s> } sets how far its world may fall behind its
clock: seconds of world time at 1x, growing with the speed as the clock's
catch-up does (by ceil(speed) past 1x), more than 0 and at most 10 s
(cvc::sim_catchup_valid). It was a fixed 30 quanta in world_worker, which is
0.25 s only at 120 Hz.

- On a worker (arigl --world-thread), it is how far the world may trail its
  clock before the host holds the clock: world_worker::options::max_lag is now
  seconds (cvc::kSimCatchup by default), max_lag_quanta() scales it with the
  leader's speed, and a value that is no catch-up is refused, so the world
  stays on the frame's thread.
- On the frame's thread (every single-threaded host, native or browser: arigl
  without the flag, the browser, snapshots, the headless AppRuntime), it is
  the catch-up one frame may run: SceneClockDriver sets the clock's stall
  guard from it when it binds (world_clock::set_max_steps_per_advance, new,
  which keeps the tick, and cap_scales_with_rate). Unset, the clock keeps the
  guard its host gave it, so no existing document changes.
- world_worker::available() is false in single-thread wasm. The worker tests
  skip there, and the browser's arigl says once that it steps the world on
  the frame's thread when given --world-thread.
- sim_tick.h: kSimCatchupMax, sim_catchup_valid, sim_catchup_quanta(_at), and
  sim_clock_config takes the catch-up.

Tests: WorldClockTest.TheStallGuardChangesInPlace,
SimTickTest.ACatchUpIsWholeQuantaAndGrowsWithTheSpeed,
AriadneScene.ClockBlockTakesAMaxLag,
AriadneSceneWorld.TheScenesMaxLagIsTheCatchUpAFrameMayRun and
AriadneWorldWorker.TheWorldMayTrailItsClockByMaxLag. Docs: ARIADNE.md
(--world-thread), WORLD_CLOCK_API.md, ARIADNE_WORLDS.md section 18.2.

* FL2, first part: a world's vehicles drawn at scale, in both holons (#1489)

Each world entity was a scene node of its own: a box look is six boxes and
a group, so 200 vehicles were 1400 actors. On arigl, 200 kinematic vehicles
at 3.6x took 61 ms a frame (19 of runtime, 42 to 46 of drawing), and 800
took seconds.

cvc::gl::ariadne::entity_view (entity_view.h) is the view of a set of
entities, whatever feeds it:
- set_entities (who each is: archetype, fleet, team, colours, look, size);
- promote, from the camera and the ids followed;
- then pose and draw each frame.

Its bodies layer draws the entities it takes as one mesh per archetype and
LOD rung:
- a fitted model gets four rungs (#1358's swarm rungs; decimate_mesh moves
  to mesh_lod.h and the swarm uses it there), a box look one;
- each copy is posed in 3-D, normals too, and culled on the frustum's
  sides. Near and far are left out: the renderer fits them to what it
  draws, and an unposed rung is a point, so a far plane fitted to it cut
  away the entities about to be drawn.

Promotion and layers:
- promote (8) are drawn as their own nodes by vehicle_view: the followed
  (a camera's track.target, vehicles.watch, the vehicle a client drives),
  then the nearest. An incumbent keeps its node until another is a fifth
  nearer.
- a layer of at most threshold (32) promotes them all, so small worlds
  look as before;
- type: entity_layer (of: all | { fleet } | { archetype } | { team }, lod:,
  promote:, threshold:) declares a layer. With none, an implicit layer
  covers every entity.

Two feeds, the local and the server-side holon:
- a scene's own world: update_entity_view in tick_scene. Poses come from the
  physics binding's group of the chassis bodies (bind_group), between steps,
  whether the frame steps the world or #1475's world_worker holon does;
- a relay's entities on a client: room_view::update_entities, from the
  entities section and the client's entity_playout poses.

sync_vehicle_markers draws only the promoted, and adds or removes nodes as
promotion changes. A boat, a mesh file look without fit, or an entity no
layer takes keeps its own node.

Test cvcgl_ariadne_entities (37 checks, 5 repeats): the implicit layer,
follow, keep, the threshold, of:, the world on a worker, and the room.
Locally, cvcgl_ariadne_labels, _scenes, _realize, _swarm, _physics and
cvcgl_room_view also pass.

arigl, 200 kinematic at 3.6x with --world-thread, alternating runs:
- 8 ms a frame (2.4 runtime, 5.4 to 6.6 drawing), against 61 with
  threshold: 100000 (each its own node);
- 800 take 8 ms of drawing. Their world, at 16 to 18 ms a frame, is now the
  cost.

Not yet: the other layers (flags, goals, trails, path, belief, dots,
targets, follow, headlights), of: { fleet } on a client (the room's
identities carry no fleet), and swarm_layer moving here (FL3).

* FL2: a parted look at scale, its wheels dark at every rung

#1471's parted look (look: { chassis:, wheel:, rig: }) is a fitted look whose
one-piece model is null, so the entity view drew every parted vehicle as a
node of its own.

- vehicle_look_mesh_of: a parted look's mesh is its chassis and its wheels
  at rest, each point where attach_parted_model's nodes draw it (the chassis
  fitted per axis; each wheel at its fitted hub, a right one turned or
  reflected as its rig says), the wheels in a tyre's dark. One texture, the
  chassis's. add_part bakes a part by a 3x3 matrix, normals by its inverse
  transpose; the one-piece model goes through it too.
- Role 3, the model's (white under its texture, else the entity's colour),
  so an untextured rung keeps role 2's dark.
- make_rungs decimates each colour role on its own. A coarse rung kept no
  roles, so the wheels would have taken the body's colour.
- sync_vehicle_markers keeps #1471's vehicle_wheels with the markers: a
  rebuild clears them, a demoted vehicle's go with its node.

Test cvcgl_ariadne_entities, parted: the mesh against attach_parted_model's
nodes (mirror turn and reflect, an axle offset); 40 at scale in the model's
four rungs, wheels dark at each rung drawn; one rung (lod: false), each
copy's chassis in its colour and its wheels dark.

* vehicle_view: entity_view.h's include without a trailing comment

CI's clang-format checks only the changed lines, so it would not align this comment with the
unchanged scene_labels.h line under it, while a whole-file format does.
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