1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-12 16:58:39 +00:00

Fix formula used for acceleration (#12353)

This commit is contained in:
Lars Müller 2022-09-20 10:55:51 +02:00 committed by GitHub
parent 11905a6db6
commit 1317cd12d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 16 deletions

View file

@ -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);
}