mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
51f230895c
commit
aa8df112ff
7 changed files with 57 additions and 61 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue