chore: cache advancing components and support any core object as adva… (#11039) a9e670e153

chore: cache advancing components and support any core object as advanceable

Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
bodymovin
2025-11-15 20:02:49 +00:00
parent f73857b3b4
commit 06c84e3653
8 changed files with 11 additions and 6 deletions

View File

@@ -1 +1 @@
7507e62b37da31cacffaf5b5176ac2fca48e3224
a9e670e1538aff90576d74905b1140df75d9da2a

View File

@@ -13,7 +13,7 @@ public:
float elapsedSeconds,
AdvanceFlags flags = AdvanceFlags::Animate |
AdvanceFlags::NewFrame) = 0;
static AdvancingComponent* from(Component* component);
static AdvancingComponent* from(Core* component);
};
} // namespace rive

View File

@@ -82,6 +82,7 @@ private:
std::vector<Joystick*> m_Joysticks;
std::vector<ResettingComponent*> m_Resettables;
std::vector<ScriptedObject*> m_ScriptedObjects;
std::vector<AdvancingComponent*> m_advancingComponents;
DataContext* m_DataContext = nullptr;
bool m_ownsDataContext = false;
bool m_JoysticksApplyBeforeUpdate = true;

View File

@@ -11,7 +11,7 @@
using namespace rive;
AdvancingComponent* AdvancingComponent::from(Component* component)
AdvancingComponent* AdvancingComponent::from(Core* component)
{
switch (component->coreType())
{

View File

@@ -286,6 +286,11 @@ StatusCode Artboard::initialize()
break;
}
}
auto advancingComponent = AdvancingComponent::from(object);
if (advancingComponent)
{
m_advancingComponents.push_back(advancingComponent);
}
}
if (!isInstance())
@@ -1056,10 +1061,9 @@ bool Artboard::advanceInternal(float elapsedSeconds, AdvanceFlags flags)
{
bool didUpdate = false;
for (auto dep : m_DependencyOrder)
for (auto adv : m_advancingComponents)
{
auto adv = AdvancingComponent::from(dep);
if (adv != nullptr && adv->advanceComponent(elapsedSeconds, flags))
if (adv->advanceComponent(elapsedSeconds, flags))
{
didUpdate = true;
}