From e914be985207459c894af17fae7d4799a714f59e Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Wed, 15 Jul 2026 08:11:21 +0300 Subject: [PATCH] perf(scene): route hide / isolate-end / solid-register through bump_entities (phase 5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hide_selected, end_isolation and register_solid_model called bump_geometry() — a full-drawing invalidation (clears the tessellation memos, bumps block_epoch) — even though each touches a known, bounded set of handles. On a large drawing hiding a few objects then re-tessellated everything still visible. Report the exact changed handles via bump_entities instead: hide/reveal mark just the affected entities Modified so the resident set drops or re-adds only those, and register_solid_model reports its one solid (also making a bulk register loop O(n) rather than O(n^2)). No block-definition changes are involved, so skipping block_epoch is correct. Deliberately left on the full path: layer freeze/off (block sub-entity layer visibility legitimately needs block_epoch), viewport-scale (annotation-key sensitive), isolate (already cheap — keeps few), and undo/redo/style/file-open. Co-Authored-By: Claude Opus 4.8 --- src/scene/mod.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 70c09307d..1b353b18d 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1421,7 +1421,10 @@ impl Scene { self.meshes.insert(handle, set); } self.solid_models.insert(handle, solid); - self.bump_geometry(); + // Only this solid's mesh changed — report just its handle so the mesh / + // wire caches patch it in rather than rebuilding the whole drawing (and + // so a bulk register loop stays O(n), not O(n²)). + self.bump_entities(&[(handle, ChangeKind::Modified)]); } /// `BACKGROUND` change picks up the new `adapt_to_bg` result without @@ -2366,7 +2369,11 @@ impl Scene { } self.set_invisible(&sel, true); self.selected.clear(); - self.bump_geometry(); + // Only the hidden entities changed visibility — report just those so the + // resident set drops them instead of re-tessellating the whole drawing. + let changes: Vec<(Handle, ChangeKind)> = + sel.iter().map(|&h| (h, ChangeKind::Modified)).collect(); + self.bump_entities(&changes); } /// Clear isolation — bring every hidden entity back (End Isolation), @@ -2378,7 +2385,10 @@ impl Scene { let restore: Vec = self.hidden.iter().copied().collect(); self.set_invisible(&restore, false); self.hidden.clear(); - self.bump_geometry(); + // Re-reveal just the previously hidden entities (bounded to that set). + let changes: Vec<(Handle, ChangeKind)> = + restore.iter().map(|&h| (h, ChangeKind::Modified)).collect(); + self.bump_entities(&changes); } /// Set the persisted visibility flag (DXF code 60) on each handle.