fix(camera): keep ortho depth precision constant across zoom

The orthographic near/far span was ±1000x the camera distance, so
zooming out ballooned the depth range and collapsed z-buffer precision:
coincident solids, meshes and wires then flipped draw order (meshes drew
in front of solids only when zoomed out, correct order when zoomed in).

Size the depth half-range from the drawing's extent instead — the bbox
diagonal on fit_to_bounds, the view height on a restored saved view —
and hold it constant as the camera zooms, so precision no longer depends
on distance. Falls back to the old distance-scaled range when unset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-02 01:23:27 +03:00
1 parent 7185f6e4fa
commit 572e9aca01
2 files changed
+29 -1

No files matched your search

+4
View File
@@ -230,6 +230,10 @@ impl Scene {
projection: view::camera::Projection::Orthographic,
yaw,
pitch,
// Sized from the saved view height rather than a zoom-scaled range,
// so a restored view keeps stable depth precision. `view_height` is
// the visible extent; a few multiples cover the drawing's depth.
depth_half_range: (view_height as f32 * 4.0).max(1.0),
})
}