Add system graph (wip)
This commit is contained in:
37
src/Nazara/Core/Systems/SystemGraph.cpp
Normal file
37
src/Nazara/Core/Systems/SystemGraph.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Systems/SystemGraph.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SystemGraph::NodeBase::~NodeBase() = default;
|
||||
|
||||
void SystemGraph::Update()
|
||||
{
|
||||
return Update(m_clock.Restart() / 1'000'000.f);
|
||||
}
|
||||
|
||||
void SystemGraph::Update(float elapsedTime)
|
||||
{
|
||||
if (!m_systemOrderUpdated)
|
||||
{
|
||||
m_orderedNodes.clear();
|
||||
m_orderedNodes.reserve(m_nodes.size());
|
||||
for (auto& nodePtr : m_nodes)
|
||||
m_orderedNodes.emplace_back(nodePtr.get());
|
||||
|
||||
std::sort(m_orderedNodes.begin(), m_orderedNodes.end(), [](const NodeBase* a, const NodeBase* b)
|
||||
{
|
||||
return a->executionOrder < b->executionOrder;
|
||||
});
|
||||
|
||||
m_systemOrderUpdated = true;
|
||||
}
|
||||
|
||||
for (NodeBase* node : m_orderedNodes)
|
||||
node->Update(elapsedTime);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user