From: Jean-Patrick Guerrero Date: Sun, 8 Mar 2020 17:21:55 +0000 (+0100) Subject: Improve arm physics (#9485) X-Git-Tag: 5.2.0~82 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c49575ef97c3c88864263d460ce4d90ecb0cba9e;p=oweals%2Fminetest.git Improve arm physics (#9485) --- diff --git a/src/client/camera.cpp b/src/client/camera.cpp index 464644044..7062e4531 100644 --- a/src/client/camera.cpp +++ b/src/client/camera.cpp @@ -39,6 +39,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define CAMERA_OFFSET_STEP 200 #define WIELDMESH_OFFSET_X 55.0f #define WIELDMESH_OFFSET_Y -35.0f +#define WIELDMESH_AMPLITUDE_X 7.0f +#define WIELDMESH_AMPLITUDE_Y 10.0f Camera::Camera(MapDrawControl &draw_control, Client *client): m_draw_control(draw_control), @@ -234,7 +236,8 @@ void Camera::addArmInertia(f32 player_yaw) m_last_cam_pos.X = player_yaw; m_wieldmesh_offset.X = rangelim(m_wieldmesh_offset.X, - WIELDMESH_OFFSET_X - 7.0f, WIELDMESH_OFFSET_X + 7.0f); + WIELDMESH_OFFSET_X - (WIELDMESH_AMPLITUDE_X * 0.5f), + WIELDMESH_OFFSET_X + (WIELDMESH_AMPLITUDE_X * 0.5f)); } if (m_cam_vel.Y > 1.0f) { @@ -249,7 +252,8 @@ void Camera::addArmInertia(f32 player_yaw) m_last_cam_pos.Y = m_camera_direction.Y; m_wieldmesh_offset.Y = rangelim(m_wieldmesh_offset.Y, - WIELDMESH_OFFSET_Y - 10.0f, WIELDMESH_OFFSET_Y + 5.0f); + WIELDMESH_OFFSET_Y - (WIELDMESH_AMPLITUDE_Y * 0.5f), + WIELDMESH_OFFSET_Y + (WIELDMESH_AMPLITUDE_Y * 0.5f)); } m_arm_dir = dir(m_wieldmesh_offset); @@ -259,10 +263,10 @@ void Camera::addArmInertia(f32 player_yaw) following a vector, with a smooth deceleration factor. */ - f32 dec_X = 0.12f * (m_cam_vel_old.X * (1.0f + + f32 dec_X = 0.35f * (std::min(15.0f, m_cam_vel_old.X) * (1.0f + (1.0f - m_arm_dir.X))) * (gap_X / 20.0f); - f32 dec_Y = 0.06f * (m_cam_vel_old.Y * (1.0f + + f32 dec_Y = 0.25f * (std::min(15.0f, m_cam_vel_old.Y) * (1.0f + (1.0f - m_arm_dir.Y))) * (gap_Y / 15.0f); if (gap_X < 0.1f)