From 7a1988e851de8cacc5c119adea7a106d3a3f6cd6 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Mon, 22 Jun 2026 08:52:20 +0300 Subject: [PATCH] fix(view): apply saved view twist as camera roll on load Drawings authored under a rotated UCS save a view twist so they open square. camera_from_vport ignored VPort.view_twist (roll hardcoded 0), so such files rendered in raw world orientation and looked tilted. Feed -view_twist in as the camera roll: the twist rotates world-X onto screen-right, so the direction that becomes horizontal is its negative. The roll rides the camera quaternion, surviving render and orbit. Co-Authored-By: Claude Opus 4.8 --- src/scene/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 329c25382..f603c0b26 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -6131,7 +6131,13 @@ impl Scene { } else { vd.x.atan2(-vd.y) }; - let rotation = view::camera::yaw_pitch_to_quat(yaw, pitch, 0.0); + // The saved view can carry a twist (rotation about the view axis), set + // when the view was aligned to a rotated UCS. The twist is the angle + // that rotates world-X onto screen-right, so the world direction that + // ends up horizontal is its negative; feed that in as the camera roll + // so the drawing opens square, the way it was saved, instead of in raw + // world orientation (which looks tilted). + let rotation = view::camera::yaw_pitch_to_quat(yaw, pitch, -vp.view_twist as f32); let view_right = rotation * glam::Vec3::X; let view_up = rotation * glam::Vec3::Y; // view_target is WCS; wire-space subtracts world_offset.