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
|
|
@ -14,7 +14,11 @@ use crate::scene::acad_to_truck::{TruckEntity, TruckObject};
|
|||
use crate::scene::object::{GripApply, GripDef, PropSection};
|
||||
use crate::scene::wire_model::SnapHint;
|
||||
|
||||
fn v3(v: &acadrust::types::Vector3) -> [f32; 3] {
|
||||
fn v3(v: &acadrust::types::Vector3) -> [f64; 3] {
|
||||
[v.x, v.y, v.z]
|
||||
}
|
||||
|
||||
fn v3f32(v: &acadrust::types::Vector3) -> [f32; 3] {
|
||||
[v.x as f32, v.y as f32, v.z as f32]
|
||||
}
|
||||
|
||||
|
|
@ -31,22 +35,22 @@ impl TruckConvertible for Solid {
|
|||
let pts = vec![
|
||||
p0,
|
||||
p1,
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
p1,
|
||||
p3,
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
p3,
|
||||
p2,
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
p2,
|
||||
p0,
|
||||
];
|
||||
|
||||
let snap = vec![
|
||||
(Vec3::from(p0), SnapHint::Node),
|
||||
(Vec3::from(p1), SnapHint::Node),
|
||||
(Vec3::from(p2), SnapHint::Node),
|
||||
(Vec3::from(p3), SnapHint::Node),
|
||||
(Vec3::from(v3f32(&self.first_corner)), SnapHint::Node),
|
||||
(Vec3::from(v3f32(&self.second_corner)), SnapHint::Node),
|
||||
(Vec3::from(v3f32(&self.third_corner)), SnapHint::Node),
|
||||
(Vec3::from(v3f32(&self.fourth_corner)), SnapHint::Node),
|
||||
];
|
||||
|
||||
Some(TruckEntity {
|
||||
|
|
@ -62,10 +66,10 @@ impl TruckConvertible for Solid {
|
|||
impl Grippable for Solid {
|
||||
fn grips(&self) -> Vec<GripDef> {
|
||||
vec![
|
||||
square_grip(0, Vec3::from(v3(&self.first_corner))),
|
||||
square_grip(1, Vec3::from(v3(&self.second_corner))),
|
||||
square_grip(2, Vec3::from(v3(&self.third_corner))),
|
||||
square_grip(3, Vec3::from(v3(&self.fourth_corner))),
|
||||
square_grip(0, Vec3::from(v3f32(&self.first_corner))),
|
||||
square_grip(1, Vec3::from(v3f32(&self.second_corner))),
|
||||
square_grip(2, Vec3::from(v3f32(&self.third_corner))),
|
||||
square_grip(3, Vec3::from(v3f32(&self.fourth_corner))),
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue