fix(ucs): grid axis lines and grid snap follow the active UCS

Two leftovers from the UCS grid work:
- The coloured X/Y/Z axis lines (draw_axes) were drawn at the world
  origin along world axes; they now run through the UCS origin along the
  UCS axes, matching the grid lines.
- Grid snap rounded the cursor on the world XYZ lattice; it now rounds in
  the UCS grid frame (to-UCS, round, back-to-world) so it lands on the
  grid the user sees. The UCS origin (wire space) + rotation reach the
  snapper via DocumentTab::ucs_grid_basis; identity outside model space.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-22 11:27:34 +03:00
1 parent 2509396ba0
commit 481adba66b
4 files changed
+72 -36

No files matched your search

+17
View File
@@ -195,6 +195,23 @@ impl DocumentTab {
self.scene.viewcube_ucs = self.ucs_xform().rotation_mat();
}
/// Grid origin (render/wire space) and UCS→world rotation for grid snap and
/// the grid overlay. Identity / origin-at-zero outside model space.
pub(super) fn ucs_grid_basis(&self) -> (glam::Vec3, glam::Mat4) {
if self.scene.current_layout != "Model" {
return (glam::Vec3::ZERO, glam::Mat4::IDENTITY);
}
let xf = self.ucs_xform();
let (o, ..) = xf.axes();
let wo = self.scene.world_offset;
let origin = glam::Vec3::new(
o.x - wo[0] as f32,
o.y - wo[1] as f32,
o.z - wo[2] as f32,
);
(origin, xf.rotation_mat())
}
pub(super) fn new_drawing(n: usize) -> Self {
let mut scene = Scene::new();
linetypes::populate_document(&mut scene.document);