From c91d6a851e0e83cfd8a1df9d897f3445dabe5ecc Mon Sep 17 00:00:00 2001 From: Vijfhoek Date: Wed, 2 Jun 2021 16:50:58 +0200 Subject: [PATCH 1/2] Release the cursor on unfocus --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1a545d5..2228bd1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod aabb; mod camera; mod chunk; mod geometry; +mod npc; mod quad; mod render_context; mod state; @@ -79,13 +80,18 @@ fn main() { button, .. } => { - if *button == MouseButton::Left && *mouse_state == ElementState::Pressed { + if !state.mouse_grabbed && *button == MouseButton::Left && *mouse_state == ElementState::Pressed { let _ = window.set_cursor_grab(true); window.set_cursor_visible(false); state.mouse_grabbed = true; + } else { + state.window_event(event); } - - state.window_event(event); + } + WindowEvent::Focused(false) => { + let _ = window.set_cursor_grab(false); + window.set_cursor_visible(true); + state.mouse_grabbed = false; } event => { state.window_event(event); } }, From d2ff642b3bd12903833b8ad76342ad0f6bf67ed4 Mon Sep 17 00:00:00 2001 From: Vijfhoek Date: Wed, 2 Jun 2021 16:58:55 +0200 Subject: [PATCH 2/2] ? --- src/chunk.rs | 1 + src/main.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chunk.rs b/src/chunk.rs index e5d0f53..73a9b2d 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -4,6 +4,7 @@ use crate::{geometry::Geometry, quad::Quad, vertex::BlockVertex}; use ahash::{AHashMap, AHashSet}; use cgmath::Vector3; use noise::utils::{NoiseMapBuilder, PlaneMapBuilder}; +use rayon::iter::{IntoParallelIterator, ParallelIterator}; #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/src/main.rs b/src/main.rs index 2228bd1..ec68421 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ mod aabb; mod camera; mod chunk; mod geometry; -mod npc; mod quad; mod render_context; mod state;