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:
Hakan Seven 2026-06-11 00:04:37 +03:00
commit 25715d1b03
33 changed files with 898 additions and 817 deletions

View file

@ -1,7 +1,5 @@
use std::cell::Cell;
use glam::Vec3;
use crate::scene::object::{GripDef, GripShape, PropValue, Property};
/// Linear / angular unit format pulled from the document header so the
@ -121,7 +119,7 @@ pub fn format_angle(value_rad: f64) -> String {
}
}
pub fn square_grip(id: usize, world: Vec3) -> GripDef {
pub fn square_grip(id: usize, world: glam::DVec3) -> GripDef {
GripDef {
id,
world,
@ -133,7 +131,7 @@ pub fn square_grip(id: usize, world: Vec3) -> GripDef {
/// Centre / translate grip — same square marker as a vertex grip but
/// flagged as a "whole-object move" handle for the grip-edit code.
pub fn center_grip(id: usize, world: Vec3) -> GripDef {
pub fn center_grip(id: usize, world: glam::DVec3) -> GripDef {
GripDef {
id,
world,
@ -146,7 +144,7 @@ pub fn center_grip(id: usize, world: Vec3) -> GripDef {
/// Mid-segment stretch grip oriented along `dir` (the segment's in-plane
/// world-XY direction). Drawn as a small rectangle elongated along the
/// segment so the affordance reads as "stretch perpendicular".
pub fn rectangle_grip(id: usize, world: Vec3, dir: [f32; 2]) -> GripDef {
pub fn rectangle_grip(id: usize, world: glam::DVec3, dir: [f32; 2]) -> GripDef {
GripDef {
id,
world,
@ -157,7 +155,7 @@ pub fn rectangle_grip(id: usize, world: Vec3, dir: [f32; 2]) -> GripDef {
}
#[allow(dead_code)]
pub fn triangle_grip(id: usize, world: Vec3) -> GripDef {
pub fn triangle_grip(id: usize, world: glam::DVec3) -> GripDef {
GripDef {
id,
world,