Player::accelerateHorizontal/Vertical should be member of LocalPlayer 3708/head
authorLoic Blot <loic.blot@unix-experience.fr>
Sun, 14 Feb 2016 16:45:06 +0000 (17:45 +0100)
committerLoic Blot <loic.blot@unix-experience.fr>
Sun, 14 Feb 2016 16:52:10 +0000 (17:52 +0100)
src/localplayer.cpp
src/localplayer.h
src/player.cpp
src/player.h

index 60aec95d4a69f88bf6393353ae6ea54dd59d4e95..524c6272ec51d00569abdca3c50deac351d519bc 100644 (file)
@@ -622,3 +622,36 @@ v3s16 LocalPlayer::getStandingNodePos()
        return floatToInt(getPosition() - v3f(0, BS, 0), BS);
 }
 
+// Horizontal acceleration (X and Z), Y direction is ignored
+void LocalPlayer::accelerateHorizontal(const v3f &target_speed, const f32 max_increase)
+{
+        if (max_increase == 0)
+                return;
+
+        v3f d_wanted = target_speed - m_speed;
+        d_wanted.Y = 0;
+        f32 dl = d_wanted.getLength();
+        if (dl > max_increase)
+                dl = max_increase;
+
+        v3f d = d_wanted.normalize() * dl;
+
+        m_speed.X += d.X;
+        m_speed.Z += d.Z;
+}
+
+// Vertical acceleration (Y), X and Z directions are ignored
+void LocalPlayer::accelerateVertical(const v3f &target_speed, const f32 max_increase)
+{
+        if (max_increase == 0)
+                return;
+
+        f32 d_wanted = target_speed.Y - m_speed.Y;
+        if (d_wanted > max_increase)
+                d_wanted = max_increase;
+        else if (d_wanted < -max_increase)
+                d_wanted = -max_increase;
+
+        m_speed.Y += d_wanted;
+}
+
index 40a7f089edf6ab1112a96ba9452d7e507b7b11ad..3ae0c4e51d29566ffa04af1e19638df7598767f4 100644 (file)
@@ -45,7 +45,7 @@ public:
        bool isAttached;
 
        v3f overridePosition;
-       
+
        void move(f32 dtime, Environment *env, f32 pos_max_d);
        void move(f32 dtime, Environment *env, f32 pos_max_d,
                        std::vector<CollisionInfo> *collision_info);
@@ -81,6 +81,9 @@ public:
        }
 
 private:
+       void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
+       void accelerateVertical(const v3f &target_speed, const f32 max_increase);
+
        // This is used for determining the sneaking range
        v3s16 m_sneak_node;
        // Whether the player is allowed to sneak
index dd5e045093c0660c6387ff9f7291989a8c131660..623dde230e929bde78f1016859392729e2c17e7e 100644 (file)
@@ -111,41 +111,6 @@ Player::~Player()
        clearHud();
 }
 
-// Horizontal acceleration (X and Z), Y direction is ignored
-void Player::accelerateHorizontal(v3f target_speed, f32 max_increase)
-{
-       if(max_increase == 0)
-               return;
-
-       v3f d_wanted = target_speed - m_speed;
-       d_wanted.Y = 0;
-       f32 dl = d_wanted.getLength();
-       if(dl > max_increase)
-               dl = max_increase;
-
-       v3f d = d_wanted.normalize() * dl;
-
-       m_speed.X += d.X;
-       m_speed.Z += d.Z;
-
-}
-
-// Vertical acceleration (Y), X and Z directions are ignored
-void Player::accelerateVertical(v3f target_speed, f32 max_increase)
-{
-       if(max_increase == 0)
-               return;
-
-       f32 d_wanted = target_speed.Y - m_speed.Y;
-       if(d_wanted > max_increase)
-               d_wanted = max_increase;
-       else if(d_wanted < -max_increase)
-               d_wanted = -max_increase;
-
-       m_speed.Y += d_wanted;
-
-}
-
 v3s16 Player::getLightPosition() const
 {
        return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);
index 0d99297cadece6b033c9d4a44b4c9275ae696f71..50267c72cb01d6b3365710fa10dfdb54c4618dc9 100644 (file)
@@ -119,9 +119,6 @@ public:
                m_speed = speed;
        }
 
-       void accelerateHorizontal(v3f target_speed, f32 max_increase);
-       void accelerateVertical(v3f target_speed, f32 max_increase);
-
        v3f getPosition()
        {
                return m_position;