From 4f7a98a2ad8cabe0ae38e5dc0ae0839f303077d0 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Wed, 24 Jun 2026 03:51:50 +0300 Subject: [PATCH] feat(f64): command layer compiles on DVec3 Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end, so picked points, snaps and grip drags stay precise at UTM-scale coordinates instead of quantizing to ~0.5 m through f32. - All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes in full f64; others via point methods), modify, annotate, insert, view, inquiry, layers, groups, clipboard, layout. - Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3). - Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3; wire-preview boundaries cast to f32 only at the GPU edge. - Modify/annotate commands keep internal Vec3 geometry where precision is non-critical, casting at the DVec3 boundary; key draw commands store f64. Builds clean (no warnings). Visual verification of crosshair/snap/grip at extreme UTM zoom pending. Co-Authored-By: Claude Opus 4.8 --- src/app/automation.rs | 4 +-- src/app/commands.rs | 6 ++-- src/app/plugin_host.rs | 4 +-- src/app/view.rs | 2 +- src/entities/hatch.rs | 4 +-- src/entities/multileader.rs | 2 +- src/entities/solid3d.rs | 6 ++-- src/modules/annotate/aligned_dim.rs | 6 ++-- src/modules/annotate/angular_dim.rs | 6 ++-- src/modules/annotate/ddedit.rs | 6 ++-- src/modules/annotate/diameter_dim.rs | 6 ++-- src/modules/annotate/dim_baseline.rs | 6 ++-- src/modules/annotate/dim_continue.rs | 6 ++-- src/modules/annotate/dimbreak.rs | 6 ++-- src/modules/annotate/dimedit.rs | 6 ++-- src/modules/annotate/dimjogline.rs | 8 ++--- src/modules/annotate/dimspace.rs | 6 ++-- src/modules/annotate/dimtedit.rs | 8 ++--- src/modules/annotate/leader_cmd.rs | 6 ++-- src/modules/annotate/linear_dim.rs | 6 ++-- src/modules/annotate/mleader_cmd.rs | 6 ++-- src/modules/annotate/mleader_edit.rs | 22 ++++++------- src/modules/annotate/mtext.rs | 6 ++-- src/modules/annotate/ordinate_dim.rs | 6 ++-- src/modules/annotate/qdim.rs | 6 ++-- src/modules/annotate/radius_dim.rs | 6 ++-- src/modules/annotate/table_cmd.rs | 6 ++-- src/modules/annotate/text.rs | 6 ++-- src/modules/annotate/textedit.rs | 8 ++--- src/modules/annotate/tolerance_cmd.rs | 6 ++-- src/modules/draw/clipboard/paste.rs | 8 ++--- src/modules/draw/draw/attdef.rs | 6 ++-- src/modules/draw/draw/donut.rs | 4 +-- src/modules/draw/draw/hatch.rs | 12 +++---- src/modules/draw/draw/hatchedit.rs | 6 ++-- src/modules/draw/draw/line.rs | 17 +++++----- src/modules/draw/draw/mline.rs | 6 ++-- src/modules/draw/draw/point.rs | 6 ++-- src/modules/draw/draw/polyline.rs | 6 ++-- src/modules/draw/draw/raster_image.rs | 6 ++-- src/modules/draw/draw/ray.rs | 10 +++--- src/modules/draw/draw/revcloud.rs | 6 ++-- src/modules/draw/draw/spline.rs | 6 ++-- src/modules/draw/draw/wipeout.rs | 6 ++-- src/modules/draw/groups/group.rs | 6 ++-- src/modules/draw/groups/ungroup.rs | 6 ++-- src/modules/draw/inquiry/area.rs | 6 ++-- src/modules/draw/inquiry/dist.rs | 6 ++-- src/modules/draw/inquiry/divide.rs | 10 +++--- src/modules/draw/inquiry/id.rs | 4 +-- src/modules/draw/layers/match_layer.rs | 6 ++-- src/modules/draw/modify/align.rs | 12 +++---- src/modules/draw/modify/attedit.rs | 8 ++--- src/modules/draw/modify/break_cmd.rs | 18 +++++------ src/modules/draw/modify/copy.rs | 15 +++++---- src/modules/draw/modify/explode.rs | 4 +-- src/modules/draw/modify/fillet.rs | 14 ++++----- src/modules/draw/modify/join.rs | 4 +-- src/modules/draw/modify/lengthen.rs | 7 +++-- src/modules/draw/modify/mirror.rs | 19 +++++++----- src/modules/draw/modify/offset.rs | 22 ++++++------- src/modules/draw/modify/pedit.rs | 6 ++-- src/modules/draw/modify/refedit.rs | 8 ++--- src/modules/draw/modify/rotate.rs | 31 +++++++++--------- src/modules/draw/modify/scale.rs | 38 +++++++++++++---------- src/modules/draw/modify/splinedit.rs | 8 ++--- src/modules/draw/modify/stretch.rs | 12 +++---- src/modules/draw/modify/torient.rs | 6 ++-- src/modules/draw/modify/translate.rs | 15 +++++---- src/modules/draw/modify/trim.rs | 14 ++++----- src/modules/draw/properties/match_prop.rs | 8 ++--- src/modules/draw/select.rs | 6 ++-- src/modules/insert/create_block.rs | 6 ++-- src/modules/insert/insert_block.rs | 6 ++-- src/modules/insert/solid3d_cmds.rs | 22 ++++++------- src/modules/insert/xattach.rs | 6 ++-- src/modules/layout/mview.rs | 6 ++-- src/modules/layout/vplayer.rs | 6 ++-- src/modules/model/primitive_cmd.rs | 6 ++-- src/modules/view/plot_window.rs | 8 ++--- src/modules/view/zoom_window.rs | 8 ++--- src/scene/mod.rs | 4 +-- src/scene/model/object.rs | 2 +- src/scene/pick/grip.rs | 2 +- 84 files changed, 358 insertions(+), 336 deletions(-) diff --git a/src/app/automation.rs b/src/app/automation.rs index 15c9f48a8..7fd4b0619 100644 --- a/src/app/automation.rs +++ b/src/app/automation.rs @@ -422,7 +422,7 @@ impl OpenCADStudio { if let Some(r) = self.tabs[i] .active_cmd .as_mut() - .map(|c| c.on_entity_pick(handle, pt)) + .map(|c| c.on_entity_pick(handle, pt.as_dvec3())) { let _ = self.apply_cmd_result(r); } @@ -436,7 +436,7 @@ impl OpenCADStudio { } } self.last_point = Some(pt); - if let Some(r) = self.tabs[i].active_cmd.as_mut().map(|c| c.on_point(pt)) { + if let Some(r) = self.tabs[i].active_cmd.as_mut().map(|c| c.on_point(pt.as_dvec3())) { let _ = self.apply_cmd_result(r); } } else if let Some(r) = self.tabs[i] diff --git a/src/app/commands.rs b/src/app/commands.rs index b5b5097aa..a39884b50 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -5402,7 +5402,7 @@ impl OpenCADStudio { if selected.len() == 1 { let handle = selected[0].0; let mut cmd = ExtrudeCommand::new(color); - cmd.on_entity_pick(handle, glam::Vec3::ZERO); + cmd.on_entity_pick(handle, glam::DVec3::ZERO); self.command_line.push_info(&cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(cmd)); } else { @@ -5931,7 +5931,7 @@ impl CadCommand for DrawOrderRefCommand { fn on_entity_pick( &mut self, handle: acadrust::Handle, - _pt: glam::Vec3, + _pt: glam::DVec3, ) -> crate::command::CmdResult { if handle.is_null() { return crate::command::CmdResult::NeedPoint; @@ -5941,7 +5941,7 @@ impl CadCommand for DrawOrderRefCommand { crate::command::CmdResult::Relaunch(cmd, std::mem::take(&mut self.to_move)) } - fn on_point(&mut self, _pt: glam::Vec3) -> crate::command::CmdResult { + fn on_point(&mut self, _pt: glam::DVec3) -> crate::command::CmdResult { crate::command::CmdResult::NeedPoint } diff --git a/src/app/plugin_host.rs b/src/app/plugin_host.rs index 9eabf3e82..b3aba53c6 100644 --- a/src/app/plugin_host.rs +++ b/src/app/plugin_host.rs @@ -232,7 +232,7 @@ impl crate::command::CadCommand for PluginInteractiveAdapter { crate::plugin::guard("InteractiveCommand::prompt", || self.inner.prompt()) .unwrap_or_default() } - fn on_point(&mut self, pt: glam::Vec3) -> crate::command::CmdResult { + fn on_point(&mut self, pt: glam::DVec3) -> crate::command::CmdResult { crate::plugin::guard("InteractiveCommand::on_point", || { self.inner.on_point([pt.x as f64, pt.y as f64, pt.z as f64]) }) @@ -250,7 +250,7 @@ impl crate::command::CadCommand for PluginInteractiveAdapter { }) .unwrap_or(false) } - fn on_entity_pick(&mut self, handle: Handle, pt: glam::Vec3) -> crate::command::CmdResult { + fn on_entity_pick(&mut self, handle: Handle, pt: glam::DVec3) -> crate::command::CmdResult { crate::plugin::guard("InteractiveCommand::on_object_pick", || { self.inner .on_object_pick(handle, [pt.x as f64, pt.y as f64, pt.z as f64]) diff --git a/src/app/view.rs b/src/app/view.rs index 9f4cc748e..e556c22a6 100644 --- a/src/app/view.rs +++ b/src/app/view.rs @@ -270,7 +270,7 @@ impl OpenCADStudio { // A command may drive a typed scalar by mouse (e.g. a // perpendicular distance to a picked object); show that live // value in the box until the user types over it. - let live = tab.active_cmd.as_ref().and_then(|c| c.dyn_live_value(w)); + let live = tab.active_cmd.as_ref().and_then(|c| c.dyn_live_value(w.as_dvec3())); let boxes: Vec = tab .dyn_fields .iter() diff --git a/src/entities/hatch.rs b/src/entities/hatch.rs index d9683535a..00c787d62 100644 --- a/src/entities/hatch.rs +++ b/src/entities/hatch.rs @@ -188,9 +188,9 @@ impl Grippable for Hatch { fn resolve(apply: &GripApply, cur: Vec3) -> (f64, f64) { let p = match apply { GripApply::Absolute(p) => *p, - GripApply::Translate(d) => cur + *d, + GripApply::Translate(d) => cur.as_dvec3() + *d, }; - (p.x as f64, p.y as f64) + (p.x, p.y) } 'outer: for path in &mut self.paths { diff --git a/src/entities/multileader.rs b/src/entities/multileader.rs index 5086db01f..2c5ca71ed 100644 --- a/src/entities/multileader.rs +++ b/src/entities/multileader.rs @@ -24,7 +24,7 @@ pub(crate) fn mleader_v_anchor(attach: TextAttachmentType) -> MTextVAnchor { | TextAttachmentType::BottomOfTopLineUnderlineAll => MTextVAnchor::BottomOfTopLine, } } -use glam::{DVec3, Vec3}; +use glam::DVec3; use crate::command::EntityTransform; use crate::entities::common::{ diff --git a/src/entities/solid3d.rs b/src/entities/solid3d.rs index 64e6f5b3a..23e455a29 100644 --- a/src/entities/solid3d.rs +++ b/src/entities/solid3d.rs @@ -78,7 +78,7 @@ impl Grippable for Solid3D { self.point_of_reference.x += d.x as f64; self.point_of_reference.y += d.y as f64; self.point_of_reference.z += d.z as f64; - translate_wires(&mut self.wires, d); + translate_wires(&mut self.wires, d.as_vec3()); } } } @@ -154,7 +154,7 @@ impl Grippable for Region { self.point_of_reference.x += d.x as f64; self.point_of_reference.y += d.y as f64; self.point_of_reference.z += d.z as f64; - translate_wires(&mut self.wires, d); + translate_wires(&mut self.wires, d.as_vec3()); } } } @@ -222,7 +222,7 @@ impl Grippable for Body { self.point_of_reference.x += d.x as f64; self.point_of_reference.y += d.y as f64; self.point_of_reference.z += d.z as f64; - translate_wires(&mut self.wires, d); + translate_wires(&mut self.wires, d.as_vec3()); } } } diff --git a/src/modules/annotate/aligned_dim.rs b/src/modules/annotate/aligned_dim.rs index 6062929d9..3ab9c9c51 100644 --- a/src/modules/annotate/aligned_dim.rs +++ b/src/modules/annotate/aligned_dim.rs @@ -3,7 +3,7 @@ use acadrust::entities::{Dimension, DimensionAligned}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -49,7 +49,7 @@ impl CadCommand for AlignedDimensionCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::First => { self.step = Step::Second(pt); @@ -83,7 +83,7 @@ impl CadCommand for AlignedDimensionCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let (p1, p2) = match self.step { Step::First => return None, Step::Second(p1) => (p1, pt), diff --git a/src/modules/annotate/angular_dim.rs b/src/modules/annotate/angular_dim.rs index 189196098..acb276ef6 100644 --- a/src/modules/annotate/angular_dim.rs +++ b/src/modules/annotate/angular_dim.rs @@ -5,7 +5,7 @@ use acadrust::EntityType; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_angular.svg")); @@ -56,7 +56,7 @@ impl CadCommand for AngularDimensionCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::Vertex => { self.step = Step::FirstRay(pt); @@ -98,7 +98,7 @@ impl CadCommand for AngularDimensionCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); match self.step { Step::Vertex => None, Step::FirstRay(vertex) => Some(preview_wire(vec![vertex, pt])), diff --git a/src/modules/annotate/ddedit.rs b/src/modules/annotate/ddedit.rs index 576328206..318258431 100644 --- a/src/modules/annotate/ddedit.rs +++ b/src/modules/annotate/ddedit.rs @@ -8,7 +8,7 @@ // entity it annotates. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -45,7 +45,7 @@ impl CadCommand for DdeditCommand { true } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -54,7 +54,7 @@ impl CadCommand for DdeditCommand { CmdResult::EditTextEntity { handle } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/annotate/diameter_dim.rs b/src/modules/annotate/diameter_dim.rs index 45b8c7037..6737eebf0 100644 --- a/src/modules/annotate/diameter_dim.rs +++ b/src/modules/annotate/diameter_dim.rs @@ -3,7 +3,7 @@ use acadrust::entities::{Dimension, DimensionDiameter}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -51,7 +51,7 @@ impl CadCommand for DiameterDimensionCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::CenterPoint => { self.step = Step::ArcPoint(pt); @@ -77,7 +77,7 @@ impl CadCommand for DiameterDimensionCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); match self.step { Step::CenterPoint => None, Step::ArcPoint(center) => Some(preview_line(center, pt)), diff --git a/src/modules/annotate/dim_baseline.rs b/src/modules/annotate/dim_baseline.rs index a0f813d38..53be9b205 100644 --- a/src/modules/annotate/dim_baseline.rs +++ b/src/modules/annotate/dim_baseline.rs @@ -9,7 +9,7 @@ use acadrust::entities::{Dimension, DimensionLinear}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -107,7 +107,7 @@ impl CadCommand for DimBaselineCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if !self.ready { return CmdResult::Cancel; } @@ -136,7 +136,7 @@ impl CadCommand for DimBaselineCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !self.ready { return None; } diff --git a/src/modules/annotate/dim_continue.rs b/src/modules/annotate/dim_continue.rs index 630e1f308..7ae3ec92f 100644 --- a/src/modules/annotate/dim_continue.rs +++ b/src/modules/annotate/dim_continue.rs @@ -9,7 +9,7 @@ use acadrust::entities::{Dimension, DimensionLinear}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -87,7 +87,7 @@ impl CadCommand for DimContinueCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if !self.ready { return CmdResult::Cancel; } @@ -116,7 +116,7 @@ impl CadCommand for DimContinueCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !self.ready { return None; } diff --git a/src/modules/annotate/dimbreak.rs b/src/modules/annotate/dimbreak.rs index 5172bdbfc..762476091 100644 --- a/src/modules/annotate/dimbreak.rs +++ b/src/modules/annotate/dimbreak.rs @@ -10,7 +10,7 @@ // and emits a ReplaceEntity sentinel that commands.rs intercepts to apply the break. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -61,7 +61,7 @@ impl CadCommand for DimBreakCommand { true } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -81,7 +81,7 @@ impl CadCommand for DimBreakCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } diff --git a/src/modules/annotate/dimedit.rs b/src/modules/annotate/dimedit.rs index f5eadab43..1be730f69 100644 --- a/src/modules/annotate/dimedit.rs +++ b/src/modules/annotate/dimedit.rs @@ -5,7 +5,7 @@ // 2. Enter new text (blank = reset to auto-measured value, "<>" = measured value placeholder) use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -56,7 +56,7 @@ impl CadCommand for DimEditCommand { matches!(self.step, Step::PickDim) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -78,7 +78,7 @@ impl CadCommand for DimEditCommand { Some(CmdResult::DdeditEntity { handle, new_text }) } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/annotate/dimjogline.rs b/src/modules/annotate/dimjogline.rs index e8a8fa251..efbb85071 100644 --- a/src/modules/annotate/dimjogline.rs +++ b/src/modules/annotate/dimjogline.rs @@ -5,7 +5,7 @@ // 2. Click the position on the dimension line where the jog should appear use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -55,7 +55,7 @@ impl CadCommand for DimJogLineCommand { matches!(self.step, Step::PickDim) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -63,7 +63,7 @@ impl CadCommand for DimJogLineCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Step::PickJogPos { handle } = &self.step { let h = *handle; // Emit sentinel for commands.rs to store the jog position @@ -79,7 +79,7 @@ impl CadCommand for DimJogLineCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !matches!(self.step, Step::PickJogPos { .. }) { return None; } diff --git a/src/modules/annotate/dimspace.rs b/src/modules/annotate/dimspace.rs index 1e0a9224d..d534296fa 100644 --- a/src/modules/annotate/dimspace.rs +++ b/src/modules/annotate/dimspace.rs @@ -6,7 +6,7 @@ // 3. Enter spacing value (or 0 for automatic equal spacing) use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -60,7 +60,7 @@ impl CadCommand for DimSpaceCommand { matches!(self.step, Step::PickBase | Step::PickOthers { .. }) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -109,7 +109,7 @@ impl CadCommand for DimSpaceCommand { None } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } diff --git a/src/modules/annotate/dimtedit.rs b/src/modules/annotate/dimtedit.rs index 42512e9a0..2d7bc003c 100644 --- a/src/modules/annotate/dimtedit.rs +++ b/src/modules/annotate/dimtedit.rs @@ -5,7 +5,7 @@ // 2. Click the new text position (entity data is injected by update.rs after pick) use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -58,7 +58,7 @@ impl CadCommand for DimTeditCommand { matches!(self.step, Step::PickDim) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -69,7 +69,7 @@ impl CadCommand for DimTeditCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Step::PickTextPos { handle, entity } = &mut self.step { let h = *handle; if let Some(mut ent) = entity.take() { @@ -92,7 +92,7 @@ impl CadCommand for DimTeditCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !matches!(self.step, Step::PickTextPos { .. }) { return None; } diff --git a/src/modules/annotate/leader_cmd.rs b/src/modules/annotate/leader_cmd.rs index 4c4854136..2fbf7f208 100644 --- a/src/modules/annotate/leader_cmd.rs +++ b/src/modules/annotate/leader_cmd.rs @@ -13,7 +13,7 @@ use acadrust::entities::mtext::AttachmentPoint; use acadrust::entities::{Leader, LeaderCreationType, MText}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::{Mat4, Vec3}; +use glam::{DVec3, Mat4, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -61,7 +61,7 @@ impl CadCommand for LeaderCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); self.verts.push(pt); CmdResult::NeedPoint } @@ -85,7 +85,7 @@ impl CadCommand for LeaderCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.verts.is_empty() { return None; } diff --git a/src/modules/annotate/linear_dim.rs b/src/modules/annotate/linear_dim.rs index 0734a8d1c..f12c2fa7b 100644 --- a/src/modules/annotate/linear_dim.rs +++ b/src/modules/annotate/linear_dim.rs @@ -5,7 +5,7 @@ use acadrust::EntityType; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::{Mat4, Vec3}; +use glam::{DVec3, Mat4, Vec3}; /// World-space measurement axis for a linear dimension between `first` and /// `second`, chosen as the UCS X or Y axis (whichever the span is closer to). @@ -69,7 +69,7 @@ impl CadCommand for LinearDimensionCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::FirstPoint => { self.step = Step::SecondPoint(pt); @@ -113,7 +113,7 @@ impl CadCommand for LinearDimensionCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); match self.step { Step::FirstPoint => None, Step::SecondPoint(first) => Some(preview_wire(vec![first, pt])), diff --git a/src/modules/annotate/mleader_cmd.rs b/src/modules/annotate/mleader_cmd.rs index 1e4d93e52..96e5a96f9 100644 --- a/src/modules/annotate/mleader_cmd.rs +++ b/src/modules/annotate/mleader_cmd.rs @@ -8,7 +8,7 @@ use acadrust::entities::MultiLeader; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::{Mat4, Vec3}; +use glam::{DVec3, Mat4, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -56,7 +56,7 @@ impl CadCommand for MLeaderCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); self.verts.push(pt); CmdResult::NeedPoint } @@ -75,7 +75,7 @@ impl CadCommand for MLeaderCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.verts.is_empty() { return None; } diff --git a/src/modules/annotate/mleader_edit.rs b/src/modules/annotate/mleader_edit.rs index e06ad89a6..e3aae8984 100644 --- a/src/modules/annotate/mleader_edit.rs +++ b/src/modules/annotate/mleader_edit.rs @@ -8,7 +8,7 @@ use acadrust::entities::{LeaderLine, MultiLeader}; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -73,7 +73,7 @@ impl CadCommand for MLeaderAddCommand { matches!(self.step, AddStep::PickMLeader) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -84,7 +84,7 @@ impl CadCommand for MLeaderAddCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &mut self.step { AddStep::PickArrowhead { handle, entity } => { if let Some(ent) = entity.take() { @@ -132,7 +132,7 @@ impl CadCommand for MLeaderAddCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let existing_pts = match &self.step { AddStep::CollectPoints { pts, .. } => pts.clone(), _ => return None, @@ -201,7 +201,7 @@ impl CadCommand for MLeaderRemoveCommand { matches!(self.step, RemoveStep::PickMLeader) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -212,7 +212,7 @@ impl CadCommand for MLeaderRemoveCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let RemoveStep::PickLeaderToRemove { handle, entity } = &mut self.step { if let Some(mut ent) = entity.take() { let h = *handle; @@ -247,7 +247,7 @@ impl CadCommand for MLeaderRemoveCommand { fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } @@ -321,7 +321,7 @@ impl CadCommand for MLeaderAlignCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &mut self.step { AlignStep::PickDirection { handles } => { let h = handles.clone(); @@ -359,7 +359,7 @@ impl CadCommand for MLeaderAlignCommand { fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } @@ -423,7 +423,7 @@ impl CadCommand for MLeaderCollectCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let CollectStep::PickLocation { handles } = &self.step { let h = handles.clone(); // Build a new combined multileader at the collection point, delete originals. @@ -447,7 +447,7 @@ impl CadCommand for MLeaderCollectCommand { fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } diff --git a/src/modules/annotate/mtext.rs b/src/modules/annotate/mtext.rs index 90ef2a8fc..c55d91df8 100644 --- a/src/modules/annotate/mtext.rs +++ b/src/modules/annotate/mtext.rs @@ -1,7 +1,7 @@ use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::DVec3; pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/mtext.svg")); @@ -41,7 +41,7 @@ impl CadCommand for MTextCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { // Hand off to the in-place editor (toolbar + text area + live preview). CmdResult::OpenMTextEditor { pos: pt, @@ -58,7 +58,7 @@ impl CadCommand for MTextCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } diff --git a/src/modules/annotate/ordinate_dim.rs b/src/modules/annotate/ordinate_dim.rs index c799a666b..bbe83deac 100644 --- a/src/modules/annotate/ordinate_dim.rs +++ b/src/modules/annotate/ordinate_dim.rs @@ -11,7 +11,7 @@ use acadrust::entities::{Dimension, DimensionOrdinate}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -55,7 +55,7 @@ impl CadCommand for OrdinateDimCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::FeaturePoint => { self.step = Step::LeaderEndpoint { feature: pt }; @@ -78,7 +78,7 @@ impl CadCommand for OrdinateDimCommand { fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_preview_wires(&mut self, _pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/annotate/qdim.rs b/src/modules/annotate/qdim.rs index 9d5760a52..afd1a81f7 100644 --- a/src/modules/annotate/qdim.rs +++ b/src/modules/annotate/qdim.rs @@ -9,7 +9,7 @@ use acadrust::entities::{Dimension, DimensionLinear}; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -67,7 +67,7 @@ impl CadCommand for QdimCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Step::PlaceLine { handles } = &self.step { CmdResult::Relaunch( format!("QDIM_PLACE {:.6} {:.6} {:.6}", pt.x, pt.y, pt.z), @@ -82,7 +82,7 @@ impl CadCommand for QdimCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !matches!(self.step, Step::PlaceLine { .. }) { return None; } diff --git a/src/modules/annotate/radius_dim.rs b/src/modules/annotate/radius_dim.rs index 691d4fd04..558570916 100644 --- a/src/modules/annotate/radius_dim.rs +++ b/src/modules/annotate/radius_dim.rs @@ -5,7 +5,7 @@ use acadrust::EntityType; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_radius.svg")); @@ -49,7 +49,7 @@ impl CadCommand for RadiusDimensionCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::CenterPoint => { self.step = Step::RadiusPoint(pt); @@ -79,7 +79,7 @@ impl CadCommand for RadiusDimensionCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); match self.step { Step::CenterPoint => None, Step::RadiusPoint(center) => Some(preview_wire(vec![center, pt])), diff --git a/src/modules/annotate/table_cmd.rs b/src/modules/annotate/table_cmd.rs index 8d3a94db3..fa77d7718 100644 --- a/src/modules/annotate/table_cmd.rs +++ b/src/modules/annotate/table_cmd.rs @@ -10,7 +10,7 @@ use acadrust::entities::TableBuilder; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -116,7 +116,7 @@ impl CadCommand for TableCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Step::Insertion { cols, rows } = self.step { let ins = Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64); let table = TableBuilder::new(rows, cols) @@ -130,7 +130,7 @@ impl CadCommand for TableCommand { } } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if let Step::Insertion { cols, rows } = self.step { // Preview: outline of the table bounding box. let w = (cols as f32) * COL_WIDTH as f32; diff --git a/src/modules/annotate/text.rs b/src/modules/annotate/text.rs index 9b5e68197..1f6544078 100644 --- a/src/modules/annotate/text.rs +++ b/src/modules/annotate/text.rs @@ -1,7 +1,7 @@ use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::DVec3; pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/text.svg")); @@ -41,7 +41,7 @@ impl CadCommand for TextCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { // Hand off to the in-place plain-text editor anchored at the click. CmdResult::OpenTextEditor { pos: pt, @@ -58,7 +58,7 @@ impl CadCommand for TextCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } diff --git a/src/modules/annotate/textedit.rs b/src/modules/annotate/textedit.rs index bf223fbe9..c970ceaf5 100644 --- a/src/modules/annotate/textedit.rs +++ b/src/modules/annotate/textedit.rs @@ -8,7 +8,7 @@ // 4. In Single mode, editing an object exits the command immediately. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -95,7 +95,7 @@ impl CadCommand for TexteditCommand { self.step == Step::PickObject } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -160,7 +160,7 @@ impl CadCommand for TexteditCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } @@ -248,7 +248,7 @@ impl CadCommand for TexteditmodeCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } diff --git a/src/modules/annotate/tolerance_cmd.rs b/src/modules/annotate/tolerance_cmd.rs index 92aaba3dc..770a91fb5 100644 --- a/src/modules/annotate/tolerance_cmd.rs +++ b/src/modules/annotate/tolerance_cmd.rs @@ -7,7 +7,7 @@ use acadrust::entities::Tolerance; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -64,7 +64,7 @@ impl CadCommand for ToleranceCommand { Some(CmdResult::NeedPoint) } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Step::Insertion { text } = &self.step { let ins = Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64); let tol = Tolerance::with_text(ins, text.clone()); @@ -78,7 +78,7 @@ impl CadCommand for ToleranceCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !matches!(self.step, Step::Insertion { .. }) { return None; } diff --git a/src/modules/draw/clipboard/paste.rs b/src/modules/draw/clipboard/paste.rs index b623a6c0c..a2d5ce337 100644 --- a/src/modules/draw/clipboard/paste.rs +++ b/src/modules/draw/clipboard/paste.rs @@ -16,7 +16,7 @@ pub const MENU_ITEMS: &[(&str, &str, IconKind)] = &[ // ── CadCommand implementation ───────────────────────────────────────────── use acadrust::Handle; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -43,7 +43,7 @@ impl CadCommand for PasteCommand { "PASTECLIP Pick insertion point:".into() } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { CmdResult::PasteClipboard { base_pt: pt } } @@ -51,11 +51,11 @@ impl CadCommand for PasteCommand { CmdResult::Cancel } - fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec { vec![] } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let pt = pt.as_vec3(); let delta = pt - self.centroid; self.wires.iter().map(|w| w.translated(delta)).collect() } diff --git a/src/modules/draw/draw/attdef.rs b/src/modules/draw/draw/attdef.rs index cdf02b6f6..3a89ad286 100644 --- a/src/modules/draw/draw/attdef.rs +++ b/src/modules/draw/draw/attdef.rs @@ -9,7 +9,7 @@ use acadrust::entities::AttributeDefinition; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -106,7 +106,7 @@ impl CadCommand for AttdefCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Step::Insertion { tag, prompt, @@ -153,7 +153,7 @@ impl CadCommand for AttdefCommand { } } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if !matches!(self.step, Step::Insertion { .. }) { return None; } diff --git a/src/modules/draw/draw/donut.rs b/src/modules/draw/draw/donut.rs index 091e269aa..377686e11 100644 --- a/src/modules/draw/draw/donut.rs +++ b/src/modules/draw/draw/donut.rs @@ -12,7 +12,7 @@ use acadrust::entities::{LwPolyline, LwVertex}; use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -91,7 +91,7 @@ impl CadCommand for DonutCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.state { DonutState::PlaceCenter => { let entity = make_donut(pt.x as f64, pt.y as f64, self.inner_r, self.outer_r); diff --git a/src/modules/draw/draw/hatch.rs b/src/modules/draw/draw/hatch.rs index c2d9dc905..0212c6d45 100644 --- a/src/modules/draw/draw/hatch.rs +++ b/src/modules/draw/draw/hatch.rs @@ -13,7 +13,7 @@ use crate::command::{CadCommand, CmdResult}; use crate::modules::IconKind; use crate::scene::model::hatch_model::{HatchModel, HatchPattern, PatFamily}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; // ── Icons ────────────────────────────────────────────────────────────────── @@ -154,7 +154,7 @@ impl CadCommand for HatchCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &self.mode { Mode::PickInside => { let xy = [pt.x, pt.y]; @@ -204,7 +204,7 @@ impl CadCommand for HatchCommand { None } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if let Mode::Manual = &self.mode { if self.manual_pts.is_empty() { return None; @@ -292,7 +292,7 @@ impl CadCommand for GradientCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &self.mode { Mode::PickInside => { let xy = [pt.x, pt.y]; @@ -342,7 +342,7 @@ impl CadCommand for GradientCommand { None } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if let Mode::Manual = &self.mode { if self.manual_pts.is_empty() { return None; @@ -395,7 +395,7 @@ impl CadCommand for BoundaryCommand { format!("BOUNDARY Pick internal point:{miss}") } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); let xy = [pt.x, pt.y]; for outline in &self.outlines { if point_in_polygon(xy, outline) { diff --git a/src/modules/draw/draw/hatchedit.rs b/src/modules/draw/draw/hatchedit.rs index f4f2eb18a..7620df141 100644 --- a/src/modules/draw/draw/hatchedit.rs +++ b/src/modules/draw/draw/hatchedit.rs @@ -9,7 +9,7 @@ // Press Enter to apply changes. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -67,7 +67,7 @@ impl CadCommand for HatcheditCommand { matches!(self.step, HatcheditStep::PickHatch) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -136,7 +136,7 @@ impl CadCommand for HatcheditCommand { Some(CmdResult::NeedPoint) } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/draw/line.rs b/src/modules/draw/draw/line.rs index beea71e97..facc4c3ea 100644 --- a/src/modules/draw/draw/line.rs +++ b/src/modules/draw/draw/line.rs @@ -12,7 +12,7 @@ use acadrust::{EntityType, Line}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::DVec3; // ── Ribbon definition ───────────────────────────────────────────────────── @@ -29,7 +29,7 @@ pub fn tool() -> ToolDef { pub struct LineCommand { /// The last committed point (start of the next segment). - last: Option, + last: Option, } impl LineCommand { @@ -51,11 +51,11 @@ impl CadCommand for LineCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { if let Some(last) = self.last { let line = Line::from_points( - Vector3::new(last.x as f64, last.y as f64, last.z as f64), - Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64), + Vector3::new(last.x, last.y, last.z), + Vector3::new(pt.x, pt.y, pt.z), ); self.last = Some(pt); CmdResult::CommitEntity(EntityType::Line(line)) @@ -73,11 +73,14 @@ impl CadCommand for LineCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let last = self.last?; Some(WireModel { name: "rubber_band".to_string(), - points: vec![[last.x, last.y, last.z], [pt.x, pt.y, pt.z]], + points: vec![ + [last.x as f32, last.y as f32, last.z as f32], + [pt.x as f32, pt.y as f32, pt.z as f32], + ], points_low: Vec::new(), color: WireModel::CYAN, selected: false, diff --git a/src/modules/draw/draw/mline.rs b/src/modules/draw/draw/mline.rs index 15e7b09d1..7c753b8a1 100644 --- a/src/modules/draw/draw/mline.rs +++ b/src/modules/draw/draw/mline.rs @@ -8,7 +8,7 @@ use acadrust::entities::MLine; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -111,7 +111,7 @@ impl CadCommand for MlineCommand { None } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); self.points.push(pt); CmdResult::NeedPoint } @@ -124,7 +124,7 @@ impl CadCommand for MlineCommand { CmdResult::CommitAndExit(entity) } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.points.is_empty() { return None; } diff --git a/src/modules/draw/draw/point.rs b/src/modules/draw/draw/point.rs index 2c4e292f0..8b7de36cf 100644 --- a/src/modules/draw/draw/point.rs +++ b/src/modules/draw/draw/point.rs @@ -9,7 +9,7 @@ use acadrust::{EntityType, Point as CadPoint}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::DVec3; #[allow(dead_code)] pub fn tool() -> ToolDef { @@ -37,7 +37,7 @@ impl CadCommand for PointCommand { "POINT Specify point [Enter=done]:".into() } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let p = CadPoint { location: Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64), ..Default::default() @@ -51,7 +51,7 @@ impl CadCommand for PointCommand { fn on_escape(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } diff --git a/src/modules/draw/draw/polyline.rs b/src/modules/draw/draw/polyline.rs index d508b6fcc..5d8ade5bc 100644 --- a/src/modules/draw/draw/polyline.rs +++ b/src/modules/draw/draw/polyline.rs @@ -12,7 +12,7 @@ use acadrust::entities::LwVertex; use acadrust::types::Vector2; use acadrust::{EntityType, Handle, LwPolyline}; -use glam::{Vec2, Vec3}; +use glam::{DVec3, Vec2, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -224,7 +224,7 @@ impl CadCommand for PlineCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if !self.vertices.is_empty() { let last = *self.vertices.last().unwrap(); let last_idx = self.vertices.len() - 1; @@ -302,7 +302,7 @@ impl CadCommand for PlineCommand { } } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); // The committed vertices already render as a real document entity, so // the preview is just the pending segment from the last vertex to the // cursor. (#119) diff --git a/src/modules/draw/draw/raster_image.rs b/src/modules/draw/draw/raster_image.rs index 75cb63b68..bb43e50cc 100644 --- a/src/modules/draw/draw/raster_image.rs +++ b/src/modules/draw/draw/raster_image.rs @@ -9,7 +9,7 @@ use acadrust::entities::RasterImage; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -75,7 +75,7 @@ impl CadCommand for ImageCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Some(origin) = self.origin { let entity = self.make_entity(origin, pt); CmdResult::CommitAndExit(entity) @@ -97,7 +97,7 @@ impl CadCommand for ImageCommand { } } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let origin = self.origin?; let world_width = (pt.x - origin.x).abs().max(0.001); let world_height = world_width / self.aspect() as f32; diff --git a/src/modules/draw/draw/ray.rs b/src/modules/draw/draw/ray.rs index 3bf37ca47..601605884 100644 --- a/src/modules/draw/draw/ray.rs +++ b/src/modules/draw/draw/ray.rs @@ -10,7 +10,7 @@ use acadrust::EntityType; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; const DISPLAY_EXTENT: f32 = 1_000_000.0; @@ -39,7 +39,7 @@ impl CadCommand for RayCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Some(base) = self.base { let dir = pt - base; let len = dir.length(); @@ -69,7 +69,7 @@ impl CadCommand for RayCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let base = self.base?; let dir = (pt - base).normalize_or_zero(); let far = base + dir * DISPLAY_EXTENT; @@ -120,7 +120,7 @@ impl CadCommand for XLineCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Some(base) = self.base { let dir = pt - base; let len = dir.length(); @@ -148,7 +148,7 @@ impl CadCommand for XLineCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let base = self.base?; let dir = (pt - base).normalize_or_zero(); let far_pos = base + dir * DISPLAY_EXTENT; diff --git a/src/modules/draw/draw/revcloud.rs b/src/modules/draw/draw/revcloud.rs index 0a5d51a43..c2a971995 100644 --- a/src/modules/draw/draw/revcloud.rs +++ b/src/modules/draw/draw/revcloud.rs @@ -7,7 +7,7 @@ use acadrust::entities::LwPolyline; use acadrust::types::Vector2; use acadrust::{entities::LwVertex, EntityType}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -59,7 +59,7 @@ impl CadCommand for RevCloudCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); self.points.push(pt); CmdResult::NeedPoint } @@ -72,7 +72,7 @@ impl CadCommand for RevCloudCommand { CmdResult::CommitAndExit(entity) } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.points.is_empty() { return None; } diff --git a/src/modules/draw/draw/spline.rs b/src/modules/draw/draw/spline.rs index 3b1f64440..598d7a4a1 100644 --- a/src/modules/draw/draw/spline.rs +++ b/src/modules/draw/draw/spline.rs @@ -9,7 +9,7 @@ use acadrust::{EntityType, Spline}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; #[allow(dead_code)] pub fn tool() -> ToolDef { @@ -84,7 +84,7 @@ impl CadCommand for SplineCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); self.pts.push(pt); CmdResult::NeedPoint } @@ -103,7 +103,7 @@ impl CadCommand for SplineCommand { } } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.pts.is_empty() { return None; } diff --git a/src/modules/draw/draw/wipeout.rs b/src/modules/draw/draw/wipeout.rs index a2b2899b1..07eea2f51 100644 --- a/src/modules/draw/draw/wipeout.rs +++ b/src/modules/draw/draw/wipeout.rs @@ -7,7 +7,7 @@ use acadrust::entities::Wipeout; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -79,7 +79,7 @@ impl CadCommand for WipeoutCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &self.mode { WipeoutMode::Rectangular => { if let Some(p1) = self.first { @@ -107,7 +107,7 @@ impl CadCommand for WipeoutCommand { } } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); match &self.mode { WipeoutMode::Rectangular => { let p1 = self.first?; diff --git a/src/modules/draw/groups/group.rs b/src/modules/draw/groups/group.rs index 572a07bb9..6b7a12f9d 100644 --- a/src/modules/draw/groups/group.rs +++ b/src/modules/draw/groups/group.rs @@ -14,7 +14,7 @@ pub fn tool() -> ToolDef { // ── CadCommand implementation ───────────────────────────────────────────── use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -64,11 +64,11 @@ impl CadCommand for GroupCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } - fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/draw/groups/ungroup.rs b/src/modules/draw/groups/ungroup.rs index aea77e3b4..606f7f4b8 100644 --- a/src/modules/draw/groups/ungroup.rs +++ b/src/modules/draw/groups/ungroup.rs @@ -14,7 +14,7 @@ pub fn tool() -> ToolDef { // ── CadCommand implementation ───────────────────────────────────────────── use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -47,7 +47,7 @@ impl CadCommand for UngroupCommand { CmdResult::DeleteGroups { handles } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } @@ -55,7 +55,7 @@ impl CadCommand for UngroupCommand { CmdResult::Cancel } - fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/draw/inquiry/area.rs b/src/modules/draw/inquiry/area.rs index 22c50e89f..0778e47a6 100644 --- a/src/modules/draw/inquiry/area.rs +++ b/src/modules/draw/inquiry/area.rs @@ -1,7 +1,7 @@ // AREA command — compute area and perimeter of a polygon picked point by point. // Press Enter to close and calculate. -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -32,7 +32,7 @@ impl CadCommand for AreaCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); self.points.push(pt); CmdResult::NeedPoint } @@ -56,7 +56,7 @@ impl CadCommand for AreaCommand { CmdResult::Measurement(msg) } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.points.is_empty() { return None; } diff --git a/src/modules/draw/inquiry/dist.rs b/src/modules/draw/inquiry/dist.rs index c3a6ef29d..dd961e177 100644 --- a/src/modules/draw/inquiry/dist.rs +++ b/src/modules/draw/inquiry/dist.rs @@ -1,6 +1,6 @@ // DIST command — measure distance and angle between two picked points. -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -28,7 +28,7 @@ impl CadCommand for DistCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Some(p1) = self.first { let delta = pt - p1; let dist = delta.length(); @@ -56,7 +56,7 @@ impl CadCommand for DistCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let p1 = self.first?; Some(WireModel { name: "dist_preview".into(), diff --git a/src/modules/draw/inquiry/divide.rs b/src/modules/draw/inquiry/divide.rs index 2f5140ad1..81f280f49 100644 --- a/src/modules/draw/inquiry/divide.rs +++ b/src/modules/draw/inquiry/divide.rs @@ -6,7 +6,7 @@ use std::f64::consts::PI; use acadrust::entities::Point as PointEnt; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -43,7 +43,7 @@ impl CadCommand for DivideCommand { self.target.is_none() } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -71,7 +71,7 @@ impl CadCommand for DivideCommand { Some(CmdResult::DivideEntity { handle, n }) } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -112,7 +112,7 @@ impl CadCommand for MeasureCommand { self.target.is_none() } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -148,7 +148,7 @@ impl CadCommand for MeasureCommand { }) } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/inquiry/id.rs b/src/modules/draw/inquiry/id.rs index ac4aa2ed1..137ffb886 100644 --- a/src/modules/draw/inquiry/id.rs +++ b/src/modules/draw/inquiry/id.rs @@ -1,6 +1,6 @@ // ID command — report coordinates of a picked point. -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -21,7 +21,7 @@ impl CadCommand for IdCommand { "ID Specify point:".into() } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { // Drawing plane is world XY (z = elevation). let x = pt.x; let y = pt.y; diff --git a/src/modules/draw/layers/match_layer.rs b/src/modules/draw/layers/match_layer.rs index 1b9aaa89a..b2103b6d8 100644 --- a/src/modules/draw/layers/match_layer.rs +++ b/src/modules/draw/layers/match_layer.rs @@ -16,7 +16,7 @@ pub fn tool() -> ToolDef { // ── CadCommand implementation ───────────────────────────────────────────── use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -66,7 +66,7 @@ impl CadCommand for LayMatchCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -75,7 +75,7 @@ impl CadCommand for LayMatchCommand { fn on_escape(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/draw/modify/align.rs b/src/modules/draw/modify/align.rs index fea32cf7e..8d44f4191 100644 --- a/src/modules/draw/modify/align.rs +++ b/src/modules/draw/modify/align.rs @@ -10,7 +10,7 @@ // With 2 pairs: translate + rotate (+ optional uniform scale to fit) use acadrust::Handle; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult, EntityTransform}; @@ -74,7 +74,7 @@ impl CadCommand for AlignCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.state { AlignState::Gathering => CmdResult::NeedPoint, AlignState::Src1 => { @@ -117,7 +117,7 @@ impl CadCommand for AlignCommand { let delta = d - s; CmdResult::TransformSelected( self.handles.clone(), - EntityTransform::Translate(delta), + EntityTransform::Translate(delta.as_dvec3()), ) } _ => CmdResult::Cancel, @@ -163,7 +163,7 @@ impl AlignCommand { let delta = d1 - s1; return CmdResult::TransformSelected( self.handles.clone(), - EntityTransform::Translate(delta), + EntityTransform::Translate(delta.as_dvec3()), ); } @@ -182,8 +182,8 @@ impl AlignCommand { // Compose via AlignTransform CmdResult CmdResult::AlignSelected { handles: self.handles.clone(), - src1: s1, - dst1: d1, + src1: s1.as_dvec3(), + dst1: d1.as_dvec3(), angle_rad: angle, scale: scale_factor, } diff --git a/src/modules/draw/modify/attedit.rs b/src/modules/draw/modify/attedit.rs index f98a2dc0b..465a7a1c5 100644 --- a/src/modules/draw/modify/attedit.rs +++ b/src/modules/draw/modify/attedit.rs @@ -7,7 +7,7 @@ // After all attributes are processed, commit via ReplaceMany. use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -59,7 +59,7 @@ impl CadCommand for AtteditCommand { matches!(self.step, Step::SelectInsert) } - fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -114,13 +114,13 @@ impl CadCommand for AtteditCommand { None } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_preview_wires(&mut self, _pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, _pt: DVec3) -> Vec { vec![] } diff --git a/src/modules/draw/modify/break_cmd.rs b/src/modules/draw/modify/break_cmd.rs index a26933c9d..1aacdb156 100644 --- a/src/modules/draw/modify/break_cmd.rs +++ b/src/modules/draw/modify/break_cmd.rs @@ -15,7 +15,7 @@ use acadrust::entities::{ }; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use truck_modeling::base::{BoundedCurve, Cut}; use crate::command::{CadCommand, CmdResult}; @@ -382,7 +382,7 @@ impl CadCommand for BreakInteractiveCommand { self.target.is_none() } - 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() { return CmdResult::NeedPoint; } @@ -391,7 +391,7 @@ impl CadCommand for BreakInteractiveCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); let handle = match self.target { Some(h) => h, None => return CmdResult::Cancel, @@ -403,14 +403,14 @@ impl CadCommand for BreakInteractiveCommand { return CmdResult::NeedPoint; } }; - CmdResult::BreakEntity { handle, p1, p2: pt } + CmdResult::BreakEntity { handle, p1: p1.as_dvec3(), p2: pt.as_dvec3() } } fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } @@ -444,7 +444,7 @@ impl CadCommand for BreakAtPointCommand { self.target.is_none() } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -452,12 +452,12 @@ impl CadCommand for BreakAtPointCommand { CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.target { Some(handle) => CmdResult::BreakEntity { handle, - p1: pt, - p2: pt, + p1: pt.as_dvec3(), + p2: pt.as_dvec3(), }, None => CmdResult::Cancel, } diff --git a/src/modules/draw/modify/copy.rs b/src/modules/draw/modify/copy.rs index f35a4b3af..0a43f4ca6 100644 --- a/src/modules/draw/modify/copy.rs +++ b/src/modules/draw/modify/copy.rs @@ -6,7 +6,7 @@ // Step 2+: each click makes another copy at (click - base); Enter to finish. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -27,7 +27,7 @@ pub fn tool() -> ToolDef { enum Step { Base, - Placing(Vec3), + Placing(DVec3), } pub struct CopyCommand { @@ -66,7 +66,7 @@ impl CadCommand for CopyCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.step { Step::Base => { self.step = Step::Placing(pt); @@ -87,7 +87,7 @@ impl CadCommand for CopyCommand { CmdResult::Cancel } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let Step::Placing(base) = &self.step else { return vec![]; }; @@ -95,11 +95,14 @@ impl CadCommand for CopyCommand { let mut out: Vec = self .wire_models .iter() - .map(|w| w.translated(delta)) + .map(|w| w.translated(delta.as_vec3())) .collect(); out.push(WireModel::solid( "rubber_band".into(), - vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], + vec![ + [base.x as f32, base.y as f32, base.z as f32], + [pt.x as f32, pt.y as f32, pt.z as f32], + ], WireModel::CYAN, false, )); diff --git a/src/modules/draw/modify/explode.rs b/src/modules/draw/modify/explode.rs index c4869b81e..b764616ed 100644 --- a/src/modules/draw/modify/explode.rs +++ b/src/modules/draw/modify/explode.rs @@ -26,7 +26,7 @@ use acadrust::{CadDocument, EntityType, Handle}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; -use glam::Vec3; +use glam::DVec3; // ── Ribbon definition ────────────────────────────────────────────────────── @@ -447,7 +447,7 @@ impl CadCommand for ExplodeCommand { "EXPLODE Select objects to explode:".into() } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::Cancel } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/modify/fillet.rs b/src/modules/draw/modify/fillet.rs index 5bcaf7168..7d09129c4 100644 --- a/src/modules/draw/modify/fillet.rs +++ b/src/modules/draw/modify/fillet.rs @@ -12,7 +12,7 @@ use acadrust::entities::{Arc as ArcEnt, Line as LineEnt, LwPolyline}; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::DVec3; const TAU: f64 = std::f64::consts::TAU; @@ -1328,7 +1328,7 @@ impl CadCommand for FilletCommand { !matches!(self.step, FilletStep::WaitingForRadius) } - fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -1406,7 +1406,7 @@ impl CadCommand for FilletCommand { } } - fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec { if handle.is_null() { return vec![]; } @@ -1484,7 +1484,7 @@ impl CadCommand for FilletCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -1743,7 +1743,7 @@ impl CadCommand for ChamferCommand { ) } - fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -1825,7 +1825,7 @@ impl CadCommand for ChamferCommand { } } - fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec { if handle.is_null() { return vec![]; } @@ -1915,7 +1915,7 @@ impl CadCommand for ChamferCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/modify/join.rs b/src/modules/draw/modify/join.rs index 272bf7196..70c60b3ab 100644 --- a/src/modules/draw/modify/join.rs +++ b/src/modules/draw/modify/join.rs @@ -11,7 +11,7 @@ use acadrust::types::{Vector2, Vector3}; use acadrust::{EntityType, Handle}; -use glam::{DVec3, Vec3}; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -52,7 +52,7 @@ impl CadCommand for JoinCommand { CmdResult::NeedPoint } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } diff --git a/src/modules/draw/modify/lengthen.rs b/src/modules/draw/modify/lengthen.rs index 1f742bcec..c5527dc38 100644 --- a/src/modules/draw/modify/lengthen.rs +++ b/src/modules/draw/modify/lengthen.rs @@ -13,7 +13,7 @@ use acadrust::entities::{ }; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use truck_modeling::base::{BoundedCurve, Cut}; use crate::command::{CadCommand, CmdResult}; @@ -53,7 +53,7 @@ impl CadCommand for LengthenCommand { matches!(self.state, LenState::PickEntity) } - 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() { return CmdResult::NeedPoint; } @@ -81,6 +81,7 @@ impl CadCommand for LengthenCommand { LenState::PickOption { handle, pick_pt } => (*handle, *pick_pt), _ => return None, }; + let pick_pt = pick_pt.as_dvec3(); let text = text.trim().to_uppercase(); if let Some(rest) = text.strip_prefix("DE ").or_else(|| text.strip_prefix("DE")) { @@ -125,7 +126,7 @@ impl CadCommand for LengthenCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/modify/mirror.rs b/src/modules/draw/modify/mirror.rs index 023df3f23..2a4dbb7aa 100644 --- a/src/modules/draw/modify/mirror.rs +++ b/src/modules/draw/modify/mirror.rs @@ -9,7 +9,7 @@ // Yes → flip the original in place (no copy kept) use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -26,9 +26,9 @@ pub fn tool() -> ToolDef { enum Step { P1, - P2(Vec3), + P2(DVec3), /// Both mirror-line points fixed; waiting on the erase-source answer. - AskErase { p1: Vec3, p2: Vec3 }, + AskErase { p1: DVec3, p2: DVec3 }, } pub struct MirrorCommand { @@ -66,7 +66,7 @@ impl CadCommand for MirrorCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.step { Step::P1 => { self.step = Step::P2(pt); @@ -113,7 +113,7 @@ impl CadCommand for MirrorCommand { Some(self.finish(p1, p2, erase)) } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { // While picking the second point the ghost tracks the cursor; once it // is fixed (erase prompt) the ghost freezes at the chosen axis. let (p1, p2) = match &self.step { @@ -125,12 +125,15 @@ impl CadCommand for MirrorCommand { let mut out: Vec = self .wire_models .iter() - .map(|w| w.mirrored(p1, p2)) + .map(|w| w.mirrored(p1.as_vec3(), p2.as_vec3())) .collect(); // Mirror-axis line (rubber-band). out.push(WireModel::solid( "rubber_band".into(), - vec![[p1.x, p1.y, p1.z], [p2.x, p2.y, p2.z]], + vec![ + [p1.x as f32, p1.y as f32, p1.z as f32], + [p2.x as f32, p2.y as f32, p2.z as f32], + ], WireModel::CYAN, false, )); @@ -141,7 +144,7 @@ impl CadCommand for MirrorCommand { impl MirrorCommand { /// Commit the mirror. `erase` true flips the originals in place; false /// keeps them and adds a mirrored copy. Either way the command ends. - fn finish(&self, p1: Vec3, p2: Vec3, erase: bool) -> CmdResult { + fn finish(&self, p1: DVec3, p2: DVec3, erase: bool) -> CmdResult { let xform = EntityTransform::Mirror { p1, p2 }; if erase { CmdResult::TransformSelected(self.handles.clone(), xform) diff --git a/src/modules/draw/modify/offset.rs b/src/modules/draw/modify/offset.rs index a269726f4..51a6a29f6 100644 --- a/src/modules/draw/modify/offset.rs +++ b/src/modules/draw/modify/offset.rs @@ -18,7 +18,7 @@ use acadrust::entities::{ Spline as SplineEnt, }; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::draw::defaults; @@ -632,7 +632,7 @@ impl CadCommand for OffsetCommand { matches!(self.step, Step::SelectObject) } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() || !matches!(self.step, Step::SelectObject) { return CmdResult::NeedPoint; } @@ -672,10 +672,10 @@ impl CadCommand for OffsetCommand { } } - fn dyn_live_value(&self, cursor: Vec3) -> Option { + fn dyn_live_value(&self, cursor: DVec3) -> Option { match &self.step { Step::PickSide { entity, locked, .. } => { - Some(locked.unwrap_or_else(|| perp_distance(entity, cursor))) + Some(locked.unwrap_or_else(|| perp_distance(entity, cursor.as_vec3()))) } _ => None, } @@ -697,7 +697,7 @@ impl CadCommand for OffsetCommand { None } - fn on_hover_entity(&mut self, handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, handle: Handle, _pt: DVec3) -> Vec { if handle.is_null() { return vec![]; } @@ -719,33 +719,33 @@ impl CadCommand for OffsetCommand { vec![] } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let (locked, entity) = match &self.step { Step::PickSide { locked, entity, .. } => (*locked, entity.clone()), _ => return CmdResult::NeedPoint, }; - let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt)); + let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt.as_vec3())); if mag < 1e-9 { return CmdResult::NeedPoint; } - match compute_offset(&entity, mag, pt) { + match compute_offset(&entity, mag, pt.as_vec3()) { Some(new_entity) => CmdResult::CommitAndExit(new_entity), None => CmdResult::NeedPoint, } } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let (locked, entity) = match &self.step { Step::PickSide { locked, entity, .. } => (*locked, entity.clone()), _ => return vec![], }; - let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt)); + let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt.as_vec3())); if mag < 1e-9 { return vec![]; } - if let Some(result) = compute_offset(&entity, mag, pt) { + if let Some(result) = compute_offset(&entity, mag, pt.as_vec3()) { let pts = entity_wire_pts(&result); if !pts.is_empty() { return vec![WireModel::solid( diff --git a/src/modules/draw/modify/pedit.rs b/src/modules/draw/modify/pedit.rs index 5b9431a9c..3431cc182 100644 --- a/src/modules/draw/modify/pedit.rs +++ b/src/modules/draw/modify/pedit.rs @@ -10,7 +10,7 @@ // X / EXIT — exit use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; @@ -41,7 +41,7 @@ impl CadCommand for PeditCommand { self.target.is_none() } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -90,7 +90,7 @@ impl CadCommand for PeditCommand { None } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/modify/refedit.rs b/src/modules/draw/modify/refedit.rs index bc332d28f..14773e696 100644 --- a/src/modules/draw/modify/refedit.rs +++ b/src/modules/draw/modify/refedit.rs @@ -14,7 +14,7 @@ // require per-entity matrix transforms not yet in EntityTransform. use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -80,7 +80,7 @@ impl CadCommand for RefEditPickCommand { true } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -89,7 +89,7 @@ impl CadCommand for RefEditPickCommand { CmdResult::Relaunch(format!("REFEDIT_BEGIN:{}", handle.value()), vec![handle]) } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -134,7 +134,7 @@ impl CadCommand for RefCloseCommand { // Default: SAVE CmdResult::Relaunch("REFCLOSE_SAVE".into(), vec![]) } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } } diff --git a/src/modules/draw/modify/rotate.rs b/src/modules/draw/modify/rotate.rs index 8005ab54c..9898447d3 100644 --- a/src/modules/draw/modify/rotate.rs +++ b/src/modules/draw/modify/rotate.rs @@ -7,7 +7,7 @@ // Step 3: pick destination point → rotates by (dest_angle - ref_angle) use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult, DynField, EntityTransform}; use crate::modules::draw::defaults; @@ -29,8 +29,8 @@ pub fn tool() -> ToolDef { enum Step { Center, - RefPoint { center: Vec3 }, - Angle { center: Vec3, ref_angle: f32 }, + RefPoint { center: DVec3 }, + Angle { center: DVec3, ref_angle: f64 }, } pub struct RotateCommand { @@ -73,7 +73,7 @@ impl CadCommand for RotateCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.step { Step::Center => { self.step = Step::RefPoint { center: pt }; @@ -90,13 +90,13 @@ impl CadCommand for RotateCommand { let ref_angle = *ref_angle; let dest_angle = (pt.y - center.y).atan2(pt.x - center.x); let delta = dest_angle - ref_angle; - defaults::set_rotate_angle(delta.to_degrees()); - self.default_angle = delta.to_degrees(); + defaults::set_rotate_angle(delta.to_degrees() as f32); + self.default_angle = delta.to_degrees() as f32; CmdResult::TransformSelected( self.handles.clone(), EntityTransform::Rotate { center, - angle_rad: delta, + angle_rad: delta as f32, }, ) } @@ -137,14 +137,17 @@ impl CadCommand for RotateCommand { None } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let (center, ref_angle) = match &self.step { Step::Angle { center, ref_angle } => (*center, *ref_angle), Step::RefPoint { center } => { // Show a reference line from center to cursor only. return vec![WireModel::solid( "rubber_band".into(), - vec![[center.x, center.y, center.z], [pt.x, pt.y, pt.z]], + vec![ + [center.x as f32, center.y as f32, center.z as f32], + [pt.x as f32, pt.y as f32, pt.z as f32], + ], WireModel::CYAN, false, )]; @@ -157,12 +160,12 @@ impl CadCommand for RotateCommand { // committing with Enter rotates the way the cursor is dragging — the // dynamic-input box shows the unsigned magnitude, but the committed // value must keep its direction (clockwise = negative). - self.default_angle = angle_rad.to_degrees(); + self.default_angle = angle_rad.to_degrees() as f32; // Object ghosts rotated to the new angle. The rotation sweep arc is // drawn by the dynamic-input overlay (polar guide), not here. self.wire_models .iter() - .map(|w| w.rotated(center, angle_rad)) + .map(|w| w.rotated(center.as_vec3(), angle_rad as f32)) .collect() } @@ -179,7 +182,7 @@ impl CadCommand for RotateCommand { // direction. The polar guide arc is anchored at the centre and starts // at the reference (via ref_point), with the value box centred on it. if let Step::Angle { center, ref_angle } = self.step { - let ref_dir = Vec3::new(center.x + ref_angle.cos(), center.y + ref_angle.sin(), center.z); + let ref_dir = DVec3::new(center.x + ref_angle.cos(), center.y + ref_angle.sin(), center.z); Some(DynSpec { anchor: DynAnchor::Point(center), fields: vec![DynFieldSpec::new(DynRole::Angle)], @@ -195,12 +198,12 @@ impl CadCommand for RotateCommand { matches!(self.step, Step::Angle { .. }) } - fn dyn_live_value(&self, cursor: Vec3) -> Option { + fn dyn_live_value(&self, cursor: DVec3) -> Option { // The rotation amount = cursor direction from the centre minus the // reference angle, so the box reads the actual rotation. if let Step::Angle { center, ref_angle } = &self.step { let dest = (cursor.y - center.y).atan2(cursor.x - center.x); - Some(crate::command::dyn_display_angle_deg(dest - ref_angle) as f64) + Some(crate::command::dyn_display_angle_deg((dest - ref_angle) as f32) as f64) } else { None } diff --git a/src/modules/draw/modify/scale.rs b/src/modules/draw/modify/scale.rs index 41174fba1..15f735625 100644 --- a/src/modules/draw/modify/scale.rs +++ b/src/modules/draw/modify/scale.rs @@ -13,7 +13,7 @@ // Step 2b: specify new length (pick a point or type a length) use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::modules::draw::defaults; @@ -33,11 +33,11 @@ pub fn tool() -> ToolDef { enum Step { Base, /// Default flow: factor is the cursor distance from `base`. - Factor { base: Vec3 }, + Factor { base: DVec3 }, /// Reference flow: defining the reference length from `base`. - RefLen { base: Vec3 }, + RefLen { base: DVec3 }, /// Reference flow: factor is `cursor_dist / ref_dist` from `base`. - RefNew { base: Vec3, ref_dist: f32 }, + RefNew { base: DVec3, ref_dist: f32 }, } pub struct ScaleCommand { @@ -58,7 +58,7 @@ impl ScaleCommand { } /// Commit a uniform scale about `base` and end the command. - fn commit(&self, base: Vec3, factor: f32) -> CmdResult { + fn commit(&self, base: DVec3, factor: f32) -> CmdResult { defaults::set_scale_factor(factor); CmdResult::TransformSelected( self.handles.clone(), @@ -95,7 +95,7 @@ impl CadCommand for ScaleCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.step { Step::Base => { self.step = Step::Factor { base: pt }; @@ -103,18 +103,18 @@ impl CadCommand for ScaleCommand { } Step::Factor { base } => { let base = *base; - let factor = base.distance(pt).max(1e-6); + let factor = base.distance(pt).max(1e-6) as f32; self.commit(base, factor) } Step::RefLen { base } => { let base = *base; - let ref_dist = base.distance(pt).max(1e-6); + let ref_dist = base.distance(pt).max(1e-6) as f32; 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); + let new_dist = base.distance(pt).max(1e-6) as f32; self.commit(base, new_dist / *ref_dist) } } @@ -164,19 +164,22 @@ impl CadCommand for ScaleCommand { } } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { - let (base, factor) = match &self.step { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { + let (base, factor): (DVec3, f32) = match &self.step { // Default flow: scale live by cursor distance from the base. - Step::Factor { base } => (*base, base.distance(pt).max(1e-6)), + 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) / ref_dist) + (*base, base.distance(pt).max(1e-6) as f32 / ref_dist) } // Reference-length step: rubber-band only, no factor defined yet. Step::RefLen { base } => { return vec![WireModel::solid( "rubber_band".into(), - vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], + vec![ + [base.x as f32, base.y as f32, base.z as f32], + [pt.x as f32, pt.y as f32, pt.z as f32], + ], WireModel::CYAN, false, )]; @@ -186,11 +189,14 @@ impl CadCommand for ScaleCommand { let mut out: Vec = self .wire_models .iter() - .map(|w| w.scaled(base, factor)) + .map(|w| w.scaled(base.as_vec3(), factor)) .collect(); out.push(WireModel::solid( "rubber_band".into(), - vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], + vec![ + [base.x as f32, base.y as f32, base.z as f32], + [pt.x as f32, pt.y as f32, pt.z as f32], + ], WireModel::CYAN, false, )); diff --git a/src/modules/draw/modify/splinedit.rs b/src/modules/draw/modify/splinedit.rs index d9032a9a8..83326eef6 100644 --- a/src/modules/draw/modify/splinedit.rs +++ b/src/modules/draw/modify/splinedit.rs @@ -10,7 +10,7 @@ // Control-point dragging is already supported via the grip editing system. use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -61,7 +61,7 @@ impl CadCommand for SplineditCommand { matches!(self.step, Step::SelectSpline) } - fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -96,13 +96,13 @@ impl CadCommand for SplineditCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_preview_wires(&mut self, _pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/draw/modify/stretch.rs b/src/modules/draw/modify/stretch.rs index f1a048ccc..2e77cf240 100644 --- a/src/modules/draw/modify/stretch.rs +++ b/src/modules/draw/modify/stretch.rs @@ -16,7 +16,7 @@ // All others : move the whole entity if any point is inside. use acadrust::Handle; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -86,7 +86,7 @@ impl CadCommand for StretchCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &self.step { Step::WindowCorner1 => { self.step = Step::WindowCorner2(pt); @@ -115,9 +115,9 @@ impl CadCommand for StretchCommand { let delta = pt - *base; CmdResult::StretchEntities { handles: self.handles.clone(), - win_min: *win_min, - win_max: *win_max, - delta, + win_min: win_min.as_dvec3(), + win_max: win_max.as_dvec3(), + delta: delta.as_dvec3(), } } } @@ -130,7 +130,7 @@ impl CadCommand for StretchCommand { CmdResult::Cancel } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let pt = pt.as_vec3(); match &self.step { Step::WindowCorner2(c1) => { // Show crossing-window rectangle preview (dashed green) diff --git a/src/modules/draw/modify/torient.rs b/src/modules/draw/modify/torient.rs index 494d0c0f2..87b07c99f 100644 --- a/src/modules/draw/modify/torient.rs +++ b/src/modules/draw/modify/torient.rs @@ -6,7 +6,7 @@ // Step 2: If first point picked, pick second point to define angle vector. use acadrust::Handle; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult, DynField}; use crate::scene::model::wire_model::WireModel; @@ -122,7 +122,7 @@ impl CadCommand for TorientCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { Step::AngleOrFirstPoint => { self.step = Step::SecondPoint { first_point: pt }; @@ -157,7 +157,7 @@ impl CadCommand for TorientCommand { } } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let pt = pt.as_vec3(); if let Step::SecondPoint { first_point } = self.step { vec![WireModel::solid( "rubber_band".into(), diff --git a/src/modules/draw/modify/translate.rs b/src/modules/draw/modify/translate.rs index a4ac31727..90e71e0ca 100644 --- a/src/modules/draw/modify/translate.rs +++ b/src/modules/draw/modify/translate.rs @@ -6,7 +6,7 @@ // Step 2: pick destination → translates all selected entities by (dest - base) use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -27,7 +27,7 @@ pub fn tool() -> ToolDef { enum Step { Base, - Target(Vec3), + Target(DVec3), } pub struct MoveCommand { @@ -64,7 +64,7 @@ impl CadCommand for MoveCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.step { Step::Base => { self.step = Step::Target(pt); @@ -87,7 +87,7 @@ impl CadCommand for MoveCommand { CmdResult::Cancel } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let Step::Target(base) = &self.step else { return vec![]; }; @@ -96,11 +96,14 @@ impl CadCommand for MoveCommand { let mut out: Vec = self .wire_models .iter() - .map(|w| w.translated(delta)) + .map(|w| w.translated(delta.as_vec3())) .collect(); out.push(WireModel::solid( "rubber_band".into(), - vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], + vec![ + [base.x as f32, base.y as f32, base.z as f32], + [pt.x as f32, pt.y as f32, pt.z as f32], + ], WireModel::CYAN, false, )); diff --git a/src/modules/draw/modify/trim.rs b/src/modules/draw/modify/trim.rs index 67c5b127a..b8eea2754 100644 --- a/src/modules/draw/modify/trim.rs +++ b/src/modules/draw/modify/trim.rs @@ -16,7 +16,7 @@ use acadrust::entities::{ }; use acadrust::types::Vector3; use acadrust::{EntityType, Handle}; -use glam::Vec3; +use glam::DVec3; use truck_modeling::base::{BoundedCurve, Cut, ParametricCurve}; use crate::command::{CadCommand, CmdResult}; @@ -1990,7 +1990,7 @@ impl CadCommand for TrimCommand { true } - fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -2169,7 +2169,7 @@ impl CadCommand for TrimCommand { self.geos = build_geos(&self.all_entities); } - fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec { if handle.is_null() { return vec![]; } @@ -2407,7 +2407,7 @@ impl CadCommand for TrimCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -2458,7 +2458,7 @@ impl CadCommand for ExtendCommand { true } - fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -2555,7 +2555,7 @@ impl CadCommand for ExtendCommand { } } - fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec { if handle.is_null() { return vec![]; } @@ -2643,7 +2643,7 @@ impl CadCommand for ExtendCommand { vec![] } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { diff --git a/src/modules/draw/properties/match_prop.rs b/src/modules/draw/properties/match_prop.rs index fb4ad1042..d08f34bd2 100644 --- a/src/modules/draw/properties/match_prop.rs +++ b/src/modules/draw/properties/match_prop.rs @@ -14,7 +14,7 @@ pub fn tool() -> ToolDef { // ── CadCommand implementation ───────────────────────────────────────────── use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -53,7 +53,7 @@ impl CadCommand for MatchPropCommand { !self.phase1_done() } - fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; // nothing hit, keep waiting } @@ -81,11 +81,11 @@ impl CadCommand for MatchPropCommand { CmdResult::Cancel } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } - fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/draw/select.rs b/src/modules/draw/select.rs index 9be87092d..d8635213b 100644 --- a/src/modules/draw/select.rs +++ b/src/modules/draw/select.rs @@ -6,7 +6,7 @@ // immediately — no Enter required. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -47,7 +47,7 @@ impl CadCommand for SelectObjectsCommand { // These are never called while is_selection_gathering is true, but the // trait requires implementations. - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -56,7 +56,7 @@ impl CadCommand for SelectObjectsCommand { fn on_escape(&mut self) -> CmdResult { CmdResult::Cancel } - fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec { + fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/insert/create_block.rs b/src/modules/insert/create_block.rs index 18f1f84d6..4107a1a2f 100644 --- a/src/modules/insert/create_block.rs +++ b/src/modules/insert/create_block.rs @@ -1,5 +1,5 @@ use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -52,7 +52,7 @@ impl CadCommand for CreateBlockCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { match &self.step { Step::Name => CmdResult::NeedPoint, Step::Base { name } => CmdResult::CreateBlock { @@ -85,7 +85,7 @@ impl CadCommand for CreateBlockCommand { Some(CmdResult::NeedPoint) } - fn on_preview_wires(&mut self, _pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, _pt: DVec3) -> Vec { vec![] } } diff --git a/src/modules/insert/insert_block.rs b/src/modules/insert/insert_block.rs index 385efc907..fc623e941 100644 --- a/src/modules/insert/insert_block.rs +++ b/src/modules/insert/insert_block.rs @@ -1,7 +1,7 @@ use acadrust::entities::{AttributeEntity, Insert}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -103,7 +103,7 @@ impl CadCommand for InsertBlockCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match &self.step { Step::Name => CmdResult::NeedPoint, Step::Point { name } => { @@ -156,7 +156,7 @@ impl CadCommand for InsertBlockCommand { } } - fn on_preview_wires(&mut self, pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, pt: DVec3) -> Vec { let pt = pt.as_vec3(); match (&self.step, &self.preview) { (Step::Point { .. }, Some((wires, base))) => { let delta = pt - *base; diff --git a/src/modules/insert/solid3d_cmds.rs b/src/modules/insert/solid3d_cmds.rs index 82e835aa0..9d4f1418f 100644 --- a/src/modules/insert/solid3d_cmds.rs +++ b/src/modules/insert/solid3d_cmds.rs @@ -7,7 +7,7 @@ // live in the Model tab (`modules::model::primitive_cmd`). use acadrust::{entities::Solid3D, EntityType}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; @@ -53,7 +53,7 @@ impl CadCommand for ExtrudeCommand { fn needs_entity_pick(&self) -> bool { self.step == ExtrudeStep::Pick } - fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -61,7 +61,7 @@ impl CadCommand for ExtrudeCommand { self.step = ExtrudeStep::Height; CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if self.step == ExtrudeStep::Height { return CmdResult::ExtrudeEntity { handle: self.target_handle, @@ -135,7 +135,7 @@ impl CadCommand for RevolveCommand { fn needs_entity_pick(&self) -> bool { self.step == RevolveStep::Pick } - fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -143,7 +143,7 @@ impl CadCommand for RevolveCommand { self.step = RevolveStep::AxisStart; CmdResult::NeedPoint } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.step { RevolveStep::AxisStart => { self.axis_start = pt; @@ -186,8 +186,8 @@ impl RevolveCommand { fn make_revolve(&self, angle_deg: f32) -> CmdResult { CmdResult::RevolveEntity { handle: self.target_handle, - axis_start: self.axis_start, - axis_end: self.axis_end, + axis_start: self.axis_start.as_dvec3(), + axis_end: self.axis_end.as_dvec3(), angle_deg, color: self.color, } @@ -231,7 +231,7 @@ impl CadCommand for SweepCommand { fn needs_entity_pick(&self) -> bool { true } - fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -248,7 +248,7 @@ impl CadCommand for SweepCommand { }, } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn on_enter(&mut self) -> CmdResult { @@ -289,7 +289,7 @@ impl CadCommand for LoftCommand { fn needs_entity_pick(&self) -> bool { true } - fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { + fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult { if handle.is_null() { return CmdResult::NeedPoint; } @@ -299,7 +299,7 @@ impl CadCommand for LoftCommand { } CmdResult::NeedPoint } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::NeedPoint } fn wants_text_input(&self) -> bool { diff --git a/src/modules/insert/xattach.rs b/src/modules/insert/xattach.rs index f6c79a880..3ba8a3427 100644 --- a/src/modules/insert/xattach.rs +++ b/src/modules/insert/xattach.rs @@ -12,7 +12,7 @@ use acadrust::entities::{Block, BlockEnd, Insert}; use acadrust::tables::block_record::{BlockFlags, BlockRecord}; use acadrust::types::Vector3; use acadrust::EntityType; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; @@ -50,7 +50,7 @@ impl CadCommand for XAttachCommand { format!("XATTACH Specify insertion point for \"{}\":", self.block_name) } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { // We return the INSERT entity; the command handler in commands.rs // calls `prepare_xref_block` on the scene before committing. CmdResult::CommitAndExit(EntityType::Insert(Insert::new( @@ -63,7 +63,7 @@ impl CadCommand for XAttachCommand { CmdResult::Cancel } - fn on_preview_wires(&mut self, _pt: Vec3) -> Vec { + fn on_preview_wires(&mut self, _pt: DVec3) -> Vec { vec![] } diff --git a/src/modules/layout/mview.rs b/src/modules/layout/mview.rs index 1f364d806..b88c3c878 100644 --- a/src/modules/layout/mview.rs +++ b/src/modules/layout/mview.rs @@ -11,7 +11,7 @@ use acadrust::EntityType; use crate::command::{CadCommand, CmdResult}; use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; // ── Ribbon definition ───────────────────────────────────────────────────── @@ -49,7 +49,7 @@ impl CadCommand for MviewCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Some(c1) = self.corner1 { let w = (pt.x - c1.x).abs() as f64; let h = (pt.y - c1.y).abs() as f64; @@ -77,7 +77,7 @@ impl CadCommand for MviewCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let c1 = self.corner1?; Some(WireModel { name: "mview_preview".to_string(), diff --git a/src/modules/layout/vplayer.rs b/src/modules/layout/vplayer.rs index 787934587..80c778240 100644 --- a/src/modules/layout/vplayer.rs +++ b/src/modules/layout/vplayer.rs @@ -11,7 +11,7 @@ // Layer names are case-insensitive. Multiple space-separated names are accepted. use acadrust::Handle; -use glam::Vec3; +use glam::DVec3; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -94,7 +94,7 @@ impl CadCommand for VplayerCommand { } } - fn on_point(&mut self, _pt: Vec3) -> CmdResult { + fn on_point(&mut self, _pt: DVec3) -> CmdResult { CmdResult::Cancel } @@ -102,7 +102,7 @@ impl CadCommand for VplayerCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, _pt: Vec3) -> Option { + fn on_mouse_move(&mut self, _pt: DVec3) -> Option { None } } diff --git a/src/modules/model/primitive_cmd.rs b/src/modules/model/primitive_cmd.rs index da6a263e3..745e5ec93 100644 --- a/src/modules/model/primitive_cmd.rs +++ b/src/modules/model/primitive_cmd.rs @@ -9,7 +9,7 @@ use acadrust::entities::Solid3D; use acadrust::{primitives, EntityType}; -use glam::Vec3; +use glam::{DVec3, Vec3}; use truck_modeling::Solid; use crate::command::{CadCommand, CmdResult}; @@ -209,7 +209,7 @@ impl CadCommand for PrimitiveCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if self.height_step { // A click in the ground plane has no Z; use its distance from the // footprint centre as the height magnitude. @@ -253,7 +253,7 @@ impl CadCommand for PrimitiveCommand { Some(self.commit(h)) } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); if self.height_step || self.pts.is_empty() { return None; } diff --git a/src/modules/view/plot_window.rs b/src/modules/view/plot_window.rs index 56d0d3c6c..5445ebc77 100644 --- a/src/modules/view/plot_window.rs +++ b/src/modules/view/plot_window.rs @@ -5,7 +5,7 @@ use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; -use glam::Vec3; +use glam::{DVec3, Vec3}; pub struct PlotWindowCommand { p1: Option, @@ -30,13 +30,13 @@ impl CadCommand for PlotWindowCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); match self.p1 { None => { self.p1 = Some(pt); CmdResult::NeedPoint } - Some(p1) => CmdResult::SetPlotWindow { p1, p2: pt }, + Some(p1) => CmdResult::SetPlotWindow { p1: p1.as_dvec3(), p2: pt.as_dvec3() }, } } @@ -44,7 +44,7 @@ impl CadCommand for PlotWindowCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let p1 = self.p1?; // Draw the selection rectangle. Some(WireModel { diff --git a/src/modules/view/zoom_window.rs b/src/modules/view/zoom_window.rs index 717fdb448..9e893d8f3 100644 --- a/src/modules/view/zoom_window.rs +++ b/src/modules/view/zoom_window.rs @@ -1,6 +1,6 @@ // ZOOM WINDOW command — pick two corners to define the zoom area. -use glam::Vec3; +use glam::{DVec3, Vec3}; use crate::command::{CadCommand, CmdResult}; use crate::scene::model::wire_model::WireModel; @@ -28,9 +28,9 @@ impl CadCommand for ZoomWindowCommand { } } - fn on_point(&mut self, pt: Vec3) -> CmdResult { + fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3(); if let Some(p1) = self.first { - CmdResult::ZoomToWindow { p1, p2: pt } + CmdResult::ZoomToWindow { p1: p1.as_dvec3(), p2: pt.as_dvec3() } } else { self.first = Some(pt); CmdResult::NeedPoint @@ -45,7 +45,7 @@ impl CadCommand for ZoomWindowCommand { CmdResult::Cancel } - fn on_mouse_move(&mut self, pt: Vec3) -> Option { + fn on_mouse_move(&mut self, pt: DVec3) -> Option { let pt = pt.as_vec3(); let p1 = self.first?; let min = p1.min(pt); let max = p1.max(pt); diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 75b3f716a..44b87c0c6 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -4175,7 +4175,7 @@ impl Scene { .add_entity(EntityType::BlockEnd(block_end)) .map_err(|e| e.to_string())?; - let local = EntityTransform::Translate(-base); + let local = EntityTransform::Translate((-base).as_dvec3()); for (old_handle, mut entity) in source_entities { view::dispatch::apply_transform(&mut entity, &local); entity = crate::modules::draw::modify::explode::normalize_entity_for_block(entity); @@ -4248,7 +4248,7 @@ impl Scene { .add_entity(EntityType::BlockEnd(block_end)) .map_err(|e| e.to_string())?; - let local = EntityTransform::Translate(-base); + let local = EntityTransform::Translate((-base).as_dvec3()); for mut entity in entities { view::dispatch::apply_transform(&mut entity, &local); entity = crate::modules::draw::modify::explode::normalize_entity_for_block(entity); diff --git a/src/scene/model/object.rs b/src/scene/model/object.rs index d1575f01d..7d254e70d 100644 --- a/src/scene/model/object.rs +++ b/src/scene/model/object.rs @@ -1,7 +1,7 @@ // Shared value types used by the dispatch and grip systems. use acadrust::types::{Color as AcadColor, LineWeight}; -use glam::{DVec3, Vec3}; +use glam::DVec3; /// The kind of value held by a property row. #[derive(Clone, Debug, PartialEq)] diff --git a/src/scene/pick/grip.rs b/src/scene/pick/grip.rs index 2f2bae2cf..acb1e10cc 100644 --- a/src/scene/pick/grip.rs +++ b/src/scene/pick/grip.rs @@ -1,7 +1,7 @@ //! OpenCADStudio-style grip editing. use acadrust::Handle; -use glam::{DVec3, Vec3}; +use glam::DVec3; use iced::{Point, Rectangle}; use crate::scene::model::object::{GripDef, GripShape};