Ndk: Add RenderSystem (experimental)

Former-commit-id: 23b11c6e9a21a4f26df6bde3d161578101cb2b29
This commit is contained in:
Lynix
2015-05-19 01:03:11 +02:00
parent e0da339217
commit 9aacbe158c
5 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Systems/RenderSystem.hpp>
#include <NDK/Components/CameraComponent.hpp>
#include <NDK/Components/GraphicsComponent.hpp>
namespace Ndk
{
RenderSystem::RenderSystem()
{
}
void RenderSystem::Update(float elapsedTime)
{
}
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
if (entity->HasComponent<CameraComponent>())
{
m_cameras.Insert(entity);
std::sort(m_cameras.begin(), m_cameras.end(), [](const EntityHandle& handle1, const EntityHandle& handle2)
{
return handle1->GetComponent<CameraComponent>().GetLayer() < handle2->GetComponent<CameraComponent>().GetLayer();
});
}
else
m_cameras.Remove(entity);
if (entity->HasComponent<GraphicsComponent>())
m_drawables.Insert(entity);
else
m_drawables.Remove(entity);
}
SystemIndex RenderSystem::systemIndex;
}