refactor(precision): widen command transform scalars and defaults to f64 (#311)

Completes the f64 migration on the CPU data path: the only f32 left now
is the GPU/render/screen layer, which is architecturally required (wgpu
vertex buffers and iced are f32; f64 vertices would double memory).

- EntityTransform::Rotate.angle_rad and Scale.factor are now f64 (the
  transform was already applied in f64 around the DVec3 center, so this
  only preserves the typed angle/factor). apply_standard_transform and
  apply_standard_scale take f64.
- CmdResult::ExtrudeEntity.height and AlignSelected.{angle_rad,scale}
  are f64; the EXTRUDE height parses as f64.
- defaults.rs (last-used construction values: circle radius/diameter,
  rotate angle, scale factor, offset/fillet/chamfer distance, array
  spacing/counts/angle) moved from Cell<f32> to Cell<f64>. Array counts
  round-trip through u32 (exact below 2^53).
- Consumers in circle/array/fillet/offset/rotate/scale/align/solid3d and
  dimension.rs rotate_point/scale_point follow. `as f32` is kept only
  where a value feeds a WireModel rubber-band/ghost (the preview path is
  screen-space f32).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-12 00:34:38 +03:00
1 parent 553b91015f
commit 62bd360e46
12 files changed
+100 -102

No files matched your search

+10 -10
View File
@@ -1211,7 +1211,7 @@ pub struct FilletCommand {
}
impl FilletCommand {
pub fn new(radius: f32, all_entities: Vec<EntityType>) -> Self {
pub fn new(radius: f64, all_entities: Vec<EntityType>) -> Self {
Self {
radius: radius as f64,
step: FilletStep::First,
@@ -1298,7 +1298,7 @@ impl CadCommand for FilletCommand {
if let Ok(v) = t.replace(',', ".").parse::<f64>() {
if v >= 0.0 {
self.radius = v;
defaults::set_fillet_radius(v as f32);
defaults::set_fillet_radius(v);
}
self.resume_after_radius();
return Some(CmdResult::NeedPoint);
@@ -1320,7 +1320,7 @@ impl CadCommand for FilletCommand {
if let Ok(v) = body.replace(',', ".").parse::<f64>() {
if v >= 0.0 {
self.radius = v;
defaults::set_fillet_radius(v as f32);
defaults::set_fillet_radius(v);
}
// Stay in the current step (keeps any first pick).
return Some(CmdResult::NeedPoint);
@@ -1590,10 +1590,10 @@ pub struct ChamferCommand {
}
impl ChamferCommand {
pub fn new(dist: f32, all_entities: Vec<EntityType>) -> Self {
pub fn new(dist: f64, all_entities: Vec<EntityType>) -> Self {
Self {
dist1: dist as f64,
dist2: defaults::get_chamfer_dist2() as f64,
dist2: defaults::get_chamfer_dist2(),
step: ChamferStep::First,
all_entities,
resume_pick: None,
@@ -1695,7 +1695,7 @@ impl CadCommand for ChamferCommand {
}
if let Ok(v) = t.replace(',', ".").parse::<f64>() {
self.dist1 = v.max(0.0);
defaults::set_chamfer_dist1(self.dist1 as f32);
defaults::set_chamfer_dist1(self.dist1);
self.step = ChamferStep::WaitingForDist2;
return Some(CmdResult::NeedPoint);
}
@@ -1711,7 +1711,7 @@ impl CadCommand for ChamferCommand {
}
if let Ok(v) = t.replace(',', ".").parse::<f64>() {
self.dist2 = v.max(0.0);
defaults::set_chamfer_dist2(self.dist2 as f32);
defaults::set_chamfer_dist2(self.dist2);
self.resume_after_dist();
return Some(CmdResult::NeedPoint);
}
@@ -1738,14 +1738,14 @@ impl CadCommand for ChamferCommand {
if !parts.is_empty() {
if let Some(&v) = parts.first() {
self.dist1 = v.max(0.0);
defaults::set_chamfer_dist1(self.dist1 as f32);
defaults::set_chamfer_dist1(self.dist1);
}
if let Some(&v) = parts.get(1) {
self.dist2 = v.max(0.0);
defaults::set_chamfer_dist2(self.dist2 as f32);
defaults::set_chamfer_dist2(self.dist2);
} else {
self.dist2 = self.dist1;
defaults::set_chamfer_dist2(self.dist2 as f32);
defaults::set_chamfer_dist2(self.dist2);
}
return Some(CmdResult::NeedPoint);
}