diff options
author | random-geek <35757396+random-geek@users.noreply.github.com> | 2018-12-30 16:07:30 -0800 |
---|---|---|
committer | Paramat <paramat@users.noreply.github.com> | 2018-12-31 00:07:30 +0000 |
commit | aa5ec2ec02f331542dfe40e781c7c93ee4c0c131 (patch) | |
tree | 207960a9115366cc9d1d82cd593dd855b166b173 /src/client/localplayer.cpp | |
parent | 7d7ccf5c0f3d8689519629282d72b1fea8f4bf30 (diff) | |
download | minetest-aa5ec2ec02f331542dfe40e781c7c93ee4c0c131.tar.gz minetest-aa5ec2ec02f331542dfe40e781c7c93ee4c0c131.tar.bz2 minetest-aa5ec2ec02f331542dfe40e781c7c93ee4c0c131.zip |
Extend pitch fly mode to swimming (#7943)
Diffstat (limited to 'src/client/localplayer.cpp')
-rw-r--r-- | src/client/localplayer.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index c15c90931..dbb50d397 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -468,6 +468,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env) { // Clear stuff swimming_vertical = false; + swimming_pitch = false; setPitch(control.pitch); setYaw(control.yaw); @@ -492,7 +493,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env) bool free_move = fly_allowed && player_settings.free_move; bool fast_move = fast_allowed && player_settings.fast_move; - bool pitch_fly = free_move && player_settings.pitch_fly; + bool pitch_move = (free_move || in_liquid) && player_settings.pitch_move; // When aux1_descends is enabled the fast key is used to go down, so fast isn't possible bool fast_climb = fast_move && control.aux1 && !player_settings.aux1_descends; bool continuous_forward = player_settings.continuous_forward; @@ -685,10 +686,17 @@ void LocalPlayer::applyControl(float dtime, Environment *env) if (!free_move) slip_factor = getSlipFactor(env, speedH); + // Don't sink when swimming in pitch mode + if (pitch_move && in_liquid) { + v3f controlSpeed = speedH + speedV; + if (controlSpeed.getLength() > 0.01f) + swimming_pitch = true; + } + // Accelerate to target speed with maximum increment accelerate((speedH + speedV) * physics_override_speed, incH * physics_override_speed * slip_factor, incV * physics_override_speed, - pitch_fly); + pitch_move); } v3s16 LocalPlayer::getStandingNodePos() |