forked from 1b-agent/opencadstudio-upstream
wip(f64): convert command layer to DVec3 (in progress)
Migrate the command/snap/grip/cursor chain from f32 Vec3 to f64 DVec3 so picked points, snaps and grip drags stay precise at UTM-scale coordinates (f32 quantizes to ~0.5 m there). Done so far: - command/mod.rs: EntityTransform, CmdResult points, CadCommand point methods, TangentObject already DVec3 (radius f64). - snap: SnapResult.world DVec3; world_to_screen/try_pt DVec3. - GripApply -> DVec3; grip find/state (GripEdit) f64; camera pick_on_plane_f64 / pick_on_target_plane_f64; scene paper_to_model_f64. - update.rs click + mouse-move + grip-drag pipelines route precise DVec3 to on_point/on_preview_wires/on_entity_pick; ortho/polar cast at the UcsXform boundary only. - cmd_result dispatch, transform helpers, dimension/arc/circle/multileader apply_grip, circle/arc/ellipse/shapes draw commands, array modify. Tree does NOT compile yet (~236 errors remain across modify/annotate/ insert command files + entity apply_grip impls); committed at user request to checkpoint progress. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
96aaf2a293
commit
3da71698b1
18 files changed
+626
-587
No files matched your search
+20
-20
@@ -157,37 +157,37 @@ fn apply_geom_prop(arc: &mut Arc, field: &str, value: &str) {
|
||||
fn apply_grip(arc: &mut Arc, grip_id: usize, apply: GripApply) {
|
||||
match (grip_id, apply) {
|
||||
(0, GripApply::Translate(d)) => {
|
||||
arc.center.x += d.x as f64;
|
||||
arc.center.y += d.y as f64;
|
||||
arc.center.z += d.z as f64;
|
||||
arc.center.x += d.x;
|
||||
arc.center.y += d.y;
|
||||
arc.center.z += d.z;
|
||||
}
|
||||
(0, GripApply::Absolute(p)) => {
|
||||
arc.center.x = p.x as f64;
|
||||
arc.center.y = p.y as f64;
|
||||
arc.center.z = p.z as f64;
|
||||
arc.center.x = p.x;
|
||||
arc.center.y = p.y;
|
||||
arc.center.z = p.z;
|
||||
}
|
||||
(1, GripApply::Absolute(p)) => {
|
||||
let dx = p.x - arc.center.x as f32;
|
||||
let dy = p.y - arc.center.y as f32;
|
||||
arc.start_angle = (dy as f64).atan2(dx as f64);
|
||||
let dx = p.x - arc.center.x;
|
||||
let dy = p.y - arc.center.y;
|
||||
arc.start_angle = dy.atan2(dx);
|
||||
}
|
||||
(2, GripApply::Absolute(p)) => {
|
||||
let dx = p.x - arc.center.x as f32;
|
||||
let dy = p.y - arc.center.y as f32;
|
||||
arc.end_angle = (dy as f64).atan2(dx as f64);
|
||||
let dx = p.x - arc.center.x;
|
||||
let dy = p.y - arc.center.y;
|
||||
arc.end_angle = dy.atan2(dx);
|
||||
}
|
||||
(3, GripApply::Translate(d)) => {
|
||||
let sa = arc.start_angle as f32;
|
||||
let ea = arc.end_angle as f32;
|
||||
let span = angle_span(sa, ea);
|
||||
let sa = arc.start_angle;
|
||||
let ea = arc.end_angle;
|
||||
let span = angle_span(sa as f32, ea as f32) as f64;
|
||||
let mid_a = sa + span * 0.5;
|
||||
let current_mid_x = arc.center.x as f32 + arc.radius as f32 * mid_a.cos();
|
||||
let current_mid_y = arc.center.y as f32 + arc.radius as f32 * mid_a.sin();
|
||||
let current_mid_x = arc.center.x + arc.radius * mid_a.cos();
|
||||
let current_mid_y = arc.center.y + arc.radius * mid_a.sin();
|
||||
let new_mid_x = current_mid_x + d.x;
|
||||
let new_mid_y = current_mid_y + d.y;
|
||||
let dx = new_mid_x - arc.center.x as f32;
|
||||
let dy = new_mid_y - arc.center.y as f32;
|
||||
let new_r = (dx * dx + dy * dy).sqrt() as f64;
|
||||
let dx = new_mid_x - arc.center.x;
|
||||
let dy = new_mid_y - arc.center.y;
|
||||
let new_r = (dx * dx + dy * dy).sqrt();
|
||||
if new_r > 1e-6 {
|
||||
arc.radius = new_r;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user