Clamp camera pitch between -85 and 85 degrees

This commit is contained in:
Jarrod Doyle 2023-04-21 10:14:05 +01:00
parent 9554f3ba7f
commit 4f4f3bced1
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 2 additions and 0 deletions

View File

@ -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);