From b73d9b8f2b545549d732ef24d36242a638c5053a Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 21 Apr 2023 10:14:05 +0100 Subject: [PATCH] Clamp camera pitch between -85 and 85 degrees --- src/camera.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/camera.rs b/src/camera.rs index 763ec69..538a2cc 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -223,8 +223,10 @@ impl CameraController { // Apply rotation let cam_ms = (self.move_speed * self.move_speed).to_radians() * dt; + let max_pitch = 85_f32.to_radians(); self.camera.yaw += cam_ms * self.rot_dirs_pressed.x as f32; self.camera.pitch += cam_ms * self.rot_dirs_pressed.y as f32; + self.camera.pitch = self.camera.pitch.clamp(-max_pitch, max_pitch); // Debug log // log::info!("Camera Front: {:?}", front);