From aa8df112ff42d94b6dc59a0153d989bd8c0b115e Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 27 Nov 2019 20:36:51 +0100 Subject: Attachments: Fix interpolation from (0,0,0) after detach GenericCAO::getPosition() did not take the camera offset into account LocalPlayer attachment cleanup: Use sane getParent() function Make that getPosition() (GenericCAO and LocalPlayer) always return the absolute position --- src/client/localplayer.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/client/localplayer.cpp') diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index c086d860a..c20c3619f 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -184,8 +184,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, v3f position = getPosition(); // Copy parent position if local player is attached - if (isAttached) { - setPosition(overridePosition); + if (getParent()) { + setPosition(m_cao->getPosition()); added_velocity = v3f(0.0f); // ignored return; } @@ -474,7 +474,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env) setYaw(control.yaw); // Nullify speed and don't run positioning code if the player is attached - if (isAttached) { + if (getParent()) { setSpeed(v3f(0.0f)); return; } @@ -706,6 +706,11 @@ v3f LocalPlayer::getEyeOffset() const return v3f(0.0f, BS * eye_height, 0.0f); } +ClientActiveObject *LocalPlayer::getParent() const +{ + return m_cao ? m_cao->getParent() : nullptr; +} + bool LocalPlayer::isDead() const { FATAL_ERROR_IF(!getCAO(), "LocalPlayer's CAO isn't initialized"); @@ -764,8 +769,8 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d, v3f position = getPosition(); // Copy parent position if local player is attached - if (isAttached) { - setPosition(overridePosition); + if (getParent()) { + setPosition(m_cao->getPosition()); m_sneak_node_exists = false; added_velocity = v3f(0.0f); return; -- cgit v1.2.3