1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 09:53:50 +00:00

Fix a potential divide-by-zero

This commit is contained in:
Chris Robinson 2013-08-19 09:36:51 -07:00
parent dca599b8c5
commit cf6e3ab933

View file

@ -885,7 +885,12 @@ void CharacterController::update(float duration)
if(mAnimation && !mSkipAnim)
{
Ogre::Vector3 moved = mAnimation->runAnimation(duration) / duration;
Ogre::Vector3 moved = mAnimation->runAnimation(duration);
if(duration > 0.0f)
moved /= duration;
else
moved = Ogre::Vector3(0.0f);
// Ensure we're moving in generally the right direction
if(mMovementSpeed > 0.f)
{
@ -899,6 +904,7 @@ void CharacterController::update(float duration)
(movement.z > 0.0f && movement.z > moved.z*2.0f))
moved.z = movement.z;
}
// Update movement
if(moved.squaredLength() > 1.0f)
world->queueMovement(mPtr, moved);
}