summaryrefslogtreecommitdiff
path: root/src/clientenvironment.cpp
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2018-07-14 18:41:26 +0100
committerGitHub <noreply@github.com>2018-07-14 18:41:26 +0100
commitb38c121856965665f5e17b64100873a4bb97bf58 (patch)
treed641d1c1a8cfcac2d4560d4833a3dc98d2034a78 /src/clientenvironment.cpp
parent69358b601cc7cde9c4df89aa23d67e6d32a2aa6b (diff)
downloadminetest-b38c121856965665f5e17b64100873a4bb97bf58.tar.gz
minetest-b38c121856965665f5e17b64100873a4bb97bf58.tar.bz2
minetest-b38c121856965665f5e17b64100873a4bb97bf58.zip
Make player liquid speed independent of FPS (#7543)
Make player liquid speed independent of FPS. Fix codestyle issues in code block.
Diffstat (limited to 'src/clientenvironment.cpp')
-rw-r--r--src/clientenvironment.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/clientenvironment.cpp b/src/clientenvironment.cpp
index 53e3f783a..a81d0dd8f 100644
--- a/src/clientenvironment.cpp
+++ b/src/clientenvironment.cpp
@@ -165,31 +165,32 @@ void ClientEnvironment::step(float dtime)
{
// Apply physics
- if(!free_move && !is_climbing)
- {
+ if (!free_move && !is_climbing) {
// Gravity
v3f speed = lplayer->getSpeed();
- if(!lplayer->in_liquid)
- speed.Y -= lplayer->movement_gravity * lplayer->physics_override_gravity * dtime_part * 2;
+ if (!lplayer->in_liquid)
+ speed.Y -= lplayer->movement_gravity *
+ lplayer->physics_override_gravity * dtime_part * 2.0f;
// Liquid floating / sinking
- if(lplayer->in_liquid && !lplayer->swimming_vertical)
- speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2;
+ if (lplayer->in_liquid && !lplayer->swimming_vertical)
+ speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
// Liquid resistance
- if(lplayer->in_liquid_stable || lplayer->in_liquid)
- {
- // How much the node's viscosity blocks movement, ranges between 0 and 1
- // Should match the scale at which viscosity increase affects other liquid attributes
- const f32 viscosity_factor = 0.3;
+ if (lplayer->in_liquid_stable || lplayer->in_liquid) {
+ // How much the node's viscosity blocks movement, ranges
+ // between 0 and 1. Should match the scale at which viscosity
+ // increase affects other liquid attributes.
+ static const f32 viscosity_factor = 0.3f;
v3f d_wanted = -speed / lplayer->movement_liquid_fluidity;
f32 dl = d_wanted.getLength();
- if(dl > lplayer->movement_liquid_fluidity_smooth)
+ if (dl > lplayer->movement_liquid_fluidity_smooth)
dl = lplayer->movement_liquid_fluidity_smooth;
- dl *= (lplayer->liquid_viscosity * viscosity_factor) + (1 - viscosity_factor);
- v3f d = d_wanted.normalize() * dl;
+ dl *= (lplayer->liquid_viscosity * viscosity_factor) +
+ (1 - viscosity_factor);
+ v3f d = d_wanted.normalize() * (dl * dtime_part * 100.0f);
speed += d;
}