mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-08 09:37:53 +00:00
Fix #5586
This commit is contained in:
parent
54f678b172
commit
7e3d19196d
@ -938,6 +938,8 @@ namespace MWClass
|
||||
|
||||
float Npc::getMaxSpeed(const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
// TODO: This function is called several times per frame for each NPC.
|
||||
// It would be better to calculate it only once per frame for each NPC and save the result in CreatureStats.
|
||||
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
||||
return 0.f;
|
||||
|
@ -1965,8 +1965,11 @@ void CharacterController::update(float duration, bool animationOnly)
|
||||
vec.normalize();
|
||||
|
||||
float effectiveRotation = rot.z();
|
||||
bool canMove = cls.getMaxSpeed(mPtr) > 0;
|
||||
static const bool turnToMovementDirection = Settings::Manager::getBool("turn to movement direction", "Game");
|
||||
if (turnToMovementDirection && !isFirstPersonPlayer)
|
||||
if (!turnToMovementDirection || isFirstPersonPlayer)
|
||||
movementSettings.mIsStrafing = std::abs(vec.x()) > std::abs(vec.y()) * 2;
|
||||
else if (canMove)
|
||||
{
|
||||
float targetMovementAngle = vec.y() >= 0 ? std::atan2(-vec.x(), vec.y()) : std::atan2(vec.x(), -vec.y());
|
||||
movementSettings.mIsStrafing = (stats.getDrawState() != MWMechanics::DrawState_Nothing || inwater)
|
||||
@ -1986,8 +1989,6 @@ void CharacterController::update(float duration, bool animationOnly)
|
||||
stats.setSideMovementAngle(stats.getSideMovementAngle() + delta);
|
||||
effectiveRotation += delta;
|
||||
}
|
||||
else
|
||||
movementSettings.mIsStrafing = std::abs(vec.x()) > std::abs(vec.y()) * 2;
|
||||
|
||||
mAnimation->setLegsYawRadians(stats.getSideMovementAngle());
|
||||
if (stats.getDrawState() == MWMechanics::DrawState_Nothing || inwater)
|
||||
|
Loading…
Reference in New Issue
Block a user