diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs index 8a4116fe2..3c5b4f256 100644 --- a/src/app/cmd_result.rs +++ b/src/app/cmd_result.rs @@ -604,19 +604,7 @@ impl OpenCADStudio { if self.clipboard.is_empty() { self.command_line.push_error("Clipboard is empty."); } else { - // The centroid was measured in the source drawing's - // offset-relative frame and `base_pt` is in this drawing's; - // correct by the world_offset difference so a cross-drawing - // paste lands at the cursor instead of drifting by the - // offset gap. Zero for a same-drawing paste. (#135) - let src_wo = self.clipboard_world_offset; - let tgt_wo = [0.0_f64; 3]; - let wo_corr = glam::DVec3::new( - tgt_wo[0] - src_wo[0], - tgt_wo[1] - src_wo[1], - tgt_wo[2] - src_wo[2], - ); - let delta = base_pt - self.clipboard_centroid + wo_corr; + let delta = base_pt - self.clipboard_centroid; let translate = crate::command::EntityTransform::Translate(delta); self.push_undo_snapshot(i, "PASTECLIP"); let count = self.clipboard.len(); diff --git a/src/app/commands.rs b/src/app/commands.rs index b48743e24..2de7aef95 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -540,7 +540,6 @@ impl OpenCADStudio { self.clipboard_centroid = super::helpers::entities_centroid( &self.tabs[i].scene.wire_models_for(&handles), ); - self.clipboard_world_offset = [0.0_f64; 3]; self.clipboard = entities; self.clipboard_deps = super::ClipboardDeps::capture( &self.tabs[i].scene.document, @@ -573,7 +572,6 @@ impl OpenCADStudio { self.clipboard_centroid = super::helpers::entities_centroid( &self.tabs[i].scene.wire_models_for(&handles), ); - self.clipboard_world_offset = [0.0_f64; 3]; let count = entities.len(); self.clipboard = entities; self.clipboard_deps = super::ClipboardDeps::capture( @@ -595,19 +593,7 @@ impl OpenCADStudio { self.command_line.push_error("Clipboard is empty."); } else { let wires = self.tabs[i].scene.wires_for_entities(&self.clipboard); - // The preview wires are tessellated in THIS drawing's - // offset-relative frame, but the stored centroid is in the - // source drawing's. Shift it by the world_offset difference - // so the ghost tracks the cursor instead of drifting by the - // offset gap. Zero within one drawing. (#135) - let src_wo = self.clipboard_world_offset; - let tgt_wo = [0.0_f64; 3]; - let centroid = self.clipboard_centroid - + glam::DVec3::new( - src_wo[0] - tgt_wo[0], - src_wo[1] - tgt_wo[1], - src_wo[2] - tgt_wo[2], - ); + let centroid = self.clipboard_centroid; use crate::modules::draw::clipboard::paste::PasteCommand; // The ghost anchor is a display-only offset; the precise // paste delta is computed in f64 at commit time. diff --git a/src/app/document.rs b/src/app/document.rs index af723b2b9..3f57eeeee 100644 --- a/src/app/document.rs +++ b/src/app/document.rs @@ -288,11 +288,10 @@ impl DocumentTab { return glam::Mat4::IDENTITY; } let (o, x, y, z) = self.ucs_xform().axes(); - let wo = [0.0_f64; 3]; let origin = glam::Vec3::new( - o.x - wo[0] as f32, - o.y - wo[1] as f32, - o.z - wo[2] as f32, + o.x as f32, + o.y as f32, + o.z as f32, ); glam::Mat4::from_cols( x.extend(0.0), @@ -321,11 +320,10 @@ impl DocumentTab { } let xf = self.ucs_xform(); let (o, ..) = xf.axes(); - let wo = [0.0_f64; 3]; let origin = glam::Vec3::new( - o.x - wo[0] as f32, - o.y - wo[1] as f32, - o.z - wo[2] as f32, + o.x as f32, + o.y as f32, + o.z as f32, ); (origin, xf.rotation_mat()) } diff --git a/src/app/mod.rs b/src/app/mod.rs index e6a3f7680..8bbcc1ce2 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -372,12 +372,6 @@ pub(super) struct OpenCADStudio { clipboard: Vec, /// Centroid of the clipboard entities (world XY plane). clipboard_centroid: glam::DVec3, - /// The source drawing's `world_offset` at copy time. The centroid above is - /// measured in that drawing's offset-relative frame; pasting into a drawing - /// with a different offset (e.g. a large-coordinate file → a fresh one) - /// must correct the paste translation by the offset difference, else the - /// objects land `source_offset − target_offset` away from the cursor. - clipboard_world_offset: [f64; 3], /// Table records (layer / linetype / text + dim style) the clipboard /// entities reference, captured from the source drawing at copy time so a /// paste into a *different* drawing can recreate any that are missing — @@ -1809,7 +1803,6 @@ impl OpenCADStudio { update_notice_body: None, clipboard: Vec::new(), clipboard_centroid: glam::DVec3::ZERO, - clipboard_world_offset: [0.0; 3], clipboard_deps: ClipboardDeps::default(), shift_down: false, mtext_editor: None, diff --git a/src/app/mtext_editor.rs b/src/app/mtext_editor.rs index 5d34127ac..e2f6dc5b1 100644 --- a/src/app/mtext_editor.rs +++ b/src/app/mtext_editor.rs @@ -395,7 +395,6 @@ impl super::OpenCADStudio { let Some(ed) = self.mtext_editor.as_ref() else { return }; let mt = ed.build_mtext(); let entity = EntityType::MText(mt.clone()); - let woff = [0.0_f64; 3]; let anno = self.tabs[i].scene.annotation_scale; let wires: Vec = tessellate::tessellate( &self.tabs[i].scene.document, @@ -409,16 +408,8 @@ impl super::OpenCADStudio { anno, None, ); - // Per-character boxes in the same offset-subtracted frame as the - // preview wires (tessellate removes world_offset; mirror that). - let mut boxes = crate::entities::mtext::glyph_boxes(&mt, &self.tabs[i].scene.document); - let (ox, oy) = (woff[0] as f32, woff[1] as f32); - for b in &mut boxes { - b.xmin -= ox; - b.xmax -= ox; - b.ymin -= oy; - b.ymax -= oy; - } + // Per-character boxes share the preview wires' absolute coordinate frame. + let boxes = crate::entities::mtext::glyph_boxes(&mt, &self.tabs[i].scene.document); if let Some(ed) = self.mtext_editor.as_mut() { ed.preview_wires = wires; ed.glyph_boxes = boxes; diff --git a/src/app/properties.rs b/src/app/properties.rs index db81b6771..909aec0f7 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -652,18 +652,6 @@ impl OpenCADStudio { _ => {} } - // Commands pick points in local space (camera coordinates with world_offset - // already subtracted). Re-add world_offset so the entity lands at the correct - // DXF coordinate. Skip for paper-space entities (they use sheet mm coords). - let is_paper = self.tabs[i].scene.current_layout != "Model"; - if !is_paper { - let wo = [0.0_f64; 3]; - if wo[0] != 0.0 || wo[1] != 0.0 || wo[2] != 0.0 { - let delta = acadrust::types::Vector3::new(wo[0], wo[1], wo[2]); - let t = acadrust::types::Transform::from_translation(delta); - entity.apply_transform(&t); - } - } if matches!(&entity, acadrust::EntityType::Viewport(_)) && self.tabs[i].scene.current_layout != "Model" diff --git a/src/app/update.rs b/src/app/update.rs index 042bf05d9..86d7d551f 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -2713,18 +2713,10 @@ impl OpenCADStudio { } } - // Paper-space entities use sheet coordinates (no world_offset). - // Only add world_offset when converting local → DXF space in model space. - let wo_vec = if self.tabs[i].scene.current_layout == "Model" { - let wo = [0.0_f64; 3]; - glam::DVec3::new(wo[0], wo[1], wo[2]) - } else { - glam::DVec3::ZERO - }; let apply = if grip.is_translate { GripApply::Translate(snapped - grip.last_world) } else { - GripApply::Absolute(snapped + wo_vec) + GripApply::Absolute(snapped) }; self.tabs[i] .scene diff --git a/src/app/view.rs b/src/app/view.rs index 6ae903317..f08fb7d78 100644 --- a/src/app/view.rs +++ b/src/app/view.rs @@ -949,13 +949,7 @@ impl OpenCADStudio { // The readout follows the active pane's UCS — model space // or inside a floating viewport (no-op without a UCS). if tab.editing_model_space() { - let wo = [0.0_f64; 3]; - let wcs = glam::Vec3::new( - lc.x + wo[0] as f32, - lc.y + wo[1] as f32, - lc.z + wo[2] as f32, - ); - tab.ucs_xform().to_ucs(wcs) + tab.ucs_xform().to_ucs(lc) } else { lc }