@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
26
26
#include " player.h"
27
27
#include < cmath>
28
28
#include " client/renderingengine.h"
29
+ #include " client/content_cao.h"
29
30
#include " settings.h"
30
31
#include " wieldmesh.h"
31
32
#include " noise.h" // easeCurve
@@ -341,13 +342,16 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
341
342
if (player->getParent ())
342
343
player_position = player->getParent ()->getPosition ();
343
344
344
- // Smooth the camera movement when the player instantly moves upward due to stepheight.
345
- // To smooth the 'not touching_ground' stepheight, smoothing is necessary when jumping
346
- // or swimming (for when moving from liquid to land).
347
- // Disable smoothing if climbing or flying, to avoid upwards offset of player model
348
- // when seen in 3rd person view.
349
- bool flying = g_settings->getBool (" free_move" ) && m_client->checkLocalPrivilege (" fly" );
350
- if (player_position.Y > old_player_position.Y && !player->is_climbing && !flying) {
345
+ // Smooth the camera movement after the player instantly moves upward due to stepheight.
346
+ // The smoothing usually continues until the camera position reaches the player position.
347
+ float player_stepheight = player->getCAO () ? player->getCAO ()->getStepHeight () : HUGE_VALF;
348
+ float upward_movement = player_position.Y - old_player_position.Y ;
349
+ if (upward_movement < 0 .01f || upward_movement > player_stepheight) {
350
+ m_stepheight_smooth_active = false ;
351
+ } else if (player->touching_ground ) {
352
+ m_stepheight_smooth_active = true ;
353
+ }
354
+ if (m_stepheight_smooth_active) {
351
355
f32 oldy = old_player_position.Y ;
352
356
f32 newy = player_position.Y ;
353
357
f32 t = std::exp (-23 * frametime);
@@ -587,6 +591,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
587
591
const bool walking = movement_XZ && player->touching_ground ;
588
592
const bool swimming = (movement_XZ || player->swimming_vertical ) && player->in_liquid ;
589
593
const bool climbing = movement_Y && player->is_climbing ;
594
+ const bool flying = g_settings->getBool (" free_move" )
595
+ && m_client->checkLocalPrivilege (" fly" );
590
596
if ((walking || swimming || climbing) && !flying) {
591
597
// Start animation
592
598
m_view_bobbing_state = 1 ;
0 commit comments