1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-21 18:11:11 +00:00

Alternative code for slipping (#6256)

* Alternative code for slipping

- does not depend on frame rate
- controllable via environment variables for now

* Adjust slipping speed for item entities too.

* Final version of framerate-independent slippery code

* Remove dead code and fix formatting

* getStandingNodePos should only look 0.05 nodes downwards

This ensures that, even if the player is standing on a partially
filled node, this node is used as the standing node and not the
node below it.

Specific use: enables slippery slabs

* Exchange global getStandingPosNode change for local inline change

Reverts previous commit

* Revert the item movement changes

* Slippery nodes now slip over cliffs and edges

Players no longer suddenly stop before falling off.
Also refactored slippery code into getSlipFactor method.

* Slipping over an edge gated by player's is_slipping state

A new flag for just this case, to reduce costly node lookups in
the normal case of leaning over a non-slippery edge.
Public access for consistency and potential future uses.

* Minor code tweaks / cosmetics

* Add temp variable to improve readability and fix indentation issues
This commit is contained in:
Ben Deutsch 2017-08-26 09:01:09 +02:00 committed by Loïc Blot
parent 0e0643df35
commit fc13c00ef3
2 changed files with 55 additions and 16 deletions

View file

@ -60,6 +60,7 @@ public:
u8 liquid_viscosity = 0;
bool is_climbing = false;
bool swimming_vertical = false;
bool is_slipping = false;
float physics_override_speed = 1.0f;
float physics_override_jump = 1.0f;
@ -143,11 +144,10 @@ public:
void setCollisionbox(const aabb3f &box) { m_collisionbox = box; }
private:
// clang-format off
void accelerateHorizontal(const v3f &target_speed, f32 max_increase, bool slippery);
// clang-format on
void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
void accelerateVertical(const v3f &target_speed, const f32 max_increase);
bool updateSneakNode(Map *map, const v3f &position, const v3f &sneak_max);
float getSlipFactor(Environment *env, const v3f &speedH);
v3f m_position;