aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2020-07-05 23:45:21 +0100
committerGitHub <noreply@github.com>2020-07-05 23:45:21 +0100
commitdc6318b84aa8c079330b2adc711113f7d4b55961 (patch)
tree1048be737e01552039bc3d0f429cd0e9ad7a562a /src
parentda71313e1df3326c2b9ddb410b963ec25682319e (diff)
downloadminetest-dc6318b84aa8c079330b2adc711113f7d4b55961.tar.gz
minetest-dc6318b84aa8c079330b2adc711113f7d4b55961.tar.bz2
minetest-dc6318b84aa8c079330b2adc711113f7d4b55961.zip
Apply camera smoothing to 'air stepheight' (#10025)
Recent changes to collision code have changed the behaviour of the 'touching_ground' bool in movement code. This had the effect of disabling camera smoothing when 'air stepheight' occurred when jumping onto a node while pressing forwards against the node, causing an unpleasant sharp camera movement. Rewrite the conditions for camera smoothing such that it is applied when jumping.
Diffstat (limited to 'src')
-rw-r--r--src/client/camera.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp
index 9b311171a..abc55e4b7 100644
--- a/src/client/camera.cpp
+++ b/src/client/camera.cpp
@@ -342,9 +342,13 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
if (player->getParent())
player_position = player->getParent()->getPosition();
- if(player->touching_ground &&
- player_position.Y > old_player_position.Y)
- {
+ // Smooth the camera movement when the player instantly moves upward due to stepheight.
+ // To smooth the 'not touching_ground' stepheight, smoothing is necessary when jumping
+ // or swimming (for when moving from liquid to land).
+ // Disable smoothing if climbing or flying, to avoid upwards offset of player model
+ // when seen in 3rd person view.
+ bool flying = g_settings->getBool("free_move") && m_client->checkLocalPrivilege("fly");
+ if (player_position.Y > old_player_position.Y && !player->is_climbing && !flying) {
f32 oldy = old_player_position.Y;
f32 newy = player_position.Y;
f32 t = std::exp(-23 * frametime);
@@ -607,14 +611,11 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
const bool walking = movement_XZ && player->touching_ground;
const bool swimming = (movement_XZ || player->swimming_vertical) && player->in_liquid;
const bool climbing = movement_Y && player->is_climbing;
- if ((walking || swimming || climbing) &&
- (!g_settings->getBool("free_move") || !m_client->checkLocalPrivilege("fly"))) {
+ if ((walking || swimming || climbing) && !flying) {
// Start animation
m_view_bobbing_state = 1;
m_view_bobbing_speed = MYMIN(speed.getLength(), 70);
- }
- else if (m_view_bobbing_state == 1)
- {
+ } else if (m_view_bobbing_state == 1) {
// Stop animation
m_view_bobbing_state = 2;
m_view_bobbing_speed = 60;