mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-07 13:23:22 +00:00
PathData::nearest, which the Direct Selection cursor runs to find the segment under the pointer, projected the pointer onto every segment of the path. It now projects the pointer first onto a segment at the anchor nearest to it, then skips each segment whose control-point box lies farther away than that distance or the nearest point found so far. Each box is measured once and the search allocates no memory. The result is the same, including which of equal distances wins. A segment is never skipped when the pointer or one of its control points is past 1e100 or not finite. Over a segment of an open path of 200,000 anchors, the cursor takes 51 ms instead of 59 ms in a release build (anchor_bench). The progress line in docs/target-app-parity.md gives the timing. Tests compare nearest with every segment projected over 400 random paths, each probed at 30 points on a coarse grid (ties included), and on open, closed, compound, one-anchor, empty, huge and non-finite paths.