forked from 1b-agent/opencadstudio-upstream
fix(precision): keep typed coordinates exact in f64 (#311)
Typed values were quantized to the f32 grid before reaching the entity (e.g. a length of 2000.8 committed as 2000.8020), worsening with magnitude. The interaction point layer was all glam::Vec3 (f32). Two-layer fix: 1. Coordinate backbone -> f64. last_point, last_cursor_world, dyn_anchor, dyn_ref become DVec3; UcsXform transforms, parse_coord, the ucs helper fns, dyn_resolve_point, the OTRACK typed-distance paths, command-line coordinate entry and the coordinate readout all compute in f64. Screen/GPU/alignment stays f32 (snap engine, render geometry, projection, UCS-icon/viewcube drawing) with casts only at those boundaries. 2. Per-command committed storage -> DVec3. on_point already received a DVec3, but many command impls narrowed it back to f32 (let pt = pt.as_vec3(); Vec<Vec3> fields) and re-widened at build, quantizing the committed coordinate. Migrated PLINE, SPLINE, MLINE, LENGTHEN, INSERT, 3D primitives, every dimension/leader/mleader, ray, revcloud, wipeout, attdef, table, tolerance, array center, mview, plot_window, plus the QDIM_PLACE handler and qdim_collect_points. Preview, hit-test and rubber-band paths keep f32 at the boundary. Hatch manual boundaries are left for a follow-up: HatchModel.boundary is structurally Arc<Vec<[f32;2]>> and needs a model-level widen. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
8ed10ceb2a
commit
57710eec2b
47 files changed
+699
-606
No files matched your search
@@ -20,15 +20,15 @@ pub fn tool() -> ToolDef {
|
||||
|
||||
enum Step {
|
||||
Vertex,
|
||||
FirstRay(Vec3),
|
||||
FirstRay(DVec3),
|
||||
SecondRay {
|
||||
vertex: Vec3,
|
||||
first: Vec3,
|
||||
vertex: DVec3,
|
||||
first: DVec3,
|
||||
},
|
||||
ArcPoint {
|
||||
vertex: Vec3,
|
||||
first: Vec3,
|
||||
second: Vec3,
|
||||
vertex: DVec3,
|
||||
first: DVec3,
|
||||
second: DVec3,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ impl CadCommand for AngularDimensionCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
|
||||
fn on_point(&mut self, pt: DVec3) -> CmdResult {
|
||||
match self.step {
|
||||
Step::Vertex => {
|
||||
self.step = Step::FirstRay(pt);
|
||||
@@ -98,28 +98,34 @@ impl CadCommand for AngularDimensionCommand {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
|
||||
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
|
||||
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> {
|
||||
let pt = pt.as_vec3();
|
||||
match self.step {
|
||||
Step::Vertex => None,
|
||||
Step::FirstRay(vertex) => Some(preview_wire(vec![vertex, pt])),
|
||||
Step::FirstRay(vertex) => Some(preview_wire(vec![vertex.as_vec3(), pt])),
|
||||
Step::SecondRay { vertex, first } => Some(preview_wire(vec![
|
||||
vertex,
|
||||
first,
|
||||
vertex.as_vec3(),
|
||||
first.as_vec3(),
|
||||
Vec3::new(f32::NAN, f32::NAN, f32::NAN),
|
||||
vertex,
|
||||
vertex.as_vec3(),
|
||||
pt,
|
||||
])),
|
||||
Step::ArcPoint {
|
||||
vertex,
|
||||
first,
|
||||
second,
|
||||
} => Some(preview_wire(angular_preview(vertex, first, second, pt))),
|
||||
} => Some(preview_wire(angular_preview(
|
||||
vertex.as_vec3(),
|
||||
first.as_vec3(),
|
||||
second.as_vec3(),
|
||||
pt,
|
||||
))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn v3(pt: Vec3) -> Vector3 {
|
||||
Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64)
|
||||
fn v3(pt: DVec3) -> Vector3 {
|
||||
Vector3::new(pt.x, pt.y, pt.z)
|
||||
}
|
||||
|
||||
fn preview_wire(points: Vec<Vec3>) -> WireModel {
|
||||
|
||||
Reference in new issue
Block a user