From c5969b4776a86e8b3d5d5acea8f4f51f8be9faa7 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 21 Jun 2026 06:32:50 +0300 Subject: [PATCH] fix(clipboard): keep the paste preview on the cursor across drawings The preview wires are tessellated in the target drawing's offset-relative frame, but the centroid driving the preview translation was the source drawing's, so the ghost drifted by the world_offset difference. Shift the centroid into the target frame to match the committed paste. Zero within one drawing. Co-Authored-By: Claude Opus 4.8 --- src/app/commands.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/commands.rs b/src/app/commands.rs index e280e3b23..e0c7fc985 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -595,8 +595,21 @@ 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 = self.tabs[i].scene.world_offset; + let centroid = self.clipboard_centroid + + glam::Vec3::new( + (src_wo[0] - tgt_wo[0]) as f32, + (src_wo[1] - tgt_wo[1]) as f32, + (src_wo[2] - tgt_wo[2]) as f32, + ); use crate::modules::draw::clipboard::paste::PasteCommand; - let cmd = PasteCommand::new(wires, self.clipboard_centroid); + let cmd = PasteCommand::new(wires, centroid); self.command_line.push_info(&cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(cmd)); }