Sdk/World: Optimize updating dirty entities by removing a branch
This commit is contained in:
parent
4536ba768c
commit
a8d4e44669
|
|
@ -253,9 +253,6 @@ namespace Ndk
|
||||||
Update(); //< Update entities
|
Update(); //< Update entities
|
||||||
|
|
||||||
// And then update systems
|
// And then update systems
|
||||||
if (!m_orderedSystemsUpdated)
|
|
||||||
ReorderSystems();
|
|
||||||
|
|
||||||
for (auto& systemPtr : m_orderedSystems)
|
for (auto& systemPtr : m_orderedSystems)
|
||||||
systemPtr->Update(elapsedTime);
|
systemPtr->Update(elapsedTime);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,9 @@ namespace Ndk
|
||||||
|
|
||||||
void World::Update()
|
void World::Update()
|
||||||
{
|
{
|
||||||
|
if (!m_orderedSystemsUpdated)
|
||||||
|
ReorderSystems();
|
||||||
|
|
||||||
// Handle killed entities before last call
|
// Handle killed entities before last call
|
||||||
for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i))
|
for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i))
|
||||||
{
|
{
|
||||||
|
|
@ -221,12 +224,8 @@ namespace Ndk
|
||||||
entity->DestroyComponent(j);
|
entity->DestroyComponent(j);
|
||||||
removedComponents.Reset();
|
removedComponents.Reset();
|
||||||
|
|
||||||
for (auto& system : m_systems)
|
for (auto& system : m_orderedSystems)
|
||||||
{
|
{
|
||||||
// Ignore non-existent systems
|
|
||||||
if (!system)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Is our entity already part of this system?
|
// Is our entity already part of this system?
|
||||||
bool partOfSystem = system->HasEntity(entity);
|
bool partOfSystem = system->HasEntity(entity);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue