summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorrandom-geek <35757396+random-geek@users.noreply.github.com>2018-12-30 16:07:30 -0800
committerParamat <paramat@users.noreply.github.com>2018-12-31 00:07:30 +0000
commitaa5ec2ec02f331542dfe40e781c7c93ee4c0c131 (patch)
tree207960a9115366cc9d1d82cd593dd855b166b173 /src/client
parent7d7ccf5c0f3d8689519629282d72b1fea8f4bf30 (diff)
downloadminetest-aa5ec2ec02f331542dfe40e781c7c93ee4c0c131.tar.gz
minetest-aa5ec2ec02f331542dfe40e781c7c93ee4c0c131.tar.bz2
minetest-aa5ec2ec02f331542dfe40e781c7c93ee4c0c131.zip
Extend pitch fly mode to swimming (#7943)
Diffstat (limited to 'src/client')
-rw-r--r--src/client/clientenvironment.cpp3
-rw-r--r--src/client/game.cpp18
-rw-r--r--src/client/inputhandler.cpp2
-rw-r--r--src/client/keys.h2
-rw-r--r--src/client/localplayer.cpp12
-rw-r--r--src/client/localplayer.h1
6 files changed, 24 insertions, 14 deletions
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index 7c2ec099c..1783e8961 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -170,7 +170,8 @@ void ClientEnvironment::step(float dtime)
lplayer->physics_override_gravity * dtime_part * 2.0f;
// Liquid floating / sinking
- if (lplayer->in_liquid && !lplayer->swimming_vertical)
+ if (lplayer->in_liquid && !lplayer->swimming_vertical &&
+ !lplayer->swimming_pitch)
speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
// Liquid resistance
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 06e8eefe3..bd37bd58a 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -702,7 +702,7 @@ protected:
void openConsole(float scale, const wchar_t *line=NULL);
void toggleFreeMove();
void toggleFreeMoveAlt();
- void togglePitchFly();
+ void togglePitchMove();
void toggleFast();
void toggleNoClip();
void toggleCinematic();
@@ -1898,8 +1898,8 @@ void Game::processKeyInput()
toggleFreeMove();
} else if (wasKeyDown(KeyType::JUMP)) {
toggleFreeMoveAlt();
- } else if (wasKeyDown(KeyType::PITCHFLY)) {
- togglePitchFly();
+ } else if (wasKeyDown(KeyType::PITCHMOVE)) {
+ togglePitchMove();
} else if (wasKeyDown(KeyType::FASTMOVE)) {
toggleFast();
} else if (wasKeyDown(KeyType::NOCLIP)) {
@@ -2109,15 +2109,15 @@ void Game::toggleFreeMoveAlt()
}
-void Game::togglePitchFly()
+void Game::togglePitchMove()
{
- bool pitch_fly = !g_settings->getBool("pitch_fly");
- g_settings->set("pitch_fly", bool_to_cstr(pitch_fly));
+ bool pitch_move = !g_settings->getBool("pitch_move");
+ g_settings->set("pitch_move", bool_to_cstr(pitch_move));
- if (pitch_fly) {
- m_game_ui->showTranslatedStatusText("Pitch fly mode enabled");
+ if (pitch_move) {
+ m_game_ui->showTranslatedStatusText("Pitch move mode enabled");
} else {
- m_game_ui->showTranslatedStatusText("Pitch fly mode disabled");
+ m_game_ui->showTranslatedStatusText("Pitch move mode disabled");
}
}
diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp
index 2692e9f1e..a79b04a90 100644
--- a/src/client/inputhandler.cpp
+++ b/src/client/inputhandler.cpp
@@ -48,7 +48,7 @@ void KeyCache::populate()
key[KeyType::CONSOLE] = getKeySetting("keymap_console");
key[KeyType::MINIMAP] = getKeySetting("keymap_minimap");
key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove");
- key[KeyType::PITCHFLY] = getKeySetting("keymap_pitchfly");
+ key[KeyType::PITCHMOVE] = getKeySetting("keymap_pitchmove");
key[KeyType::FASTMOVE] = getKeySetting("keymap_fastmove");
key[KeyType::NOCLIP] = getKeySetting("keymap_noclip");
key[KeyType::HOTBAR_PREV] = getKeySetting("keymap_hotbar_previous");
diff --git a/src/client/keys.h b/src/client/keys.h
index 28c6574ba..50d3d194b 100644
--- a/src/client/keys.h
+++ b/src/client/keys.h
@@ -47,7 +47,7 @@ public:
CONSOLE,
MINIMAP,
FREEMOVE,
- PITCHFLY,
+ PITCHMOVE,
FASTMOVE,
NOCLIP,
HOTBAR_PREV,
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()
diff --git a/src/client/localplayer.h b/src/client/localplayer.h
index 28404aa01..b1fc1fbc8 100644
--- a/src/client/localplayer.h
+++ b/src/client/localplayer.h
@@ -62,6 +62,7 @@ public:
u8 liquid_viscosity = 0;
bool is_climbing = false;
bool swimming_vertical = false;
+ bool swimming_pitch = false;
float physics_override_speed = 1.0f;
float physics_override_jump = 1.0f;