Skip to content

Commit

Permalink
Capture mouse when clicking and uncaptured, FOV
Browse files Browse the repository at this point in the history
  • Loading branch information
drey7925 committed Dec 31, 2023
1 parent a43a6f6 commit cad7389
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions perovskite_client/src/game_state/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ impl InputState {
} else if let &WindowEvent::MouseInput { state, button, .. } = event {
match state {
ElementState::Pressed => {
self.active_keybinds.insert(Keybind::MouseButton(button));
self.new_presses.insert(Keybind::MouseButton(button));
if self.mouse_captured {
self.active_keybinds.insert(Keybind::MouseButton(button));
self.new_presses.insert(Keybind::MouseButton(button));
} else {
self.mouse_captured = true;
}
}
ElementState::Released => {
self.active_keybinds.remove(&Keybind::MouseButton(button));
Expand Down
8 changes: 7 additions & 1 deletion perovskite_client/src/game_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,13 @@ impl ClientState {
* cgmath::Matrix4::from_angle_y(Deg(180.) - Deg(az));
// TODO figure out why this is needed
let coordinate_correction = cgmath::Matrix4::from_nonuniform_scale(-1., 1., 1.);
let projection = cgmath::perspective(Deg(45.0), aspect_ratio, 0.01, 1000.);

let projection = cgmath::perspective(
Deg(self.settings.load().render.fov_degrees),
aspect_ratio,
0.01,
1000.,
);
let view_proj_matrix = (projection * coordinate_correction * rotation)
.cast()
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions perovskite_client/src/game_state/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub(crate) struct RenderSettings {
pub(crate) physics_debug: bool,
pub(crate) preferred_gpu: String,
pub(crate) scale_inventories_with_high_dpi: bool,
pub(crate) fov_degrees: f64,
}

impl Default for RenderSettings {
Expand All @@ -28,6 +29,7 @@ impl Default for RenderSettings {
physics_debug: false,
preferred_gpu: String::from(""),
scale_inventories_with_high_dpi: false,
fov_degrees: 75.0,
}
}
}
Expand Down

0 comments on commit cad7389

Please sign in to comment.