forked from 1b-agent/opencadstudio-upstream
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
3da71698b1
commit
4f7a98a2ad
84 files changed
+358
-336
No files matched your search
@@ -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<WireModel> {
|
||||
fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
@@ -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<WireModel> {
|
||||
fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> { let pt = pt.as_vec3();
|
||||
match (&self.step, &self.preview) {
|
||||
(Step::Point { .. }, Some((wires, base))) => {
|
||||
let delta = pt - *base;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<WireModel> {
|
||||
fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user