fix(render): preserve f64 precision until world_offset subtraction
Entity converters were casting WCS coordinates to f32 before the renderer subtracted world_offset, which destroyed sub-unit precision on drawings sitting at large coordinates (typical UTM-style CAD files). The multileader case made it visible — glyphs warped under rotation — but every entity that emits TruckObject::Lines/SegmentedLines/key_vertices/fill_tris was affected. Type changes (in src/scene/acad_to_truck.rs): - TruckObject::Lines / SegmentedLines: Vec<[f32; 3]> → Vec<[f64; 3]> - TruckEntity::key_vertices / fill_tris: f32 → f64 All ~17 producer files updated to keep WCS coordinates in f64 right up to the TruckEntity boundary. The consumer in scene/tessellate.rs now performs `(x - ox) as f32` (f64 subtract, then cast) for points, key_vertices, and fill_tris — preserving precision near the camera origin even when the drawing sits at million-unit coordinates. catmull_rom_pts (multileader spline) is now f64; the scene path widens its offset-relative f32 ctrl points to f64 around the call and narrows back at the output. Notes: - Table layout still uses glam::Vec3 (f32) internally; widened to f64 only at the TruckEntity boundary for type compatibility. Separate cleanup to switch its internal math to f64 is tracked. - snap_pts and tangent_geoms remain f32 — they are UI feedback (snap candidates, tangent hints) and the precision is sufficient there.
This commit is contained in:
parent
8bfa5088c4
commit
288ccff95a
20 changed files with 371 additions and 360 deletions
|
|
@ -21,38 +21,27 @@ fn to_truck(line: &Line) -> TruckEntity {
|
|||
crate::scene::transform::ocs_point_to_wcs((line.end.x, line.end.y, line.end.z), normal);
|
||||
let p0 = Point3::new(sx, sy, sz);
|
||||
let p1 = Point3::new(ex, ey, ez);
|
||||
let kv = vec![
|
||||
[p0.x as f32, p0.y as f32, p0.z as f32],
|
||||
[p1.x as f32, p1.y as f32, p1.z as f32],
|
||||
];
|
||||
let kv: Vec<[f64; 3]> = vec![[p0.x, p0.y, p0.z], [p1.x, p1.y, p1.z]];
|
||||
let tangent = TangentGeom::Line {
|
||||
p1: kv[0],
|
||||
p2: kv[1],
|
||||
p1: [kv[0][0] as f32, kv[0][1] as f32, kv[0][2] as f32],
|
||||
p2: [kv[1][0] as f32, kv[1][1] as f32, kv[1][2] as f32],
|
||||
};
|
||||
|
||||
if line.thickness.abs() > 1e-10 {
|
||||
let t = line.thickness;
|
||||
let (nx, ny, nz) = normal;
|
||||
let p0t = [
|
||||
(sx + t * nx) as f32,
|
||||
(sy + t * ny) as f32,
|
||||
(sz + t * nz) as f32,
|
||||
];
|
||||
let p1t = [
|
||||
(ex + t * nx) as f32,
|
||||
(ey + t * ny) as f32,
|
||||
(ez + t * nz) as f32,
|
||||
];
|
||||
let pts = vec![
|
||||
let p0t = [sx + t * nx, sy + t * ny, sz + t * nz];
|
||||
let p1t = [ex + t * nx, ey + t * ny, ez + t * nz];
|
||||
let pts: Vec<[f64; 3]> = vec![
|
||||
kv[0],
|
||||
kv[1],
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
p0t,
|
||||
p1t,
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
kv[0],
|
||||
p0t,
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
kv[1],
|
||||
p1t,
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue