Fix camera "jumping" when attached and the parent goes too fast
authorZeg9 <dazeg9@gmail.com>
Thu, 27 Dec 2012 13:22:59 +0000 (14:22 +0100)
committerPilzAdam <pilzadam@minetest.net>
Wed, 3 Apr 2013 21:22:40 +0000 (23:22 +0200)
src/camera.cpp
src/content_cao.cpp
src/localplayer.cpp
src/localplayer.h

index b1e5884153969c11338b579379230a175cc5c2a5..138b022c049208ec07a788e8daa7db15310e5f0d 100644 (file)
@@ -218,6 +218,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
        // Smooth the movement when walking up stairs
        v3f old_player_position = m_playernode->getPosition();
        v3f player_position = player->getPosition();
+       if (player->isAttached && player->parent)
+               player_position = player->parent->getPosition();
        //if(player->touching_ground && player_position.Y > old_player_position.Y)
        if(player->touching_ground &&
                        player_position.Y > old_player_position.Y)
index ee1009b6cb6e7cfcbdd00762a8232fe88de67373..84fc0bf79bf2defbcc604d8bf10fea3fe5c2cc06 100644 (file)
@@ -1129,6 +1129,7 @@ public:
                        {
                                LocalPlayer *player = m_env->getLocalPlayer();
                                player->overridePosition = getParent()->getPosition();
+                               m_env->getLocalPlayer()->parent = getParent();
                        }
                }
                else
index ee9b41c58eb34f948b2edccdacacb2aed2e63304..a90ae69671ce70583b353cedb1fca72da18aee92 100644 (file)
@@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 LocalPlayer::LocalPlayer(IGameDef *gamedef):
        Player(gamedef),
+       parent(0),
        isAttached(false),
        overridePosition(v3f(0,0,0)),
        last_position(v3f(0,0,0)),
index 17434d37910e2103b377afd61e47317651a1a2bc..9ac2bc6828b3b3946287615516a0ca3e9c796db5 100644 (file)
@@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 class ClientEnvironment;
 
+class ClientActiveObject;
+
 class LocalPlayer : public Player
 {
 public:
@@ -35,6 +37,8 @@ public:
        {
                return true;
        }
+       
+       ClientActiveObject *parent;
 
        bool isAttached;