mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
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:
@@ -1 +1 @@
|
||||
7507e62b37da31cacffaf5b5176ac2fca48e3224
|
||||
a9e670e1538aff90576d74905b1140df75d9da2a
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
using namespace rive;
|
||||
|
||||
AdvancingComponent* AdvancingComponent::from(Component* component)
|
||||
AdvancingComponent* AdvancingComponent::from(Core* component)
|
||||
{
|
||||
switch (component->coreType())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user