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) 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);
} }