From 3884f9bdd775afd3a40503286eb5d06ef72eeb1a Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 18 May 2024 23:35:41 +0200 Subject: fix(engine): prevent camera moving when window regains focus --- engine/src/camera/fly.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engine/src/camera/fly.rs') diff --git a/engine/src/camera/fly.rs b/engine/src/camera/fly.rs index 3f5a0c2..ed41253 100644 --- a/engine/src/camera/fly.rs +++ b/engine/src/camera/fly.rs @@ -7,7 +7,7 @@ use glfw::window::{Key, KeyState}; use crate::camera::Camera; use crate::delta_time::DeltaTime; use crate::event::Update as UpdateEvent; -use crate::input::{Cursor, Keys}; +use crate::input::{Cursor, CursorFlags, Keys}; use crate::vector::{Vec2, Vec3}; /// Fly camera extension. @@ -41,6 +41,7 @@ fn update( camera_query: Query<(Camera,)>, keys: Single, cursor: Single, + cursor_flags: Single, delta_time: Single, mut cursor_state: Local, options: Local, @@ -53,11 +54,10 @@ fn update( return; }; - if cursor.has_moved && cursor_state.first_mouse { + if cursor.has_moved && cursor_flags.is_first_move.flag { println!("First cursor move"); cursor_state.last_pos = cursor.position; - cursor_state.first_mouse = false; } let delta_time = delta_time.duration; @@ -119,7 +119,6 @@ struct CursorState last_pos: Vec2, current_pitch: f64, current_yaw: f64, - first_mouse: bool, } impl Default for CursorState @@ -130,7 +129,6 @@ impl Default for CursorState last_pos: Vec2::default(), current_pitch: 0.0, current_yaw: 0.0, - first_mouse: true, } } } -- cgit v1.2.3-18-g5258