Skip to main content

Module pick3d

Module pick3d 

Source
Expand description

Transformed picking for transform3d layers.

Layer promotion is render-side only, so a 3D-transformed subtree’s nodes keep their untransformed layout rects on the window camera — the stock hit-test sees them where layout put them, not where the composite quad draws them. This module makes picking follow the visual:

  1. drive_transform3d_pointer inverts the cursor through the topmost transformed layer’s screen homography onto the layer plane and drives a shared PointerId::Custom virtual pointer at the recovered untransformed window position — stock picking then resolves the subtree’s descendants normally (the <surface> virtual-pointer pattern, but window-target).
  2. suppress_transformed_layer_hits drops the real mouse pointer’s hits on members of visually-transformed layers (their layout rects are visually stale) and scopes the virtual pointer’s hits to the layer it is remapping into (its window location overlaps unrelated nodes).
  3. correct_transformed_interactions re-derives the legacy Interaction for those members from the virtual pointer’s HoverMap entry — ui_focus_system runs its own geometric hit-test that neither 1 nor 2 reaches.

Identity-valued transforms keep everything here inert (visual == layout); nested transformed-in-transformed layers invert the nearest transformed root only — a documented v1 limitation. Click-through under the visual quad (the real pointer hitting non-members the transformed result covers) is out of scope for v1.

Structs§

Transform3dPointer
The single virtual pointer remapping cursor input into transformed layers (topmost-wins, like the one surface pointer serving every surface), plus its frame-to-frame state.

Constants§

TRANSFORM3D_POINTER_UUID
The transform3d virtual pointer’s fixed id (see [crate::surface::SURFACE_POINTER_UUID] for the pattern).

Functions§

correct_transformed_interactions
Re-derive the legacy Interaction — and RelativeCursorPosition — for members of visually-transformed layers from the virtual pointer (HoverMap entry + press state + remapped location). ui_focus_system computes both geometrically from the real cursor against the stale layout rect (suppress_transformed_layer_hits never reaches it), so without this the real pointer lights hover/press styling — and reports drag positions — where layout put the subtree, not where it renders. Runs before apply_interaction_styles/collect_hover_events/ collect_pointer_events so styling, enter/leave, and onPointer* positions all see the corrected state.
drive_transform3d_pointer
Remap the window cursor into the topmost visually-transformed layer under it and drive the virtual pointer there (PointerInput move/press/release, the surface driver’s contract). With no transformed layer under the cursor — or no transformed layers at all — the pointer parks off-bounds and releases owed presses.
init_transform3d_pointer
Spawn the virtual pointer at startup and publish its id.
invert_screen_to_plane
Map a physical-px screen position back onto the layer plane (untransformed physical px). None when the plane is edge-on (degenerate homography), the recovered point sits at infinity, or it lies behind the eye (past the vanishing line, where the quad is not visible). A backface (negative determinant) still inverts — backfaces render and stay clickable.
suppress_transformed_layer_hits
Scope picking hits around the transformed-layer remap: the real mouse pointer must not hit members of visually-transformed layers (their layout rects are stale), and the virtual pointer must hit only members of the layer it is remapping into (its window location overlaps whatever else layout put there). Runs between the picking backends and the hover-map update, after the clip filter.
visually_transformed_members
The set of entities that belong to a visually-transformed layer this frame — the members the window cursor scan must skip (their layout rects are stale). Empty when no layer is transformed.