fix(paste): UTM-precise paste/block base via f64 centroid

entities_centroid summed the f32 points (double-single HIGH half) alone, so
at UTM scale (~5.7e6) it both quantized each term ~0.5 m and lost low bits
across the running total — drifting the paste base and PASTEBLOCK's block
base metres off, which placed the wrapped block at the wrong spot/scale.

It now reconstructs each vertex's absolute f64 from points + points_low and
accumulates in f64. clipboard_centroid is DVec3; the PASTECLIP commit delta
is fully f64; define_block_from_owned_entities takes an f64 base so the
block-local fold (Translate(-base)) stays precise. The interactive ghost
anchors (PasteCommand, InsertBlockCommand) still take the f32 cast — display
only; the committed geometry is f64.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-24 10:42:58 +03:00
commit 60d4712179
5 changed files with 31 additions and 21 deletions

View file

@ -603,13 +603,15 @@ impl OpenCADStudio {
let src_wo = self.clipboard_world_offset;
let tgt_wo = [0.0_f64; 3];
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,
+ glam::DVec3::new(
src_wo[0] - tgt_wo[0],
src_wo[1] - tgt_wo[1],
src_wo[2] - tgt_wo[2],
);
use crate::modules::draw::clipboard::paste::PasteCommand;
let cmd = PasteCommand::new(wires, centroid);
// The ghost anchor is a display-only offset; the precise
// paste delta is computed in f64 at commit time.
let cmd = PasteCommand::new(wires, centroid.as_vec3());
self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
@ -674,7 +676,7 @@ impl OpenCADStudio {
self.tabs[i].dirty = true;
let wires = self.tabs[i].scene.wires_for_entities(&self.clipboard);
use crate::modules::insert::insert_block::InsertBlockCommand;
let cmd = InsertBlockCommand::new_for_block(name, wires, base);
let cmd = InsertBlockCommand::new_for_block(name, wires, base.as_vec3());
self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd));
}