Cancel the setAnimationEndCallback when a non-existing animation is

tried to be set. Fixes #2628.
This commit is contained in:
hiker 2017-08-31 23:47:39 +10:00
parent 0dd3bbbd9b
commit 4759ff2490

View File

@ -881,6 +881,7 @@ void KartModel::setAnimation(AnimationFrameType type, bool play_non_loop)
{ {
// Special animation not found, revert to default // Special animation not found, revert to default
m_current_animation = AF_DEFAULT; m_current_animation = AF_DEFAULT;
m_animated_node->setAnimationEndCallback(NULL);
} }
} // setAnimation } // setAnimation
@ -899,17 +900,6 @@ void KartModel::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node)
// kart_model // kart_model
assert(node==m_animated_node); assert(node==m_animated_node);
// It should be a non-default type of animation, and should have
// a non negative frame (i.e. the animation is indeed defined).
if(m_current_animation==AF_DEFAULT ||
m_animation_frame[m_current_animation]<=-1)
{
Log::error("Kart_Model", "OnAnimationEnd for '%s': current %d frame %d",
m_model_filename.c_str(),
m_current_animation, m_animation_frame[m_current_animation]);
assert(false);
}
// 'type' is the start frame of the animation, type + 1 the frame // 'type' is the start frame of the animation, type + 1 the frame
// to begin the loop with, type + 2 to end the frame with // to begin the loop with, type + 2 to end the frame with
AnimationFrameType start = (AnimationFrameType)(m_current_animation+1); AnimationFrameType start = (AnimationFrameType)(m_current_animation+1);