From fc13c00ef3e9b6f280146f3d77b6659fcc55a13c Mon Sep 17 00:00:00 2001 From: Ben Deutsch Date: Sat, 26 Aug 2017 09:01:09 +0200 Subject: 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 --- src/localplayer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/localplayer.h') diff --git a/src/localplayer.h b/src/localplayer.h index c64e0042a..3521512af 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -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; -- cgit v1.2.3