forked from 1b-agent/opencadstudio-upstream
fix(grips): compute grip positions in f64 so they sit on the wire
Grip markers drew visibly offset from the entity on large-coordinate (UTM-scale) drawings: every Grippable impl cast the f64 entity coordinates to f32 BEFORE the world-offset subtraction, and at 1e7 magnitude an f32 holds ~0.9 drawing units of rounding error. The wires subtract the offset in f64 first (precision-preserving), so the grips landed up to ~1 unit away from the geometry they belong to. GripDef.world is now DVec3: producers fill it straight from the f64 entity data, refresh_selected_grips subtracts the world offset in f64, and only the small offset-local result is cast to f32 for screen-space projection (grips_to_screen / find_hit_grip) and drag state. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed29933d87
commit
25715d1b03
33 files changed
+898
-817
No files matched your search
+6
-14
@@ -140,15 +140,11 @@ fn to_truck(ell: &Ellipse) -> TruckEntity {
|
||||
}
|
||||
|
||||
fn grips(ell: &Ellipse) -> Vec<GripDef> {
|
||||
let ctr = Vec3::new(
|
||||
ell.center.x as f32,
|
||||
ell.center.y as f32,
|
||||
ell.center.z as f32,
|
||||
);
|
||||
let maj = Vec3::new(
|
||||
(ell.center.x + ell.major_axis.x) as f32,
|
||||
(ell.center.y + ell.major_axis.y) as f32,
|
||||
(ell.center.z + ell.major_axis.z) as f32,
|
||||
let ctr = glam::DVec3::new(ell.center.x, ell.center.y, ell.center.z);
|
||||
let maj = glam::DVec3::new(
|
||||
ell.center.x + ell.major_axis.x,
|
||||
ell.center.y + ell.major_axis.y,
|
||||
ell.center.z + ell.major_axis.z,
|
||||
);
|
||||
let major_xy =
|
||||
((ell.major_axis.x * ell.major_axis.x + ell.major_axis.y * ell.major_axis.y) as f64).sqrt();
|
||||
@@ -158,11 +154,7 @@ fn grips(ell: &Ellipse) -> Vec<GripDef> {
|
||||
} else {
|
||||
(0.0, ell.major_axis_length() * ell.minor_axis_ratio)
|
||||
};
|
||||
let min = Vec3::new(
|
||||
(ell.center.x + px) as f32,
|
||||
(ell.center.y + py) as f32,
|
||||
ell.center.z as f32,
|
||||
);
|
||||
let min = glam::DVec3::new(ell.center.x + px, ell.center.y + py, ell.center.z);
|
||||
vec![
|
||||
center_grip(0, ctr),
|
||||
square_grip(1, maj),
|
||||
|
||||
Reference in new issue
Block a user