mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
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:
@@ -1 +1 @@
|
||||
5615843df14982a800a9973889f24f186baad133
|
||||
3b82e09da9d34a185d0022d678525622594484ac
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
BIN
tests/unit_tests/assets/nested_needs_advance.riv
Normal file
BIN
tests/unit_tests/assets/nested_needs_advance.riv
Normal file
Binary file not shown.
@@ -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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/unit_tests/silvers/nested_needs_advance.sriv
Normal file
BIN
tests/unit_tests/silvers/nested_needs_advance.sriv
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user