summaryrefslogtreecommitdiff
path: root/engine/src/camera
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-18 23:35:41 +0200
committerHampusM <hampus@hampusmat.com>2024-05-18 23:35:41 +0200
commit3884f9bdd775afd3a40503286eb5d06ef72eeb1a (patch)
treeed8b5a39fbf485a71be31ba6fd30bef58dea34f6 /engine/src/camera
parentbcf1e9c00e3959c3db047d2d8b3ac7d6c4853796 (diff)
fix(engine): prevent camera moving when window regains focus
Diffstat (limited to 'engine/src/camera')
-rw-r--r--engine/src/camera/fly.rs8
1 files changed, 3 insertions, 5 deletions
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<Keys>,
cursor: Single<Cursor>,
+ cursor_flags: Single<CursorFlags>,
delta_time: Single<DeltaTime>,
mut cursor_state: Local<CursorState>,
options: Local<Options>,
@@ -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<f64>,
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,
}
}
}