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
|
|
@ -18,7 +18,7 @@ use crate::scene::wire_model::SnapHint;
|
|||
// ── Marker geometry ───────────────────────────────────────────────────────────
|
||||
|
||||
/// Small diamond marker at the shape insertion point.
|
||||
fn shape_marker(ox: f32, oy: f32, oz: f32, size: f32) -> Vec<[f32; 3]> {
|
||||
fn shape_marker(ox: f64, oy: f64, oz: f64, size: f64) -> Vec<[f64; 3]> {
|
||||
let s = size * 0.5;
|
||||
vec![
|
||||
[ox, oy + s, oz], // top
|
||||
|
|
@ -26,7 +26,7 @@ fn shape_marker(ox: f32, oy: f32, oz: f32, size: f32) -> Vec<[f32; 3]> {
|
|||
[ox, oy - s, oz], // bottom
|
||||
[ox - s, oy, oz], // left
|
||||
[ox, oy + s, oz], // close
|
||||
[f32::NAN; 3],
|
||||
[f64::NAN; 3],
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -34,12 +34,12 @@ fn shape_marker(ox: f32, oy: f32, oz: f32, size: f32) -> Vec<[f32; 3]> {
|
|||
|
||||
impl TruckConvertible for Shape {
|
||||
fn to_truck(&self, _document: &acadrust::CadDocument) -> Option<TruckEntity> {
|
||||
let ox = self.insertion_point.x as f32;
|
||||
let oy = self.insertion_point.y as f32;
|
||||
let oz = self.insertion_point.z as f32;
|
||||
let size = (self.size as f32).abs().max(0.5);
|
||||
let ox = self.insertion_point.x;
|
||||
let oy = self.insertion_point.y;
|
||||
let oz = self.insertion_point.z;
|
||||
let size = self.size.abs().max(0.5);
|
||||
|
||||
let snap_pt = Vec3::new(ox, oy, oz);
|
||||
let snap_pt = Vec3::new(ox as f32, oy as f32, oz as f32);
|
||||
let pts = shape_marker(ox, oy, oz, size);
|
||||
|
||||
Some(TruckEntity {
|
||||
|
|
|
|||
Loading…
Reference in a new issue