From fbe18506206c070a0500a87ac7bc809979fb0198 Mon Sep 17 00:00:00 2001 From: mjtalbot Date: Fri, 3 Mar 2023 18:08:36 +0000 Subject: [PATCH] force blend states to keepGoing makes blend states keepGoing! fixes a regression introduced when looking at keep going of states when deciding if to advance them. for blend states specifically mixing is done as well as animating animation instances, and if the mix value changes we need to apply this change. @luigi-rosso struggled to build state machines into an automated test on the cpp side before. going to add one loading a `.riv` for this I think, at least to cover some basics here. btw, I assume we also want this behaviour for direct blend states https://2dimensions.slack.com/archives/CHMAP278R/p1677820699177779 Diffs= 2504d2ab2 force blend states to keepGoing (#4922) --- .rive_head | 2 +- .../rive_core/animation/blend_state_instance.dart | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.rive_head b/.rive_head index 3727ac5..1f1cfee 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -bc6c6f467b8f1e0f794be093a514768bd068088a +2504d2ab24d258621fc89a0120c794f2b53a2ffc diff --git a/lib/src/rive_core/animation/blend_state_instance.dart b/lib/src/rive_core/animation/blend_state_instance.dart index b71d895..5ba2721 100644 --- a/lib/src/rive_core/animation/blend_state_instance.dart +++ b/lib/src/rive_core/animation/blend_state_instance.dart @@ -27,18 +27,20 @@ abstract class BlendStateInstance, .toList(growable: false), super(state); - bool _keepGoing = true; @override - bool get keepGoing => _keepGoing; + bool get keepGoing => true; @mustCallSuper @override void advance(double seconds, StateMachineController controller) { - _keepGoing = false; // Advance all the animations in the blend state + // NOTE: we are intentionally ignoring the animationInstances' keepGoing + // return value. + // Blend states need to keep blending forever, as even if the animation + // does not change the mix values may for (final animation in animationInstances) { - if (animation.animationInstance.advance(seconds) && !keepGoing) { - _keepGoing = true; + if (animation.animationInstance.keepGoing) { + animation.animationInstance.advance(seconds); } } }