[Client] Implement head rotation sync for NPCs

0.6.1
David Cernat 8 years ago
parent b8ca2382c7
commit 417284c701

@ -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);
}

@ -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;

Loading…
Cancel
Save