Skip to content

Conversation

@tomcur
Copy link
Contributor

@tomcur tomcur commented Dec 23, 2025

This checks all the local geometry to perform hit testing, checking the node's local bounds, the local clip, and then the node's ancestors' clips. Rounded rectangle clips are now handled correctly, rather than checking point containment on the underlying Rect.

Because we need to walk the tree to correctly check the geometry, we do away with the depth and path_to_root helpers (and build the path in a scratch buffer as we're walking).

#93 passes when based on this PR.

This checks all the local geometry to perform hit testing, checking the
node's local bounds, the local clip, and then the node's ancestors'
clips. Rounded rectangle clips are now handled correctly, rather than
checking point containment on the underlying `Rect`.

Because we need to walk the tree to correctly check the geometry, we do
away with the `depth` and `path_to_root` helpers (and build the path in
a scratch buffer as we're walking).

endoli#93 passes when based on this
PR.
if !clip.rect().contains(local_point) {
continue;
}
walk_tree_and_check_geometry(self, point, id, node, &mut path_buf);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Tree::containg_point returns many nodes that share ancestors, we will end up walking those ancestors many times. We could e.g. introduce a scratch buffer (once we've seen a node and know it is contained, we don't need to walk up from that point the next time we hit that same node when walking from a sibling).

We can also do some additional processing on Tree::commit to compress the tree, so hit testing can jump across ancestors that do not clip (those nodes trivially let the hit pass through).

But this first aims for correctness.

@tomcur tomcur merged commit 8c79b89 into endoli:main Dec 23, 2025
15 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