forked from mirror/openmw-tes3mp
Fix a potential divide-by-zero
This commit is contained in:
parent
dca599b8c5
commit
cf6e3ab933
1 changed files with 7 additions and 1 deletions
|
@ -885,7 +885,12 @@ void CharacterController::update(float duration)
|
||||||
|
|
||||||
if(mAnimation && !mSkipAnim)
|
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
|
// Ensure we're moving in generally the right direction
|
||||||
if(mMovementSpeed > 0.f)
|
if(mMovementSpeed > 0.f)
|
||||||
{
|
{
|
||||||
|
@ -899,6 +904,7 @@ void CharacterController::update(float duration)
|
||||||
(movement.z > 0.0f && movement.z > moved.z*2.0f))
|
(movement.z > 0.0f && movement.z > moved.z*2.0f))
|
||||||
moved.z = movement.z;
|
moved.z = movement.z;
|
||||||
}
|
}
|
||||||
|
// Update movement
|
||||||
if(moved.squaredLength() > 1.0f)
|
if(moved.squaredLength() > 1.0f)
|
||||||
world->queueMovement(mPtr, moved);
|
world->queueMovement(mPtr, moved);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue