mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-26 06:21:29 -04:00
Merge branch 'fix_5586' into 'master'
Fix #5586 Closes #5586 See merge request OpenMW/openmw!291
This commit is contained in:
commit
f5f59c1149
@ -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…
x
Reference in New Issue
Block a user