Skip to content

Ariadne: a scene node's own on_pick: - #1491

Merged
transfix merged 3 commits into
masterfrom
scene/node-on-pick
Nov 24, 2026
Merged

transfix merged 3 commits into
masterfrom
scene/node-on-pick

Conversation

@transfix

@transfix transfix commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

A scene node can now say what a click on it does. on_pick: on a node is an action (a program, or a bare name for a host handler). It runs when a press in an input: pick viewport lands on the node, or on a descendant that has no on_pick: of its own. Until now only the viewport had an on_pick:, so a document with several clickable things sorted every pick by (get-attr event "node") in one program.

scene:
  nodes:
    - node: crate_{i}
      repeat: 4
      source: { box: 1 }
      on_pick: (if (= (get-attr event "phase") "down") (state-set "selected" "crate_{i}"))

This is item 3 of the Ariadne scene-format gap plan.

How it behaves

  • Which node's. A press runs the on_pick: of the node it hits or, when that node has none, of its nearest ancestor that has one. So a group's handler covers its children, and a child's own handler replaces it. A press that hits no such node runs none. In a slice view, a press past the volume's edge lands on the plane, not on the node. This matches VRML/X3D, where the pointing-device sensor nearest the geometry is the one that fires.
  • The press belongs to the node. The node a press lands on keeps it: its on_pick: runs again on each drag and on the up, wherever they land, as an X3D drag sensor keeps tracking the press that started it. node and hit say what is under the pointer at that moment, so a program can drag what it picked.
  • Fields. The event dict holds the same fields as the view's (x, y, z, hit, node, i/j/k/value/axis, button, mods, phase, view, seq).
  • Scope. It runs in the document's scope, as on_key: does: its keys resolve against the document's prefix and it calls the document's functions:. This holds wherever the viewport sits, including inside a load:ed module. The handler belongs to the scene, not to the widget that saw the click.
  • With the view's. The view's own on_pick: runs too, in the view's scope. They are separate programs, and the runtime runs each queued program as a process of its own, so neither waits for the other: the docs say not to count on which runs first. (I first wrote "the node's runs first"; the test showed the runtime does not promise that, as it doesn't for two button clicks in one frame.) SceneViews::pick reports the node's handler in PickHit::on_pick.
  • Repeats. A repeat: copy gets {i} filled in its on_pick:, as in its id and binds.

Changes

  • SceneNode::on_pick: the loader reads it as a built-in key, so it is never a custom type's prop. scene_node_instance fills in {i}.
  • RealizedScene::TaggedNode::on_pick: realize_node records it. A custom type's extra part entries leave it empty.
  • SceneViews::pick_at keeps the GraphicsNode behind each pickable prop and walks getParentNode() to find the handler. pick holds the handler from down through up.
  • CustomEdit::events lets a custom widget raise more than one event in a frame. An event marked document runs at the document's prefix with the document's functions (Runtime::Impl::enqueue_document_fields). The viewport now raises its own on_pick: through events too; its behaviour is unchanged.
  • ARIADNE.md: a "Picking a node" paragraph in §5.4, "A node's own on_pick:" in §5.18, and on_pick: added to the repeat copy's {i} list.

Tests

  • ariadne_loader_test OnPickParsedOntoNodeAndCopies: parsed at any depth, not left in props, {i} filled in a copy.
  • ariadne_runtime_test CustomWidgetEventsRunEachInItsScope: a custom widget inside a mount raises a document event and one of its own. The first writes at the document's prefix, the second at the mount's.
  • New cvcgl_ariadne_node_pick, offscreen, 23 checks. The viewport sits in a load:ed module, and the node handlers call a document function the module is not granted:
    • SceneViews::pick names the handler: the node's own, its parent's for a child without one, none for a node with no handler above it, none for a miss;
    • a press on the crate, dragged across the jar and released on the post, runs only the crate's handler, for down, each drag and up (with node = post);
    • a click on the jar runs the shelf's, a click on the lid runs only the lid's, and the post and empty space run none;
    • the node's handler writes at the document's prefix; the view's runs on every pick and writes at the module's.

Verified locally

