Fix animation frame duration issue - #86
Conversation
…Noble.Animation. (upstream PR NobleRobot#86) Fixes uneven frame timing for animation states whose frameDuration differs from the first-added state: previousFrameDurationCount was being reset from the stale animation-level self.frameDuration instead of self.current.frameDuration at the loop/next-state sites. Also redirects the now-unused animation-level frameDuration assignment in addState. Applies upstream PR NobleRobot#86. Co-authored-by: Juan Xavier Gomez <xendke@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Commit 6be1f0e (upstream PR NobleRobot#86) reset previousFrameDurationCount to the current state's frameDuration, but the advance condition (frameDurationCount - previousFrameDurationCount) >= frameDuration, together with frameDurationCount resetting to 1, means the consistent reset value is 1 (the value both counters are initialized with). Using the state's frameDuration made the first frame after a loop or state change display for (2 * frameDuration - 1) ticks instead of frameDuration - a visible stutter on every loop whenever frameDuration is greater than 1. In the state-transition branch it also read the outgoing state's frameDuration, since setState() runs on the next line. Reset both counters to 1 in both branches. This also makes the addState() line "self.current.frameDuration = frameDuration" a redundant assignment (the state table constructor already sets it), so remove it. Refs upstream PR NobleRobot#86. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…Noble.Animation. (upstream PR NobleRobot#86) Fixes uneven frame timing for animation states whose frameDuration differs from the first-added state: previousFrameDurationCount was being reset from the stale animation-level self.frameDuration instead of self.current.frameDuration at the loop/next-state sites. Also redirects the now-unused animation-level frameDuration assignment in addState. Applies upstream PR NobleRobot#86. Co-authored-by: Juan Xavier Gomez <xendke@users.noreply.github.com>
Commit 6be1f0e (upstream PR NobleRobot#86) reset previousFrameDurationCount to the current state's frameDuration, but the advance condition (frameDurationCount - previousFrameDurationCount) >= frameDuration, together with frameDurationCount resetting to 1, means the consistent reset value is 1 (the value both counters are initialized with). Using the state's frameDuration made the first frame after a loop or state change display for (2 * frameDuration - 1) ticks instead of frameDuration - a visible stutter on every loop whenever frameDuration is greater than 1. In the state-transition branch it also read the outgoing state's frameDuration, since setState() runs on the next line. Reset both counters to 1 in both branches. This also makes the addState() line "self.current.frameDuration = frameDuration" a redundant assignment (the state table constructor already sets it), so remove it. Refs upstream PR NobleRobot#86.
|
Thanks for this fix — switching the reset sites to read The advance check is Since self.frameDurationCount = 1
self.previousFrameDurationCount = 1With that, the |
I've noticed that in my walking animation (a looping 2 frame animation) there's one frame being drawn more than the other. This PR fixes that.
It seems that there were a couple of instances of
self.frameDurationthat should have really beenself.current.frameDurationBefore
After