From 202641052b07f49223b3145e5d2c66205767ecb9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 18 Nov 2024 20:31:25 +0100 Subject: [PATCH] Simplify --- crates/fj-viewer/src/input/event.rs | 11 ----------- crates/fj-viewer/src/viewer.rs | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/crates/fj-viewer/src/input/event.rs b/crates/fj-viewer/src/input/event.rs index eda8343b1..23b44c560 100644 --- a/crates/fj-viewer/src/input/event.rs +++ b/crates/fj-viewer/src/input/event.rs @@ -1,16 +1,5 @@ -use crate::screen::NormalizedScreenPosition; - /// An input event pub enum InputEvent { - /// Move the model up, down, left or right - Translation { - /// The normalized position of the cursor before input - previous: NormalizedScreenPosition, - - /// The normalized position of the cursor after input - current: NormalizedScreenPosition, - }, - /// Rotate the model around the focus point Rotation { /// The angle around the screen x axis to rotate (in radians) diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index 5f4ea7f91..4fb98eb72 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -73,10 +73,6 @@ impl Viewer { }; match event { - InputEvent::Translation { previous, current } => { - self.camera - .apply_translation(previous, current, focus_point); - } InputEvent::Rotation { angle_x, angle_y } => { self.camera.apply_rotation(angle_x, angle_y, focus_point); } @@ -110,10 +106,16 @@ impl Viewer { Some(InputEvent::Rotation { angle_x, angle_y }) } - MouseButton::Right => Some(InputEvent::Translation { - previous: cursor_old, - current: cursor_new, - }), + MouseButton::Right => { + if let Some(focus_point) = self.focus_point { + self.camera.apply_translation( + cursor_old, + cursor_new, + focus_point, + ); + } + None + } }, _ => None, };