[General] Synchronize player & NPC rotation animations

0.6.1
David Cernat 8 years ago
parent f4cdedd8cb
commit 068a45be87

@ -1685,17 +1685,30 @@ void CharacterController::update(float duration)
Start of tes3mp addition
Character movement setting rotations get reset here, so we have to assign movement
settings to a relevant LocalActor now
settings to the LocalPlayer or a LocalActor now
*/
if (mwmp::Main::get().getCellController()->isLocalActor(mPtr))
if (MWBase::Environment::get().getWorld()->getPlayerPtr() == mPtr)
{
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
MWMechanics::Movement &movementSettings = mPtr.getClass().getMovementSettings(mPtr);
localPlayer->direction.pos[0] = movementSettings.mPosition[0];
localPlayer->direction.pos[1] = movementSettings.mPosition[1];
localPlayer->direction.pos[2] = movementSettings.mPosition[2];
localPlayer->direction.rot[0] = movementSettings.mRotation[0];
localPlayer->direction.rot[1] = movementSettings.mRotation[1];
localPlayer->direction.rot[2] = movementSettings.mRotation[2];
}
else if (mwmp::Main::get().getCellController()->isLocalActor(mPtr))
{
mwmp::LocalActor *localActor = mwmp::Main::get().getCellController()->getLocalActor(mPtr);
localActor->direction.pos[0] = cls.getMovementSettings(mPtr).mPosition[0];
localActor->direction.pos[1] = cls.getMovementSettings(mPtr).mPosition[1];
localActor->direction.pos[2] = cls.getMovementSettings(mPtr).mPosition[2];
localActor->direction.rot[0] = cls.getMovementSettings(mPtr).mRotation[0];
localActor->direction.rot[1] = cls.getMovementSettings(mPtr).mRotation[1];
localActor->direction.rot[2] = cls.getMovementSettings(mPtr).mRotation[2];
MWMechanics::Movement &movementSettings = mPtr.getClass().getMovementSettings(mPtr);
localActor->direction.pos[0] = movementSettings.mPosition[0];
localActor->direction.pos[1] = movementSettings.mPosition[1];
localActor->direction.pos[2] = movementSettings.mPosition[2];
localActor->direction.rot[0] = movementSettings.mRotation[0];
localActor->direction.rot[1] = movementSettings.mRotation[1];
localActor->direction.rot[2] = movementSettings.mRotation[2];
}
/*
End of tes3mp addition

@ -104,6 +104,9 @@ void DedicatedActor::setMovementSettings()
move->mPosition[0] = direction.pos[0];
move->mPosition[1] = direction.pos[1];
move->mPosition[2] = direction.pos[2];
move->mRotation[0] = direction.rot[0];
move->mRotation[1] = direction.rot[1];
move->mRotation[2] = direction.rot[2];
}
void DedicatedActor::setPosition()

@ -117,12 +117,16 @@ void DedicatedPlayer::move(float dt)
world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]);
}
world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]);
MWMechanics::Movement *move = &ptr.getClass().getMovementSettings(ptr);
move->mPosition[0] = direction.pos[0];
move->mPosition[1] = direction.pos[1];
move->mPosition[2] = direction.pos[2];
move->mRotation[0] = direction.rot[0];
move->mRotation[1] = direction.rot[1];
move->mRotation[2] = direction.rot[2];
world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]);
}
void DedicatedPlayer::setAnimFlags()

@ -324,10 +324,8 @@ void LocalPlayer::updatePosition(bool forceUpdate)
static bool isJumping = false;
static bool sentJumpEnd = true;
const MWMechanics::Movement &move = player.getClass().getMovementSettings(player);
bool posIsChanging = (move.mPosition[0] != 0 || move.mPosition[1] != 0 || move.mPosition[2] != 0 ||
move.mRotation[0] != 0 || move.mRotation[1] != 0 || move.mRotation[2] != 0);
bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 || direction.pos[2] != 0 ||
direction.rot[0] != 0 || direction.rot[1] != 0 || direction.rot[2] != 0);
if (forceUpdate || posIsChanging || posWasChanged)
{
@ -340,10 +338,6 @@ void LocalPlayer::updatePosition(bool forceUpdate)
position = player.getRefData().getPosition();
direction.pos[0] = move.mPosition[0];
direction.pos[1] = move.mPosition[1];
direction.pos[2] = move.mPosition[2];
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send();
}

@ -36,7 +36,7 @@ void PacketActorCellChange::Packet(RakNet::BitStream *bs, bool send)
RW(actor.cell.mName, send, 1);
RW(actor.position, send, 1);
RW(actor.direction.pos, send, 1);
RW(actor.direction, send, 1);
if (!send)
{

@ -31,7 +31,7 @@ void PacketActorPosition::Packet(RakNet::BitStream *bs, bool send)
RW(actor.mpNum, send);
RW(actor.position, send, 1);
RW(actor.direction.pos, send, 1);
RW(actor.direction, send, 1);
actor.hasPositionData = true;

@ -20,5 +20,5 @@ void PacketPlayerPosition::Packet(RakNet::BitStream *bs, bool send)
PlayerPacket::Packet(bs, send);
RW(player->position, send, 1);
RW(player->direction.pos, send, 1);
RW(player->direction, send, 1);
}

Loading…
Cancel
Save