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:
Hakan SevenandClaude Opus 4.8 committed 2026-06-24 03:32:11 +03:00
1 parent 96aaf2a293
commit 3da71698b1
18 files changed
+626 -587

No files matched your search

+26 -22
View File
@@ -14,7 +14,7 @@
// 1. Center point → 2. Item count (text) → 3. Total angle in degrees (text)
use acadrust::Handle;
use glam::{Mat4, Vec3};
use glam::{DVec3, Mat4, Vec3};
use crate::command::{CadCommand, CmdResult, EntityTransform};
use crate::modules::draw::defaults;
@@ -94,8 +94,8 @@ impl ArrayRectCommand {
if r == 0 && c == 0 {
continue;
}
t.push(EntityTransform::Translate(ucs.transform_vector3(
Vec3::new(col_sp * c as f32, row_sp * r as f32, 0.0),
t.push(EntityTransform::Translate(ucs.as_dmat4().transform_vector3(
glam::DVec3::new((col_sp * c as f32) as f64, (row_sp * r as f32) as f64, 0.0),
)));
}
}
@@ -194,7 +194,7 @@ impl CadCommand for ArrayRectCommand {
}
}
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> {
fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
let (rows, cols, row_sp, col_sp) = match self.step {
RectStep::Rows => (
self.default_rows,
@@ -219,7 +219,7 @@ impl CadCommand for ArrayRectCommand {
if let EntityTransform::Translate(delta) = t {
self.wire_models
.iter()
.map(|w| w.translated(*delta))
.map(|w| w.translated(delta.as_vec3()))
.collect::<Vec<_>>()
} else {
vec![]
@@ -228,7 +228,7 @@ impl CadCommand for ArrayRectCommand {
.collect()
}
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint
}
@@ -331,6 +331,7 @@ impl CadCommand for ArrayPolarCommand {
v
};
let step_rad = total_deg.to_radians() / count as f32;
let center = center.as_dvec3();
let transforms = (1..count)
.map(|n| EntityTransform::Rotate {
center,
@@ -343,7 +344,8 @@ impl CadCommand for ArrayPolarCommand {
}
}
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> {
fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
let pt = pt.as_vec3();
let (center, count, total_deg) = match &self.step {
PolarStep::Center => (pt, self.default_count, self.default_angle),
PolarStep::Count { center } => (*center, self.default_count, self.default_angle),
@@ -370,7 +372,8 @@ impl CadCommand for ArrayPolarCommand {
out
}
fn on_point(&mut self, pt: Vec3) -> CmdResult {
fn on_point(&mut self, pt: DVec3) -> CmdResult {
let pt = pt.as_vec3();
if let PolarStep::Center = self.step {
self.step = PolarStep::Count { center: pt };
}
@@ -655,13 +658,13 @@ impl ArrayPathCommand {
.map(|(i, &p)| {
let dth = tans[i] - t0;
if dth.abs() < 1e-5 {
EntityTransform::Translate(p - p0)
EntityTransform::Translate((p - p0).as_dvec3())
} else {
// The aligned copy is the rigid motion x' = p + R(x - p0),
// which is a pure rotation by `dth` about its fixed point.
let center = Self::rigid_center(p0, p, dth);
EntityTransform::Rotate {
center,
center: center.as_dvec3(),
angle_rad: dth,
}
}
@@ -720,7 +723,8 @@ impl CadCommand for ArrayPathCommand {
}
}
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult {
fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult {
let pt = pt.as_vec3();
if handle.is_null() || self.handles.contains(&handle) {
return CmdResult::NeedPoint;
}
@@ -738,7 +742,7 @@ impl CadCommand for ArrayPathCommand {
CmdResult::NeedPoint
}
fn on_hover_entity(&mut self, handle: Handle, _pt: Vec3) -> Vec<WireModel> {
fn on_hover_entity(&mut self, handle: Handle, _pt: DVec3) -> Vec<WireModel> {
if handle.is_null() || self.handles.contains(&handle) {
return vec![];
}
@@ -784,7 +788,7 @@ impl CadCommand for ArrayPathCommand {
Some(CmdResult::BatchCopy(self.handles.clone(), transforms))
}
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> {
fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
let PathStep::Count { path_entity } = &self.step else {
return vec![];
};
@@ -796,19 +800,19 @@ impl CadCommand for ArrayPathCommand {
EntityTransform::Translate(delta) => self
.wire_models
.iter()
.map(|w| w.translated(*delta))
.map(|w| w.translated(delta.as_vec3()))
.collect::<Vec<_>>(),
EntityTransform::Rotate { center, angle_rad } => self
.wire_models
.iter()
.map(|w| w.rotated(*center, *angle_rad))
.map(|w| w.rotated(center.as_vec3(), *angle_rad))
.collect::<Vec<_>>(),
_ => vec![],
})
.collect()
}
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint
}
@@ -885,10 +889,10 @@ impl Array3DCommand {
}
// Drawing plane is world XY: X = col dir, Y = row dir,
// Z = level (elevation).
t.push(EntityTransform::Translate(Vec3::new(
col_sp * c as f32,
row_sp * r as f32,
lvl_sp * l as f32,
t.push(EntityTransform::Translate(DVec3::new(
(col_sp * c as f32) as f64,
(row_sp * r as f32) as f64,
(lvl_sp * l as f32) as f64,
)));
}
}
@@ -1025,7 +1029,7 @@ impl CadCommand for Array3DCommand {
}
}
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint
}
@@ -1037,7 +1041,7 @@ impl CadCommand for Array3DCommand {
CmdResult::Cancel
}
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> {
fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
vec![]
}
}