Fix #3007 (Change animation speed Entity, without starting it from the beginning)

This commit is contained in:
NaruTrey 2016-06-10 15:51:49 +04:00
parent d36dd7a283
commit f66d8367bd
1 changed files with 8 additions and 1 deletions

View File

@ -1489,10 +1489,17 @@ void GenericCAO::updateAnimation()
{
if(m_animated_meshnode == NULL)
return;
if (m_animated_meshnode->getStartFrame() != m_animation_range.X ||
m_animated_meshnode->getEndFrame() != m_animation_range.Y)
{
f32 current_frame = m_animated_meshnode->getFrameNr();
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
// setFrameLoop method has a side effect, it resets the current frame of the animation
if (current_frame > m_animated_meshnode->getStartFrame() &&
current_frame < m_animated_meshnode->getEndFrame())
m_animated_meshnode->setCurrentFrame(current_frame);
}
if (m_animated_meshnode->getAnimationSpeed() != m_animation_speed)
m_animated_meshnode->setAnimationSpeed(m_animation_speed);
m_animated_meshnode->setTransitionTime(m_animation_blend);