aboutsummaryrefslogtreecommitdiff
path: root/src/client/camera.cpp
diff options
context:
space:
mode:
authorJean-Patrick Guerrero <kilbith@users.noreply.github.com>2020-03-08 18:21:55 +0100
committerGitHub <noreply@github.com>2020-03-08 18:21:55 +0100
commitc49575ef97c3c88864263d460ce4d90ecb0cba9e (patch)
tree1728ed73451675e12e5b8ed0c8b1168df3a6ad4c /src/client/camera.cpp
parentb9a0626d8893324aa6be41607efbc131d23eee2d (diff)
downloadminetest-c49575ef97c3c88864263d460ce4d90ecb0cba9e.tar.gz
minetest-c49575ef97c3c88864263d460ce4d90ecb0cba9e.tar.bz2
minetest-c49575ef97c3c88864263d460ce4d90ecb0cba9e.zip
Improve arm physics (#9485)
Diffstat (limited to 'src/client/camera.cpp')
-rw-r--r--src/client/camera.cpp12
1 files changed, 8 insertions, 4 deletions
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)