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
@@ -37,14 +37,14 @@ enum Step {
/// Reference flow: defining the reference length from `base`.
RefLen { base: DVec3 },
/// Reference flow: factor is `cursor_dist / ref_dist` from `base`.
RefNew { base: DVec3, ref_dist: f32 },
RefNew { base: DVec3, ref_dist: f64 },
}
pub struct ScaleCommand {
handles: Vec<Handle>,
wire_models: Vec<WireModel>,
step: Step,
default_factor: f32,
default_factor: f64,
}
impl ScaleCommand {
@@ -58,7 +58,7 @@ impl ScaleCommand {
}
/// Commit a uniform scale about `base` and end the command.
fn commit(&self, base: DVec3, factor: f32) -> CmdResult {
fn commit(&self, base: DVec3, factor: f64) -> CmdResult {
defaults::set_scale_factor(factor);
CmdResult::TransformSelected(
self.handles.clone(),
@@ -112,18 +112,18 @@ impl CadCommand for ScaleCommand {
}
Step::Factor { base } => {
let base = *base;
let factor = base.distance(pt).max(1e-6) as f32;
let factor = base.distance(pt).max(1e-6);
self.commit(base, factor)
}
Step::RefLen { base } => {
let base = *base;
let ref_dist = base.distance(pt).max(1e-6) as f32;
let ref_dist = base.distance(pt).max(1e-6);
self.step = Step::RefNew { base, ref_dist };
CmdResult::NeedPoint
}
Step::RefNew { base, ref_dist } => {
let base = *base;
let new_dist = base.distance(pt).max(1e-6) as f32;
let new_dist = base.distance(pt).max(1e-6);
self.commit(base, new_dist / *ref_dist)
}
}
@@ -152,12 +152,12 @@ impl CadCommand for ScaleCommand {
self.step = Step::RefLen { base };
return Some(CmdResult::NeedPoint);
}
let factor: f32 = t.replace(',', ".").parse().ok()?;
let factor: f64 = t.replace(',', ".").parse().ok()?;
(factor > 0.0).then(|| self.commit(base, factor))
}
Step::RefLen { base } => {
let base = *base;
let ref_dist: f32 = t.replace(',', ".").parse().ok()?;
let ref_dist: f64 = t.replace(',', ".").parse().ok()?;
if ref_dist > 0.0 {
self.step = Step::RefNew { base, ref_dist };
return Some(CmdResult::NeedPoint);
@@ -166,7 +166,7 @@ impl CadCommand for ScaleCommand {
}
Step::RefNew { base, ref_dist } => {
let (base, ref_dist) = (*base, *ref_dist);
let new_len: f32 = t.replace(',', ".").parse().ok()?;
let new_len: f64 = t.replace(',', ".").parse().ok()?;
(new_len > 0.0).then(|| self.commit(base, new_len / ref_dist))
}
Step::Base => None,
@@ -179,7 +179,7 @@ impl CadCommand for ScaleCommand {
Step::Factor { base } => (*base, base.distance(pt).max(1e-6) as f32),
// Reference flow, new-length step: factor = cursor_dist / ref_dist.
Step::RefNew { base, ref_dist } => {
(*base, base.distance(pt).max(1e-6) as f32 / ref_dist)
(*base, (base.distance(pt).max(1e-6) / ref_dist) as f32)
}
// Reference-length step: rubber-band only, no factor defined yet.
Step::RefLen { base } => {