Roadmap 0.13, Fixes

FX.826 Lasso selection is about 100x faster on big sets (shared lasso-core.js in CadCraft, DetailCraft, CivilCraft, TakeoffCraft, MarkupCraft)

  • Fix
  • Built · in the lab
  • CadCraft
  • MarkupCraft
  • TakeoffCraft
  • CivilCraft
  • DetailCraft

What was wrong: lassoSelect tested every segment of every item against every segment of the lasso, and segsCross made two new functions on each call; pointInPoly made an object per probe. A freehand lasso over 1,000 ink strokes took 1.3-1.8 s.

What changed (canonical cadcraft/a Discord member/lasso-core.js, copied byte-identical to the four other 2D apps): the lasso's segments are packed flat and bucketed in a coarse grid, so an item segment is tested only against nearby lasso segments, with a box check first; the helpers are module-level (no allocation per test); point-in-polygon runs on bare numbers and only once per connected run of segments; window mode rejects on the first point before any segment test. Same API, same results.

Tested: old vs new on 12,000 random cases (integer grid with exact touches and collinear overlaps, and random floats; window, crossing, fence): 0 differ. 1,000 strokes x 200 segments, 300-point lasso: crossing 1,817 ms -> 21 ms, window 1,289 ms -> 7 ms. bin/test-cadcraft.mjs 3040/13 (the same 13 DWG/empty-click failures with the old file), byte-identical copies check passes; bin/test-civilcraft-points.mjs 46/0.

Add a comment

Community comments

No comments yet

Add detail as we go: how you would use it, files or steps that show the problem, what other programs do. The team reads every comment.

Sign in or create a free account to add a comment.