Custom step height: Fix implementation
authorparamat <mat.gregory@virginmedia.com>
Mon, 8 May 2017 00:27:11 +0000 (01:27 +0100)
committerparamat <mat.gregory@virginmedia.com>
Mon, 8 May 2017 04:59:19 +0000 (05:59 +0100)
Recent commit 45ab62d6a3d90ab3b97aec88251a766cb5dd1899 had a coding error that
made climbing out of water difficult due to an incorrect value of the step height
when not 'touching ground'.
It also incorrectly multiplied the custom stepheight by BS, resulting in being
able to step-up 2 nodes if set to the default of 0.6, or even 0.3.
Also the implementation was wrong because it customised the step height when
not 'touching ground', this step height is for a slight rise when catching the
edge of a node during a jump, and should always remain at 0.2 * BS.

src/localplayer.cpp

index 37aef7afe88beaafab0da029c94368bccfd12a49..20892dee63001d1ecd83e03dffc75bd256cd663c 100644 (file)
@@ -344,13 +344,11 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
                }
        }
 
-       float player_stepheight = (m_cao == 0) ? 0.0 :
-                               (touching_ground ?
-                               (m_cao->getStepheight() * BS) :
-                               (m_cao->getStepheight() -0.4 * BS));
+       float player_stepheight = (m_cao == 0) ? 0.0f :
+                       ((touching_ground) ? m_cao->getStepheight() : (0.2f * BS));
 
 #ifdef __ANDROID__
-       player_stepheight += (0.6 * BS);
+       player_stepheight += (0.6f * BS);
 #endif
 
        v3f accel_f = v3f(0,0,0);