diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index a7b2766a57..9bc7742d2d 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -78,6 +78,7 @@ pub struct SceneData<'a> { pub mouse_smoothing: bool, pub sprite_render_distance: f32, pub figure_lod_render_distance: f32, + pub is_aiming: bool, } impl Scene { @@ -236,6 +237,7 @@ impl Scene { player_scale * 1.65 } }, + CameraMode::ThirdPerson if scene_data.is_aiming => 2.1, CameraMode::ThirdPerson => 1.65, }; diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index fd39a92d90..9ccd8c34ba 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -166,6 +166,18 @@ impl PlayState for SessionState { _ => cam_pos, // Should never happen, but a safe fallback }; + let (is_aiming, aim_dir_offset) = { + let client = self.client.borrow(); + let is_aiming = client + .state() + .read_storage::() + .get(client.entity()) + .map(|cs| cs.is_aimed()) + .unwrap_or(false); + + (is_aiming, if is_aiming { Vec3::unit_z() * 0.025 } else { Vec3::zero() }) + }; + let cam_dir: Vec3 = Vec3::from(view_mat.inverted() * -Vec4::unit_z()); // Check to see whether we're aiming at anything @@ -435,7 +447,7 @@ impl PlayState for SessionState { if !free_look { ori = self.scene.camera().get_orientation(); - self.inputs.look_dir = Dir::from_unnormalized(cam_dir).unwrap(); + self.inputs.look_dir = Dir::from_unnormalized(cam_dir + aim_dir_offset).unwrap(); } // Calculate the movement input vector of the player from the current key // presses and the camera direction. @@ -512,16 +524,7 @@ impl PlayState for SessionState { &self.scene.camera(), clock.get_last_delta(), HudInfo { - is_aiming: { - let client = self.client.borrow(); - let aimed = client - .state() - .read_storage::() - .get(client.entity()) - .map(|cs| cs.is_aimed()) - .unwrap_or(false); - aimed - }, + is_aiming, is_first_person: matches!( self.scene.camera().get_mode(), camera::CameraMode::FirstPerson @@ -753,6 +756,7 @@ impl PlayState for SessionState { .graphics .figure_lod_render_distance as f32, + is_aiming, }; // Runs if either in a multiplayer server or the singleplayer server is unpaused