fix(viewcube): land face clicks upright, never upside-down

A drawing opened with a twisted view made a TOP-face click keep the
twist, so north ended up at the bottom. Add Camera::snap_to_face, which
snaps to a canonical orientation — north (UCS +Y) up for top/bottom,
world (UCS +Z) up for the side elevations — ignoring the current
up-sense. Face clicks use it; edges/corners still preserve their up so
they spin smoothly around the clicked feature.

The Home button routes through the same path, giving a reliable reset
for a twisted view.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-26 00:11:40 +03:00
1 parent f00c48bebb
commit 012ec3febc
2 files changed
+41 -7

No files matched your search

+18 -4
View File
@@ -4512,13 +4512,27 @@ impl OpenCADStudio {
}
let eye_dir = r_ucs.transform_vector3(region.snap_direction());
// Faces snap to a canonical upright orientation (never upside
// down); edges/corners keep the current up-sense so they spin
// smoothly around the clicked feature.
let is_face = matches!(region, scene::CubeRegion::Face(_));
if self.tabs[i].scene.active_viewport.is_some() {
self.tabs[i]
.scene
.snap_active_viewport_to_direction(eye_dir, r_ucs);
if is_face {
self.tabs[i]
.scene
.mutate_active_viewport_camera(|c| c.snap_to_face(eye_dir, r_ucs));
} else {
self.tabs[i]
.scene
.snap_active_viewport_to_direction(eye_dir, r_ucs);
}
} else {
let mut cam = self.tabs[i].scene.camera.borrow_mut();
cam.snap_to_direction(eye_dir, r_ucs);
if is_face {
cam.snap_to_face(eye_dir, r_ucs);
} else {
cam.snap_to_direction(eye_dir, r_ucs);
}
}
self.tabs[i].scene.camera_generation += 1;
self.command_line