aboutsummaryrefslogtreecommitdiff
path: root/src/client/clientenvironment.cpp
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2022-09-20 10:55:51 +0200
committerGitHub <noreply@github.com>2022-09-20 10:55:51 +0200
commit1317cd12d74dba4ff765d6e18b0b30cdf42002a3 (patch)
tree417fcd478cf89fbf4912f816bec13cf8a4b6a9c5 /src/client/clientenvironment.cpp
parent11905a6db65e70c84683098711ce36958968c6c3 (diff)
downloadminetest-1317cd12d74dba4ff765d6e18b0b30cdf42002a3.tar.xz
Fix formula used for acceleration (#12353)
Diffstat (limited to 'src/client/clientenvironment.cpp')
-rw-r--r--src/client/clientenvironment.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index d7b3c4950..f5e8b3601 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -195,21 +195,24 @@ void ClientEnvironment::step(float dtime)
lplayer->applyControl(dtime_part, this);
// Apply physics
+ lplayer->gravity = 0;
if (!free_move) {
// Gravity
- v3f speed = lplayer->getSpeed();
if (!is_climbing && !lplayer->in_liquid)
- speed.Y -= lplayer->movement_gravity *
- lplayer->physics_override.gravity * dtime_part * 2.0f;
+ // HACK the factor 2 for gravity is arbitrary and should be removed eventually
+ lplayer->gravity = 2 * lplayer->movement_gravity * lplayer->physics_override.gravity;
// Liquid floating / sinking
if (!is_climbing && lplayer->in_liquid &&
!lplayer->swimming_vertical &&
!lplayer->swimming_pitch)
- speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
+ // HACK the factor 2 for gravity is arbitrary and should be removed eventually
+ lplayer->gravity = 2 * lplayer->movement_liquid_sink;
// Movement resistance
if (lplayer->move_resistance > 0) {
+ v3f speed = lplayer->getSpeed();
+
// How much the node's move_resistance blocks movement, ranges
// between 0 and 1. Should match the scale at which liquid_viscosity
// increase affects other liquid attributes.
@@ -232,15 +235,16 @@ void ClientEnvironment::step(float dtime)
(1 - resistance_factor);
v3f d = d_wanted.normalize() * (dl * dtime_part * 100.0f);
speed += d;
- }
- lplayer->setSpeed(speed);
+ lplayer->setSpeed(speed);
+ }
}
/*
Move the lplayer.
This also does collision detection.
*/
+
lplayer->move(dtime_part, this, position_max_increment,
&player_collisions);
}