Fix animations not being restartable (#15016)

This commit is contained in:
Lars Müller 2024-08-20 11:51:52 +02:00 committed by GitHub
parent 2664afd832
commit dc21924f31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 7 deletions

@ -1518,9 +1518,8 @@ void GenericCAO::updateAnimation()
if (!m_animated_meshnode) if (!m_animated_meshnode)
return; return;
if (m_animated_meshnode->getStartFrame() != m_animation_range.X || // Note: This sets the current frame as well, (re)starting the animation.
m_animated_meshnode->getEndFrame() != m_animation_range.Y) m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
if (m_animated_meshnode->getAnimationSpeed() != m_animation_speed) if (m_animated_meshnode->getAnimationSpeed() != m_animation_speed)
m_animated_meshnode->setAnimationSpeed(m_animation_speed); m_animated_meshnode->setAnimationSpeed(m_animation_speed);
m_animated_meshnode->setTransitionTime(m_animation_blend); m_animated_meshnode->setTransitionTime(m_animation_blend);

@ -55,10 +55,7 @@ const ItemGroupList &UnitSAO::getArmorGroups() const
void UnitSAO::setAnimation( void UnitSAO::setAnimation(
v2f frame_range, float frame_speed, float frame_blend, bool frame_loop) v2f frame_range, float frame_speed, float frame_blend, bool frame_loop)
{ {
if (std::tie(m_animation_range, m_animation_speed, m_animation_blend, // Note: Always resend (even if parameters are unchanged) to restart animations.
m_animation_loop) ==
std::tie(frame_range, frame_speed, frame_blend, frame_loop))
return; // no change
m_animation_range = frame_range; m_animation_range = frame_range;
m_animation_speed = frame_speed; m_animation_speed = frame_speed;
m_animation_blend = frame_blend; m_animation_blend = frame_blend;