Phase 3: Active viewport MSPACE/PSPACE workflow

- Add active_viewport: Option<Handle> field to Scene
- Add EnterViewport(Handle) and ExitViewport messages
- Double-click on a user viewport (id > 1) enters MSPACE;
  double-click on empty area while in MSPACE exits to PSPACE
- MSPACE middle-drag pans the viewport's model-space view (view_target)
- MSPACE scroll zooms the viewport's view_height / custom_scale
- Drawing commands inside MSPACE receive model-space coordinates
  via paper_to_model() coordinate transform
- Active viewport rendered with yellow dashed border (vs. cyan solid)
- Camera screen_delta_to_world helper for MSPACE pan conversion
- LayoutSwitch clears active_viewport

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Sonnet 4.6 committed 2026-03-31 07:24:16 +03:00
1 parent 474b38f4fb
commit 523ba74c10
4 files changed
+215 -13

No files matched your search

+10
View File
@@ -201,6 +201,16 @@ impl Camera {
self.target += cam_up * delta_y * speed;
}
/// Returns the world-space translation that `pan(delta_x, delta_y)` would
/// apply to the camera target — without actually moving the camera.
/// Used by MSPACE to pan the viewport's model-space view independently.
pub fn screen_delta_to_world(&self, delta_x: f32, delta_y: f32, _bounds: Rectangle) -> Vec3 {
let speed = self.distance * 0.001;
let cam_right = self.rotation * Vec3::X;
let cam_up = self.rotation * Vec3::Y;
-(cam_right * delta_x * speed) + (cam_up * delta_y * speed)
}
pub fn fit_to_bounds(&mut self, min: Vec3, max: Vec3) {
self.target = (min + max) * 0.5;
let size = (max - min).length();