Pixi's own hit test decided what a click in the scene view selected.
A tilemap caught clicks over its whole area, even on empty cells and
over sprites sorted above one of its layers. A press always grabbed
the topmost object, so a hidden selected object could not be dragged,
and there was no way to reach an object underneath another one.
- New pure rule in src/viewport/pick.ts. It lists the objects under
the cursor front to back, in the order they are drawn.
- A tilemap counts only where it has a tile. Its depth there is the Z
of the highest layer with a tile at that spot. An empty cell is
empty space, so a click clears the selection or starts a marquee.
- Pressing on any selected object, hidden ones included, drags the
selection. Otherwise the press selects the topmost object and drags
it, as before.
- A click without drag on a selected object selects the next one
underneath. After the lowest it starts again at the top.
- New debug hook __gm.sceneStack(x, y) returns that list.
Decisions:
- With a paint tool the selected tilemap paints anywhere on its grid,
even under a sprite. With empty cells as empty space an empty cell
could not be painted otherwise.
- Icons such as colliders and cameras stay in front. A second click
now reaches the sprite under a collider.
Tests:
- ./check.sh: 142 files, 2090 tests, exit 0 (was 141 / 2080)
- 10 new unit tests in tests/viewport/pick.test.ts
- GM_STEPS=39,40: ALL PASSED, 77 checks
- GM_STEPS=1-16,29,39-43: ALL PASSED, 626 checks
- 4 new checks in block 40q: sprite over a lower layer, empty cell,
cycling crate, map, crate, dragging the hidden selected crate.
- Counter test: whole-area tilemap hits and always-topmost presses
fail 4 unit tests and all 4 new checks.
- Check total 1290 (1286 + 4), computed, not yet counted by CI.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>