diff --git a/src/scene/camera.rs b/src/scene/camera.rs index acff7b942..8d1d9af3c 100644 --- a/src/scene/camera.rs +++ b/src/scene/camera.rs @@ -242,16 +242,6 @@ impl Camera { self.target += cam_up * delta_y * speed; } - /// Returns the world-space translation that `pan(delta_x, delta_y)` would - /// apply to the camera target — without actually moving the camera. - /// Used by MSPACE to pan the viewport's model-space view independently. - pub fn screen_delta_to_world(&self, delta_x: f32, delta_y: f32, _bounds: Rectangle) -> Vec3 { - let speed = self.distance * 0.001; - let cam_right = self.rotation * Vec3::X; - let cam_up = self.rotation * Vec3::Y; - -(cam_right * delta_x * speed) + (cam_up * delta_y * speed) - } - pub fn fit_to_bounds(&mut self, min: Vec3, max: Vec3) { self.target = (min + max) * 0.5; let size = (max - min).length(); diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 913679360..baa73e4bb 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -208,15 +208,21 @@ impl Scene { pub fn is_content_viewport(vp: &acadrust::entities::Viewport) -> bool { if vp.id == 1 { return false; } if vp.id > 1 { return true; } - // id=0 or id<0 — distinguish by geometry + // id ≤ 0: DWG files never write group-code 69 (viewport id), so all + // viewports arrive with id=0. Distinguish the sheet viewport by scale: + // the sheet ("overall") viewport has view_height ≈ vp.height → scale ≈ 1. + // True content viewports have deliberate drawing scales (1:50, 1:100 …) + // whose scale value is far from 1.0. The old check also required the + // center to be at the origin, but the sheet viewport center is the + // paper centre (e.g. 105, 148.5 for A4), so that condition failed for + // DWG files and incorrectly classified the sheet viewport as a content + // viewport — making it tessellated and enterable via double-click. let scale = if vp.view_height.abs() > 1e-9 { vp.height / vp.view_height } else { 1.0 }; - let at_origin = vp.center.x.abs() < 0.5 && vp.center.y.abs() < 0.5; - let scale_one = (scale - 1.0).abs() < 0.02; - !(at_origin && scale_one) + (scale - 1.0).abs() >= 0.02 }