Sdk/World: Optimize updating dirty entities by removing a branch

This commit is contained in:
Jérôme Leclercq 2016-11-08 12:29:15 +01:00
parent 4536ba768c
commit a8d4e44669
2 changed files with 4 additions and 8 deletions

View File

@ -253,9 +253,6 @@ namespace Ndk
Update(); //< Update entities
// And then update systems
if (!m_orderedSystemsUpdated)
ReorderSystems();
for (auto& systemPtr : m_orderedSystems)
systemPtr->Update(elapsedTime);
}

View File

@ -172,6 +172,9 @@ namespace Ndk
void World::Update()
{
if (!m_orderedSystemsUpdated)
ReorderSystems();
// Handle killed entities before last call
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);
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?
bool partOfSystem = system->HasEntity(entity);