Windows, MSVC, with cvcGL (no examples, no pycvc), on master 04d6f76: the full ctest suite, 8,376 tests.

  • Pass: everything except the eight below, including the three new tests and the existing pick views (cvcgl_ariadne_pick, cvcgl_ariadne_slice_view, cvcgl_ariadne_volume_grid, cvcgl_volume_grid, cvcgl_volume_slice).
  • cvcgl_contour_lab, cvcgl_volume_grid_contours: this build has no cvc::planar (Clipper2/CDT).
  • cvcgl_ari_golden: the same seven goldens that fail on this machine without this change (Intel Arc GPU, no mesh_lab, no cvc::planar), with the same pixel counts as an earlier run of master 484ba6f on this machine.
  • Five timeouts under -j 12 (LocksStress.LK18_RandomOperationsKeepInvariants sync and async, LocksModelStress.L1Bound4, L2Bound4, NavPlantConvergence.CheckpointSelectionOnJoltReach): all pass rerun at -j 3, the slowest in 418 s.

Not verified locally: Linux, macOS, wasm and pycvc.

Schema (#1464)

#1464, the closed .ari schema, lands last among the PRs that add loader keys and carries their keys, so this PR can merge first. #1464 needs "on_pick": {"$ref": "#/$defs/program"} in node_builtin and node_custom; until then a document that uses a node's on_pick would warn "unknown key" under #1464. (I first wrote that #1464 would merge first; Joe's plan for #1464 is the other way round.)

Not done

  • A scene key for hover (on_hover: or a node-level pointer:): the view's pointer: key covers probing for now.

A node can say what a click on it does. on_pick: on a scene node is an
action (a program, or a bare name for a host handler) run when a press in
an input: pick viewport lands on the node, or on a descendant without an
on_pick: of its own (the nearest-ancestor rule VRML/X3D use for pointing
sensors). The node a press lands on keeps it: its on_pick: runs again on
the press's drags and its release, wherever they land, with the same
fields, so a program can drag what it picked. It runs in the document's
scope, as on_key: does, wherever the viewport sits; the view's own
on_pick: runs too, in the view's scope. A repeat: copy gets {i} filled in
its on_pick:.

- SceneNode::on_pick, read as a built-in key; scene_node_instance fills {i}.
- RealizedScene::TaggedNode::on_pick, recorded by realize_node.
- SceneViews::pick_at keeps each pickable prop's GraphicsNode and walks its
  parents for the handler (PickHit::on_pick); pick() holds it from down to up.
- CustomEdit::events: a custom widget raises several events a frame; one
  marked document runs at the document's prefix with its functions.
- ARIADNE.md: section 5.4 "Picking a node", section 5.18 "A node's own on_pick:".

Tests: ariadne_loader_test OnPickParsedOntoNodeAndCopies, ariadne_runtime_test
CustomWidgetEventsRunEachInItsScope, new cvcgl_ariadne_node_pick.
@transfix
transfix enabled auto-merge (squash) November 23, 2026 15:09
transfix added a commit that referenced this pull request Nov 23, 2026
loader.cpp conflicted where master edited the inline schema this branch
replaces (#1450's notifications: always); the closed schema already has it,
so the branch's side stays.

The schema gains the keys master now reads:
- #1495 (merged): a camera's position, target, up, fov, near, far,
  orthographic and height;
- #1491 (open): a scene node's on_pick.
src/cvcGL/CMakeLists.txt conflicted where this branch registers
cvcgl_ariadne_node_pick and #1495 registers cvcgl_ariadne_viewpoints at the
same place: both kept. ariadne.cpp (#1493's custom_scope around the custom
widget call) and scene_views.cpp (#1493's key_scope, #1495's viewpoints) merged
cleanly beside this branch's events.
@transfix
transfix merged commit 7337df6 into master Nov 24, 2026
31 checks passed
@transfix
transfix deleted the scene/node-on-pick branch November 24, 2026 00:51
transfix added a commit that referenced this pull request Nov 24, 2026
known_scene_node_key conflicted where #1491 adds on_pick and this branch use
and args: all three kept. With the validator: ariadne_schema_test 13 (one
skip), ariadne_loader_test 264; cvcgl_ariadne_prototypes 14/14 and
cvcgl_ariadne_node_pick 23/23 on the merge.
transfix added a commit that referenced this pull request Nov 24, 2026
src/cvcGL/CMakeLists.txt conflicted where this branch registers
cvcgl_ariadne_pbr and #1491 cvcgl_ariadne_node_pick at the same place: both
kept. With the validator: ariadne_schema_test 13 (one skip), ariadne_loader_test
264; cvcgl_pbr_material, cvcgl_ariadne_pbr 17/17 and cvcgl_ariadne_node_pick
23/23 on the merge.
transfix added a commit that referenced this pull request Nov 24, 2026
…s' box

A view without show: was framed on whatever its renderer held: the
props ViewportManager primed it with before SceneViews set the view's
filter, until the render re-synced it. With a volren that is the main
view's picture quad, which spans the main camera's frustum (+-145 in
volren_views), so the views framed far out; SH4's golden encodes that,
and its zoom: 1.7 was set against it. The view's own picture of a
volren (VolRenViewActor, bounded by the volumes' box) joins the
renderer only once its first raycast lands, after framing.

- ViewportManager::syncMirror(name): a live mirror's re-sync through
  its filter, now. SceneViews::prepare runs it before framing, so the
  renderer holds what the view will draw (also what it leaves out:
  chrome, tags).
- The bounds of a view without show: take in each volren node it draws
  by its volumes' box, known from the first frame.
- volren_views.ari drops zoom: 1.7: framed on the rods and the volume's
  box, its views look as the golden composed them. The golden itself
  is retaken from CI on vtk 9.5.0+cvc.7 (its rods draw with each view's
  own lights).
- cvcgl_ariadne_node_pick (#1491) maps the view's points through
  rendererToWindow, as the other pick tests do.

Under llvmpipe every other golden's frame is pixel-identical before and
after.
transfix added a commit that referenced this pull request Nov 24, 2026
… ...) into p9/volume-grid-segment

#1464 checks every load against the closed schema, which already takes a
color picker's fmt: rgb | hex. ColorWidgetFmtHexDrawsTheHexPicker counted
every warning of its fmt: hsv load; it now counts the loader's own, as
#1464's loader tests do, and checks that the schema flags that fmt where
it is when the validator is built in.
transfix added a commit that referenced this pull request Nov 25, 2026
…ck over them (#1500)

* cvcGL: viewport views drawn into textures, so windows stack over them (shell SH2)

An Ariadne `viewport` widget's view used to be drawn into the window's
frame under all of the UI, with a hole cut in its window's background,
so any window over the view's rect covered it, even one behind the
view's window, and the view's first frame was opaque.

Each view now draws into a texture of its own (Viewport::setTextureSize,
texture()), the widget's size in framebuffer pixels, at the window's own
multisampling and resolved as the window's pixels are; the widget draws
that texture as an image in its window. The window stacks, clips and
scrolls the view like any of its content. The view draws in the window's
render after the widget walk placed it, so its first frame shows it: the
mirror re-syncs and the throttle (refresh_hz) decides as the render
reaches it, and a view made this frame is readied (what it leaves out,
its shadows, its framing) by its widget. Picks, pointer probes and the
wheel map a point on screen to the view's texture
(Viewport::windowToRenderer / rendererToWindow). A scenes: entry's
anchor bakes its shadow maps by drawing one pixel into a texture of its
own. ImGuiBackend::cut_window_background and its background painting go.

Tests: cvcgl_ariadne_view_stacking (a window over a view, a view's
window over another window, the first frame, a clipped and a scrolled
view against the same picture in full, a pick through the scroll), the
view_stacking golden, and the pick and slice-view tests through the new
coordinate mapping. cvcgl_ari_frame_bench measures a document's frame
cost offscreen. The arigl-web CI job now also runs on changes to how a
view draws.

* cvcGL: a mirror's re-sync leaves it alone when nothing it draws changed; docs for SH2

syncMirrorProps took every prop out of a mirror and put it back every
frame, and the next draw of those props was slower for it. With views
now re-synced just before they draw, each view paid that: on
viewer_grid.ari a view's draw took 1.6 ms instead of 0.4. The mirror is
now left alone when it already holds exactly the props and lights it
should draw (same ones, same order), which also takes the cost off the
main view where the old order put it.

ARIADNE.md 5.18: how a view draws (a texture its window shows), its
refresh rate (moving it does not redraw it), a scenes: entry's anchor,
what it costs, and the limits (the view under the UI and the opaque
first frame are gone). The UI-DSL roadmap's render-to-texture tier
notes that rendering a view into a texture is built.

* goldens: view_stacking, and orthoslicer / volume_grid / volume_grid_quad with views drawn into textures

Written under Mesa 25.3.6 llvmpipe (cvcpkg's Windows build; it matches the
grid, menus, scene, widgets and windows goldens to the pixel).

view_stacking is new: a window over a view, a view's window over another
window, a clipped view. The other three change around their views: the
view's window now shows its border, resize grip, scroll bars and tab-bar
separator, which the old background painting around the hole covered, and
in volume_grid a slice view's caption that runs past its view is covered by
the view beside it. Inside the slice views a few nearest-sampled texels at
ties land on the other side under llvmpipe, the view being rasterized at
its texture's origin rather than at its place in the window (none on an
NVIDIA GPU).

* cvcgl_ariadne_volume_grid: project world points to the screen through the view's texture

A view's renderer draws into its texture now, so its display coordinates are
the texture's pixels; the test maps them to the window (rendererToWindow)
before it moves the pointer there, as the pick and slice-view tests do.

* cvcGL: every viewport sends its own lights, where VTK can (UpdateLightingUniformsEveryRender)

The renderers of a window share its shader programs, and VTK 9.5 keeps a
program's light uniforms with only the time they were set
(vtkOpenGLRenderer::UpdateLightingUniforms), not whose lights they are. A
view and the main view draw the same props, so one of them could draw
with the other's lights; which one depended on the order of VTK's
modified times, and differed between Linux and Windows.

cvcpkg's VTK 9.5.0+cvc.7 (cy-pca/cvcpkg#636) adds an opt-in
vtkOpenGLRenderer::UpdateLightingUniformsEveryRender. A compile check
(CVC_VTK_HAS_LIGHTING_UNIFORMS_EVERY_RENDER, as for FinishEveryRender)
finds it, and Viewport turns it on for every renderer it makes: the main
view's, the views', mirrors. An older VTK builds and renders as before.

cvcgl_ariadne_view_stacking compares the main view with a window's view
and without it (a see-through shell around a box the view shows from
its own camera): with the property it checks they match; without it, it
reports how many pixels differ (11,667 of 434,700 here, NVIDIA).
ARIADNE.md 5.18 lists the older-VTK behaviour as a limit.

* cvcgl_ariadne_pick: the module view's pointer maps its renderer's point to the window

master's module-view checks (#1493) took the view's renderer display
point as the window's; the view draws into its texture now, so it goes
through rendererToWindow, as the test's other sections do.

* cvcGL: a window's renderers send their own lights once it has two; goldens on VTK 9.5.0+cvc.7

UpdateLightingUniformsEveryRender moves from Viewport's constructor to
ViewportManager, which turns it on for every renderer of a window once
the window has a second one, and leaves it on when a view goes (the
view's lights may still be in a program). A window that only ever had
one renderer keeps VTK's default: nothing else writes its programs'
lights. With the property on, VTK sends a program's lights in the first
cell-type block that uses it each render; cvcgl_lowmem_fastdraw derives
Fast's trace by deleting empty blocks from the AllCellTypes trace, so
it could not see those uploads move to the next block (its uniform-state
and pixel checks held). Its single-renderer window is back on VTK's
default.

cvcgl_ariadne_view_stacking checks the property is on for both
renderers with a view, and off for the main view alone.

Goldens from CI on vtk 9.5.0+cvc.7 (Linux release and release-grpc,
identical to 1 LSB). Against the same commit on cvc.5 (Windows), only
renderers that drew with another's lights change: the main view in
view_stacking, skeleton and molecule_skeleton, and 23 px of the 3-D view
in volume_grid_contours.

* SceneViews: a view is framed on what it draws, a volren by its volumes' box

A view without show: was framed on whatever its renderer held: the
props ViewportManager primed it with before SceneViews set the view's
filter, until the render re-synced it. With a volren that is the main
view's picture quad, which spans the main camera's frustum (+-145 in
volren_views), so the views framed far out; SH4's golden encodes that,
and its zoom: 1.7 was set against it. The view's own picture of a
volren (VolRenViewActor, bounded by the volumes' box) joins the
renderer only once its first raycast lands, after framing.

- ViewportManager::syncMirror(name): a live mirror's re-sync through
  its filter, now. SceneViews::prepare runs it before framing, so the
  renderer holds what the view will draw (also what it leaves out:
  chrome, tags).
- The bounds of a view without show: take in each volren node it draws
  by its volumes' box, known from the first frame.
- volren_views.ari drops zoom: 1.7: framed on the rods and the volume's
  box, its views look as the golden composed them. The golden itself
  is retaken from CI on vtk 9.5.0+cvc.7 (its rods draw with each view's
  own lights).
- cvcgl_ariadne_node_pick (#1491) maps the view's points through
  rendererToWindow, as the other pick tests do.

Under llvmpipe every other golden's frame is pixel-identical before and
after.

* golden: volren_views on SH2 (views framed on what they draw; vtk 9.5.0+cvc.7)

Its views are framed on the rods and the volume's box (42eed3b), with zoom: 1.7
dropped from the document, so they keep SH4's composition; the windows show
their border and grip over their views; the main view's rods draw with the main
view's own lights. From CI run 45326238844 (Linux libcvc-release); Windows's
frame is within 3 of it.

* ari test: FramesAndTimeout's stuck document gets 4 s, not 1

The timeout counts from before the document loads, and its message names
the test only once the test has started. On a slow runner a Debug build
spent the whole second loading, so the message had no test in it: the
debug lane failed this test on master (f32ae43) and on several branches,
while it passed in about 3 s on others.

* tests: PL-5's pumps are 20 ms, far past a slow step

#1524's package-linux / libcvc-debug failed ExecPool.PL05_ALightGroupIsNotStarved three times: a
message's latency was 2 heavy pumps (1 or 2 of 100), against at most the one in progress. The pool's
virtual time is pump time, and at the default 2 ms budget a step slowed past it (steps of 2-3 ms
were logged in both groups on that runner) ends a light pump before its program takes the message,
which then waits out a heavy pump more. A probe with a 20 us budget shows the same latencies here.

The case now pumps 20 ms with unbounded steps, so every build's heavy pump takes the whole budget and
a light pump outlasts a slow step: 40 of 40 as 4 copies sharing 2 cores, 10 of 10 alone. A steps-only
budget was tried and dropped: a light pump could then run long, and a descheduled one put the light
group tens of heavy pumps behind (latencies of 12 to 107 under the 2-core squeeze).

(cherry picked from commit 67fda68, #1524: the same flake failed
#1500's recipe / ubuntu-22.04 / Debug three times at a651d0c)

* goldens: volume_grid's four on SH2 after #1452 (views in textures)

volume_grid, volume_grid_contours, volume_grid_quad and #1452's
volume_grid_segment, from CI run 45482759652 (Linux libcvc-release, vtk
9.5.0+cvc.7). Against SH2's previous images only #1452's panel differs (the
Segmentation tab, names and hex colours); against master's, SH2's changes:
a view's overlay text stops at its view, a view drawn in its window's order
covers the tab bar's rule, and the windows show their border and grip.
volume_grid_segment's Bones view is unchanged (within 1).

* goldens: macOS images for the documents SH2 re-renders

From ci/full run 45572393826 at 59220fb (package-macos / libcvc-release,
vtk 9.5.0+cvc.7; the debug, release-grpc and release-grpc-static lanes'
frames are within 1 of it).

orthoslicer (a refresh: the view's window shows its border and grip, and
the slices' tied texels), view_stacking (new) and volren_views (new: its
views are framed on what they draw) change with SH2 itself. skeleton,
molecule_skeleton, volume_grid, volume_grid_contours, volume_grid_quad and
volume_grid_segment already failed on master's macOS lane; SH2 re-renders
them too, so their macOS images are taken at SH2's rendering. #1526's
images for these seven are taken at master's and differ from SH2's frames
by 2,414 to 16,792 px; its contour_tiler.macos.png is unaffected.
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