Skip to content

fix(scene): report declared indices in hit paths after clustering - #17

Merged
riteshshukla04 merged 1 commit into
margelo:mainfrom
SectionTN:fix/hit-test-paths-after-clustering
Nov 4, 2026
Merged

riteshshukla04 merged 1 commit into
margelo:mainfrom
SectionTN:fix/hit-test-paths-after-clustering

Conversation

@SectionTN

@SectionTN SectionTN commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Since the batch clustering in 088cd8e, hitTest can return the wrong path for unnamed nodes. When the renderer reads the program, clustering regroups disjoint siblings of the same kind in lists of eight or more. hitWalk then reported each hit by its position in the regrouped list. JS reads paths as declared child indices, which is what HitTestResult.path documents. With eight interleaved rects and circles after a <Fill>, hitTest at the center of the first circle, declared at index 2, returned the path [5].

Only unnamed rects, rounded rects, ovals, circles, and images with a solid fill can move. A node with a ref stays in place: the handle turns its geometry into value slots, and clustering never moves a node with slotted geometry. That's why node was always right. Headless surface.hitTest had the same problem, since it goes through the same walk.

Each DrawCmd now keeps its declared index, set where the reader builds the root list and each child list, and the hit walks report that index. Clustering still reorders the draw.

I added a harness test with that scene. On a Pixel 9a emulator running Android 16, it failed before the fix with expected [ 5 ] to deeply equal [ 2 ] and passed three times after it. The other hit-test harness tests still pass. The transform3d "nearer face" test fails its center-pixel check on this emulator, with or without this change. I also added a SceneTest case for the root list and for a group's children. It compiles against the tgfx headers, but I couldn't run it, because it needs the private tgfx source.

As with #16, I couldn't build the example app for iOS, because Google ML Kit has no arm64 simulator slice for the Xcode 27 simulators.

@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

@SectionTN is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

@SectionTN
SectionTN marked this pull request as ready for review November 3, 2026 08:19
@riteshshukla04

Copy link
Copy Markdown
Member

Can you rebase your PR with main

@SectionTN

SectionTN commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

hey, sure. i'm on it
it's now done @riteshshukla04

Batch clustering reorders a node's batchable children when the program
is read, but hitWalk and collectHitPlanes reported each hit by its
position in the reordered list. JS resolves hit paths by declared child
index, so an unnamed rect, circle, oval or image in a list of eight or
more siblings came back with another sibling's index. Nodes with a
handle were never affected: a handle slots their geometry, which keeps
them out of clustering.

Each DrawCmd now carries the index it was declared at, and the hit walks
report that.
@SectionTN
SectionTN force-pushed the fix/hit-test-paths-after-clustering branch from de941ee to 5eecf0d Compare November 3, 2026 16:43
@riteshshukla04
riteshshukla04 merged commit 7a5977d into margelo:main Nov 4, 2026
4 of 7 checks passed
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.

2 participants