diff --git a/src/input.rs b/src/input.rs index 039f925..99ed63e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -135,10 +135,14 @@ impl EditorCamInputEvent { let screen_to_view_space = |camera: &Camera, proj: &Projection, controller: &EditorCam, - viewport_position: Vec2| + target_position: Vec2| -> Option { + let mut viewport_position = if let Some(rect) = camera.logical_viewport_rect() { + target_position.as_dvec2() - rect.min.as_dvec2() + } else { + target_position.as_dvec2() + }; let target_size = camera.logical_viewport_size()?.as_dvec2(); - let mut viewport_position = viewport_position.as_dvec2(); // Flip the Y co-ordinate origin from the top to the bottom. viewport_position.y = target_size.y - viewport_position.y; let ndc = viewport_position * 2. / target_size - DVec2::ONE;