perf(io,scene): drop redundant purge walk, fuse world-offset scan

Phase 1.1: resolve_xrefs now purges corrupt entities inline as it
merges each xref and returns the dropped count, removing the second
full-document purge_corrupt_entities walk in the FileOpened handler.
Every xref-bearing open saves one O(N) entities() pass.

Phase 2.4: split compute_world_offset into offset_prep / offset_centroid
/ world_offset_from_centers; centroid accumulation now rides the existing
cache-handle walk in build_derived_caches. Two O(N) entity walks collapse
into one, with identical MSPACE-membership filtering preserved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-05 00:32:39 +03:00
commit 3098523b8d
7 changed files with 148 additions and 119 deletions

View file

@ -27,7 +27,7 @@ Source-scan summary (references):
**Goal:** measurably halve the wall time between "Open" click and "first
frame" for a 50 MB DWG.
### 1.1 Drop the second `purge_corrupt_entities`
### 1.1 Drop the second `purge_corrupt_entities` ✅ DONE
Today `purge_corrupt_entities` runs once on the
[background thread](src/io/mod.rs#L62-L74) and again in the
@ -56,7 +56,9 @@ list back. The UI thread only emits log lines.
- corrupt-entity detection,
- hatch / image / mesh handle lists,
- AABB accumulation for `world_offset` (currently a separate pass inside
`compute_world_offset`).
`compute_world_offset`). ✅ the world_offset AABB scan is now folded into
the cache-handle walk (see 2.4); corrupt-detect + hatch/image/mesh planning
remain a follow-up.
Target: three `O(N)` passes → one.
@ -131,7 +133,7 @@ On the first frame emit a **coarse**-tol wire pass (e.g. 4× the normal
tol); refine to full tol on the second frame. The user sees *something*
within 16 ms; detail snaps in smoothly afterwards.
### 2.4 Merge the world-offset scan into the single-pass walk
### 2.4 Merge the world-offset scan into the single-pass walk ✅ DONE
[`compute_world_offset`](src/scene/mod.rs#L128) walks the whole MSPACE
AABB when the header is unreliable. That scan should join the single-pass