1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 23:53:52 +00:00

[Client] Implement head rotation sync for NPCs

This commit is contained in:
David Cernat 2017-04-08 11:40:19 +03:00
parent b8ca2382c7
commit 417284c701
2 changed files with 30 additions and 2 deletions

View file

@ -1595,8 +1595,8 @@ void CharacterController::update(float duration)
*/
bool hasLocalActorRecord = mwmp::Main::get().getCellController()->hasLocalActorRecord(mPtr);
bool hasDedicatedActorRecord = mwmp::Main::get().getCellController()->hasDedicatedActorRecord(mPtr);
mwmp::LocalActor *localActor;
mwmp::DedicatedActor *dedicatedActor;
mwmp::LocalActor *localActor = nullptr;
mwmp::DedicatedActor *dedicatedActor = nullptr;
if (hasLocalActorRecord)
localActor = mwmp::Main::get().getCellController()->getLocalActor(mPtr);
@ -2454,6 +2454,31 @@ void CharacterController::updateHeadTracking(float duration)
xAngleRadians = (1.f-factor) * mAnimation->getHeadPitch() + factor * (-xAngleRadians);
zAngleRadians = (1.f-factor) * mAnimation->getHeadYaw() + factor * (-zAngleRadians);
/*
Start of tes3mp addition
Save or load head pitch and yaw depending on whether this is a local or dedicated actor
*/
if (mwmp::Main::get().getCellController()->hasLocalActorRecord(mPtr))
{
mwmp::LocalActor *localActor = mwmp::Main::get().getCellController()->getLocalActor(mPtr);
localActor->headPitch = xAngleRadians;
localActor->headYaw = zAngleRadians;
}
else if (mwmp::Main::get().getCellController()->hasDedicatedActorRecord(mPtr))
{
mwmp::DedicatedActor *dedicatedActor = mwmp::Main::get().getCellController()->getDedicatedActor(mPtr);
if (dedicatedActor->headPitch != -1)
xAngleRadians = dedicatedActor->headPitch;
if (dedicatedActor->headYaw != -1)
zAngleRadians = dedicatedActor->headYaw;
}
/*
End of tes3mp addition
*/
mAnimation->setHeadPitch(xAngleRadians);
mAnimation->setHeadYaw(zAngleRadians);
}

View file

@ -134,6 +134,9 @@ void Cell::readCellFrame(WorldEvent& worldEvent)
actor->position = worldObject.pos;
actor->drawState = worldObject.drawState;
actor->headPitch = worldObject.headPitch;
actor->headYaw = worldObject.headYaw;
actor->hasAnimation = worldObject.hasAnimation;
actor->hasAnimStates = worldObject.hasAnimStates;
actor->hasMovement = worldObject.hasMovement;