summaryrefslogtreecommitdiff
path: root/src/client/localplayer.cpp
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2019-11-27 20:36:51 +0100
committerSmallJoker <SmallJoker@users.noreply.github.com>2019-12-07 15:12:26 +0100
commitaa8df112ff42d94b6dc59a0153d989bd8c0b115e (patch)
tree3488aea2ccd10228740d810f9a34da2260c95a57 /src/client/localplayer.cpp
parent51f230895c2b6d99a6fddc1c235140fcf9938742 (diff)
downloadminetest-aa8df112ff42d94b6dc59a0153d989bd8c0b115e.tar.gz
minetest-aa8df112ff42d94b6dc59a0153d989bd8c0b115e.tar.bz2
minetest-aa8df112ff42d94b6dc59a0153d989bd8c0b115e.zip
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
Diffstat (limited to 'src/client/localplayer.cpp')
-rw-r--r--src/client/localplayer.cpp15
1 files changed, 10 insertions, 5 deletions
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;