Fix visual glitch when jumping without adjusting camera afterwards

This commit is contained in:
David Cernat 2016-08-23 22:27:12 +03:00
parent fc4d8b82fb
commit 7b187d0295

View file

@ -133,6 +133,9 @@ void LocalPlayer::updatePosition(bool forceUpdate)
static bool posChanged = false; static bool posChanged = false;
static bool isJumping = false;
static bool sentJumpEnd = true;
ESM::Position _pos = player.getRefData().getPosition(); ESM::Position _pos = player.getRefData().getPosition();
const bool isChangedPos = (move.mPosition[0] != 0 || move.mPosition[1] != 0 || move.mPosition[2] != 0 const bool isChangedPos = (move.mPosition[0] != 0 || move.mPosition[1] != 0 || move.mPosition[2] != 0
@ -142,6 +145,9 @@ void LocalPlayer::updatePosition(bool forceUpdate)
{ {
posChanged = isChangedPos; posChanged = isChangedPos;
if (!isJumping && !world->isOnGround(player) && !world->isFlying(player)) {
isJumping = true;
}
(*Position()) = _pos; (*Position()) = _pos;
@ -151,6 +157,18 @@ void LocalPlayer::updatePosition(bool forceUpdate)
GetNetworking()->GetPacket(ID_GAME_UPDATE_POS)->Send(this); GetNetworking()->GetPacket(ID_GAME_UPDATE_POS)->Send(this);
} }
else if (isJumping && world->isOnGround(player)) {
isJumping = false;
sentJumpEnd = false;
}
// Packet with jump end position has to be sent one tick after above check
else if (!sentJumpEnd) {
sentJumpEnd = true;
(*Position()) = _pos;
GetNetworking()->GetPacket(ID_GAME_UPDATE_POS)->Send(this);
}
} }