From 4f4f3bced1cc5efa28f987567b78a854386cc51f 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 781bb5b..e1298c6 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);