Skip to content

Commit 84d3cdf

Browse files
authored
Fix anim executables when animations wrap around (#7076)
1 parent b1e4bd7 commit 84d3cdf

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

code/model/animation/modelanimation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,15 @@ namespace animation {
240240
}
241241

242242
m_animation->calculateAnimation(applyBuffer, instanceData.time, pmi->id);
243-
m_animation->executeAnimation(applyBuffer, MIN(prevTime, instanceData.time), MAX(prevTime, instanceData.time), instanceData.canonicalDirection, pmi->id);
243+
244+
if ((prevTime > instanceData.time && instanceData.canonicalDirection == ModelAnimationDirection::FWD) || (prevTime < instanceData.time && instanceData.canonicalDirection == ModelAnimationDirection::RWD)) {
245+
//We _should_ have been going FWD, but we appear to have gone backwards (or we _should_ have been going FWD, but we appear to have gone forwards).
246+
//This indicates that we looped around, or that we did a hard reset. Unfortunately, we can't quite differentiate that.
247+
m_animation->executeAnimation(applyBuffer, 0.0f, MIN(prevTime, instanceData.time), instanceData.canonicalDirection, pmi->id);
248+
m_animation->executeAnimation(applyBuffer, MAX(prevTime, instanceData.time), instanceData.duration, instanceData.canonicalDirection, pmi->id);
249+
}
250+
else
251+
m_animation->executeAnimation(applyBuffer, MIN(prevTime, instanceData.time), MAX(prevTime, instanceData.time), instanceData.canonicalDirection, pmi->id);
244252
break;
245253

246254
case ModelAnimationState::PAUSED:

0 commit comments

Comments
 (0)