From 28d0a400288862e344cd16baae0dfd04f358a806 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 3 Apr 2022 21:42:23 +0000 Subject: [PATCH] Only enable mouse movement when pressed in scene_viewer (#4405) # Objective - Only move the camera when explicitly wanted, otherwise the camera goes crazy if the cursor isn't already in the middle of the window when it opens. ## Solution - Check if the Left mouse button is pressed before updating the mouse delta - Input is configurable --- examples/tools/scene_viewer.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/tools/scene_viewer.rs b/examples/tools/scene_viewer.rs index a4c69a06bccf4..2ae16a25025ee 100644 --- a/examples/tools/scene_viewer.rs +++ b/examples/tools/scene_viewer.rs @@ -18,6 +18,8 @@ fn main() { println!( " Controls: + MOUSE - Move camera orientation + LClick - Enable mouse movement WSAD - forward/back/strafe left/right LShift - 'run' E - up @@ -356,6 +358,7 @@ struct CameraController { pub key_up: KeyCode, pub key_down: KeyCode, pub key_run: KeyCode, + pub key_enable_mouse: MouseButton, pub walk_speed: f32, pub run_speed: f32, pub friction: f32, @@ -377,6 +380,7 @@ impl Default for CameraController { key_up: KeyCode::E, key_down: KeyCode::Q, key_run: KeyCode::LShift, + key_enable_mouse: MouseButton::Left, walk_speed: 5.0, run_speed: 15.0, friction: 0.5, @@ -390,17 +394,12 @@ impl Default for CameraController { fn camera_controller( time: Res