From: Zeg9 Date: Thu, 27 Dec 2012 13:22:59 +0000 (+0100) Subject: Fix camera "jumping" when attached and the parent goes too fast X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=c1bf6f9f7a6d2c5bd743422593a5ec72939bc6af;p=zefram%2Fminetest%2Fminetest_engine.git Fix camera "jumping" when attached and the parent goes too fast --- diff --git a/src/camera.cpp b/src/camera.cpp index b1e58841..138b022c 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 ee1009b6..84fc0bf7 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1129,6 +1129,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 ee9b41c5..a90ae696 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -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)), diff --git a/src/localplayer.h b/src/localplayer.h index 17434d37..9ac2bc68 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -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;