mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-22 18:39:40 +00:00
Fix #5586
This commit is contained in:
parent
54f678b172
commit
7e3d19196d
2 changed files with 6 additions and 3 deletions
|
@ -938,6 +938,8 @@ namespace MWClass
|
||||||
|
|
||||||
float Npc::getMaxSpeed(const MWWorld::Ptr& ptr) const
|
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);
|
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||||
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
|
@ -1965,8 +1965,11 @@ void CharacterController::update(float duration, bool animationOnly)
|
||||||
vec.normalize();
|
vec.normalize();
|
||||||
|
|
||||||
float effectiveRotation = rot.z();
|
float effectiveRotation = rot.z();
|
||||||
|
bool canMove = cls.getMaxSpeed(mPtr) > 0;
|
||||||
static const bool turnToMovementDirection = Settings::Manager::getBool("turn to movement direction", "Game");
|
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());
|
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)
|
movementSettings.mIsStrafing = (stats.getDrawState() != MWMechanics::DrawState_Nothing || inwater)
|
||||||
|
@ -1986,8 +1989,6 @@ void CharacterController::update(float duration, bool animationOnly)
|
||||||
stats.setSideMovementAngle(stats.getSideMovementAngle() + delta);
|
stats.setSideMovementAngle(stats.getSideMovementAngle() + delta);
|
||||||
effectiveRotation += delta;
|
effectiveRotation += delta;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
movementSettings.mIsStrafing = std::abs(vec.x()) > std::abs(vec.y()) * 2;
|
|
||||||
|
|
||||||
mAnimation->setLegsYawRadians(stats.getSideMovementAngle());
|
mAnimation->setLegsYawRadians(stats.getSideMovementAngle());
|
||||||
if (stats.getDrawState() == MWMechanics::DrawState_Nothing || inwater)
|
if (stats.getDrawState() == MWMechanics::DrawState_Nothing || inwater)
|
||||||
|
|
Loading…
Reference in a new issue