Skip to content

ariadne: built-in sim.step and sim.restart (L0, last part: step and restart) - #1097

Merged
transfix merged 3 commits into
masterfrom
feat/world-sim-verbs-picking
Nov 9, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/world-sim-verbs-picking

Conversation

@transfix

@transfix transfix commented Nov 9, 2026

Copy link
Copy Markdown
Owner

The first half of L0's last part in ARIADNE_WORLDS.md (section 14, "Built-in handlers for sim.step and sim.restart"). Click-to-world picking in a viewport, the other half, comes in its own PR.

Built-in handlers. Every AppRuntime now handles sim.step and sim.restart, the bare-name events that sim_transport.ari's Step and Restart buttons raise. Until now nothing in libcvc handled them: only nav_convoy registered its own. A host's own on("sim.step", ...) still replaces the built-in one.

  • step_world(n) adds n to the scene clock's step key (<prefix>.sim.step by default, resolved as the clock's driver resolves it). The clock then runs n more quanta, paused or not. It works whether the runtime drives the clock itself (headless) or an adapter does (cvcGL), because both drivers read the same key. For a document with no scene it does nothing.
  • restart_world():
    • puts app.world_clock() back to tick 0;
    • rebuilds the scene's world (headless, or through the new SceneAdapter::restart);
    • adds one to <prefix>.sim.restarts, so a program or a host can reset state of its own.

SceneWorld::restart. This rebuilds the world as build() made it.

  • It keeps the same physics::world object and builds a fresh one into it, with the same config and materials.
  • Each body is made again in the order build() made it, so the ids stay the same. Each starts where its node put it, at rest unless it declared a velocity.
  • Each generated world or dataset node gets its colliders as they are now.
  • The next follow() anchors on the clock again.
  • A restarted world steps exactly as a world loaded fresh.

cvcGL. restart_scene_world(RealizedScene&) rebuilds a drawn scene's world and binds its moving bodies' nodes again (RealizedScene::body_nodes). AriRuntime's adapter implements SceneAdapter::restart with it.

pycvc. AriApp.step_world(n) and AriApp.restart_world().

Docs

  • ARIADNE.md: a "Step and restart" bullet in the physics section.
  • sim_transport.ari and INDEX.ari comments.
  • WORLD_CLOCK_API.md.
  • ARIADNE_WORLDS.md: section 1's "Step and restart" row and section 14's list.

Tests (Windows Release)

  • AriadneSceneWorld.SimStepAndRestartAreBuiltIn, headless, on a paused clock:
    • 30 step requests run the world;
    • a restart brings the clock and the world back to tick 0, with the state hash the document built;
    • the same 30 steps then reach the same state hash, which is also what a world loaded fresh reaches;
    • a document with no scene restarts nothing.
  • cvcgl_ariadne_physics's test_restart_drawn_world: a drawn scene restarts into the same physics::world object with the build's state hash, and after the same frames reaches the same hash.
  • pycvc_ariadne: AriApp.step_world bumps the step key and runs the paused world; restart_world counts the restart and the world steps as before.
  • Related suites pass after a full build: 985 ctest tests matching [Aa]riadne|[Ss]ceneWorld|scene_world|[Cc]lock|[Pp]hysics|pycvc|cvcgl_ariadne|[Nn]avConvoy|nav_convoy, except AriadneUri.StoreFileAtomicallyOverwrites, which failed once under -j8 (a temp file) and passed when run alone.

Not in this PR: viewport picking. nav_convoy keeps its own handlers, since it drives a raw Runtime.

…estart)

- Every AppRuntime handles sim.step and sim.restart, the bare-name events sim_transport.ari's
  Step and Restart raise; a host's own Runtime::on replaces them.
  step_world(n) adds n to the scene clock's step key (<prefix>.sim.step by default), so the
  clock runs n more quanta whether this runtime drives it or an adapter does.
  restart_world() resets app.world_clock() to tick 0, rebuilds the scene's world, and adds one
  to <prefix>.sim.restarts.
- SceneWorld::restart rebuilds the world as build() made it: the same physics::world object,
  a fresh one with the same config and materials, each body made again in the same order (so
  the same ids), each tracked node's colliders as they are now. The next follow() anchors on
  the clock again. A restarted world steps exactly as a world loaded fresh.
- SceneAdapter::restart (default false); cvcGL's adapter calls restart_scene_world, which
  rebuilds a RealizedScene's world and binds its moving nodes again (RealizedScene::body_nodes).
- pycvc AriApp: step_world(n), restart_world().
…orld

EachPolicyDrivesItsOwnAgents checked one coordinate of agent 1. On macOS,
scatter_free's draw (std::uniform_*_distribution, which differs between
standard libraries) puts that agent where it ends at the same x under both
policies, so package-macos failed. Compare every agent's position instead.
transfix added a commit that referenced this pull request Nov 9, 2026
…acOS)

The test asserted that agent 2 ends somewhere different under the two
policies, but scatter_free's draw differs between standard libraries,
and on macOS that agent starts where neither policy moves it: both
runs leave it at the same point and the check fails. Compare every
agent's position instead. The same change as #1097.
@transfix
transfix merged commit 370fff6 into master Nov 9, 2026
30 checks passed
@transfix
transfix deleted the feat/world-sim-verbs-picking branch November 9, 2026 23:01
transfix added a commit that referenced this pull request Nov 10, 2026
#1096)

* cloud_sky: near clouds over far ones, far clouds as view-aligned slices

Near clouds showed behind far ones for two reasons. A near volume drew
the copy of its cloud nearest the ground's centre, but the deck's
pattern repeats out to far_reach, so with the camera at the ground's
edge or past it the clouds in front of it were drawn by the coarse far
deck, fuzzy, over crisp volumes further off. The near volumes now take
the copies nearest the camera, ranking clouds out of view last. And the
near volumes drew in whatever order they joined the renderer; they now
draw after the far deck, farthest first.

The far deck is drawn as VolSlice draws a volume: planes facing the
camera, cut to the deck's box by cvc::volslice (new compute_slices_at,
the same plane/box clip at the caller's distances) and blended back to
front, spaced wider with distance, at most 64. Each slice marches the
slab behind it, within the deck, so seen edge-on the far clouds no
longer break into horizontal streaks.

* nav: EachPolicyDrivesItsOwnAgents compares the whole world's poses (macOS)

The test asserted that agent 2 ends somewhere different under the two
policies, but scatter_free's draw differs between standard libraries,
and on macOS that agent starts where neither policy moves it: both
runs leave it at the same point and the check fails. Compare every
agent's position instead. The same change as #1097.

* cloud_sky: the far clouds are a VolSliceNode

The far clouds were their own mesh of view-aligned slices that only
borrowed cvc::volslice's plane clip. They are now a VolSliceNode, given
the deck's coarse opacity as its volume, which gains what they need:

- distance slicing (setDistanceSlicing): planes facing the camera at
  distances growing by a fixed fraction, from compute_slices_at, each
  cut to the box grown by a share of its slab's depth;
- a sample shader of the caller's (setSampleShader) in place of the
  volume-then-LUT lookup, seeing the fragment's local position and the
  camera's eye, view direction and the slices' growth;
- repeat wrap on the volume texture (setVolumeWrap) and vertices past
  the far plane drawn on it (setClampToFarPlane);
- a node drawn with the volumes leaves the renderer's order-independent
  translucency on.

The clouds' lighting march is the sample shader. Native snapshots match
the previous mesh's from all five views. setDistanceSlicing is left out
of pycvc (std::optional of a nested struct).

* Align the far-cloud constant comments for clang-format
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