From e4668c66e7c758b5563ecb181592580badaa89eb Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sat, 30 May 2026 21:40:48 +0300 Subject: [PATCH] fix(zoom): Zoom Extents fits full drawing on first use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The viewport context-menu item dispatched a bare "ZOOM" string, which no command branch handled, so it did nothing. Send "ZOOM EXTENTS" instead. fit_all() also fed on the frustum-culled wire set, so it only framed the entities already on screen — each invocation revealed a little more and the view converged on the true extent only after several uses (issue #51). It now builds an un-culled wire set at a fixed tessellation tolerance, so the bounds are zoom-independent and the first call fits the whole drawing. Co-Authored-By: Claude Opus 4.8 --- src/app/view.rs | 2 +- src/scene/mod.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/view.rs b/src/app/view.rs index 3c9a1824c..a1997a9c4 100644 --- a/src/app/view.rs +++ b/src/app/view.rs @@ -1458,7 +1458,7 @@ fn viewport_context_menu_overlay( items.push(item("Quick Select...".to_string(), Message::QSelectOpen)); items.push(item( "Zoom Extents".to_string(), - Message::Command("ZOOM".to_string()), + Message::Command("ZOOM EXTENTS".to_string()), )); } diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 60220212b..dc99dc21e 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -4948,7 +4948,17 @@ impl Scene { } pub fn fit_all(&mut self) { - let wires = self.entity_wires(); + // Use the FULL, un-culled wire set — not `entity_wires()`, which is + // frustum-culled to the current view. Culled input would fit only the + // entities already on screen, so each call would zoom out a little and + // reveal more, converging on the true extent only after several uses + // (issue #51). `wpp = None` also tessellates at a fixed tolerance so + // the bounds don't drift with zoom-adaptive curve sampling. + let layout_block = self.current_layout_block_handle(); + let mut wires = self.wires_for_block_culled(layout_block, None, None, None, None); + if self.current_layout != "Model" { + wires.extend(self.viewport_content_wires(layout_block, None, None)); + } if wires.is_empty() { return; }