From 91c22d9528e88264aa81fceb63d900c422ac84af Mon Sep 17 00:00:00 2001 From: Zeg9 Date: Thu, 27 Dec 2012 14:22:59 +0100 Subject: [PATCH] Fix camera "jumping" when attached and the parent goes too fast --- src/camera.cpp | 2 ++ src/content_cao.cpp | 1 + src/localplayer.cpp | 1 + src/localplayer.h | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/src/camera.cpp b/src/camera.cpp index 1b9a8c763..46453b52c 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -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) diff --git a/src/content_cao.cpp b/src/content_cao.cpp index d71911b95..f4e99aebb 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1111,6 +1111,7 @@ public: { LocalPlayer *player = m_env->getLocalPlayer(); player->overridePosition = getParent()->getPosition(); + m_env->getLocalPlayer()->parent = getParent(); } } else diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 2a83ba956..ecd72ccd2 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -34,6 +34,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)), diff --git a/src/localplayer.h b/src/localplayer.h index c9d010d7c..4c6d7722b 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "player.h" +class ClientActiveObject; + class LocalPlayer : public Player { public: @@ -32,6 +34,8 @@ public: { return true; } + + ClientActiveObject *parent; bool isAttached;