fix(runtime): Revert state machine checks for needsAdvance (#10985) 3b82e09da9

Reverted an update where nested artboards were checking their nested state machine instances for needsAdvance and advancing if true. This appeared to fix (#10842) an issue that required a double advance when running goldens, however, there is actually another issue that this masked rather than fixing it. That will come in a seperate PR.

Co-authored-by: Philip Chung <philterdesign@gmail.com>
This commit is contained in:
philter
2025-11-06 02:19:48 +00:00
parent 883e0c8094
commit 3d195c35fd
28 changed files with 31 additions and 9 deletions

View File

@@ -1 +1 @@
5615843df14982a800a9973889f24f186baad133
3b82e09da9d34a185d0022d678525622594484ac

View File

@@ -2045,10 +2045,9 @@ bool StateMachineInstance::advanceAndApply(float seconds)
}
// Advance all animations.
if (this->tryChangeState() || this->needsAdvance())
if (this->tryChangeState())
{
this->advance(0.0f, false);
this->m_needsAdvance = false;
keepGoing = true;
}

View File

@@ -327,8 +327,7 @@ bool ArtboardComponentList::advanceComponent(float elapsedSeconds,
// finally settle in the same value
if (!newFrame)
{
if (stateMachine->tryChangeState() ||
stateMachine->needsAdvance())
if (stateMachine->tryChangeState())
{
if (stateMachine->advance(elapsedSeconds, newFrame))
{

View File

@@ -514,10 +514,7 @@ bool NestedArtboard::advanceComponent(float elapsedSeconds, AdvanceFlags flags)
{
if (animation->is<NestedStateMachine>())
{
auto nestedSM = animation->as<NestedStateMachine>();
if (nestedSM->tryChangeState() ||
(nestedSM->stateMachineInstance() != nullptr &&
nestedSM->stateMachineInstance()->needsAdvance()))
if (animation->as<NestedStateMachine>()->tryChangeState())
{
if (animation->advance(localElapsedSeconds, newFrame))
{

Binary file not shown.

View File

@@ -305,4 +305,31 @@ TEST_CASE("Quantize and speed on nested artboards", "[silver]")
}
CHECK(silver.matches("nested_artboard_quantize_and_speed"));
}
TEST_CASE("Nested artboard needs advance", "[silver]")
{
rive::SerializingFactory silver;
auto file = ReadRiveFile("assets/nested_needs_advance.riv", &silver);
auto artboard = file->artboardNamed("node");
silver.frameSize(artboard->width(), artboard->height());
REQUIRE(artboard != nullptr);
auto stateMachine = artboard->stateMachineAt(0);
stateMachine->advanceAndApply(0.1f);
auto renderer = silver.makeRenderer();
artboard->draw(renderer.get());
int frames = 120;
for (int i = 0; i < frames; i++)
{
silver.addFrame();
stateMachine->advanceAndApply(0.016f);
artboard->draw(renderer.get());
}
CHECK(silver.matches("nested_needs_advance"));
}

Binary file not shown.

Binary file not shown.