Ndk: Add RenderSystem (experimental)
Former-commit-id: 23b11c6e9a21a4f26df6bde3d161578101cb2b29
This commit is contained in:
parent
e0da339217
commit
9aacbe158c
|
|
@ -0,0 +1,39 @@
|
|||
// 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class GraphicsComponent;
|
||||
|
||||
class NDK_API RenderSystem : public System<RenderSystem>
|
||||
{
|
||||
public:
|
||||
RenderSystem();
|
||||
~RenderSystem() = default;
|
||||
|
||||
void Update(float elapsedTime);
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
|
||||
EntityList m_cameras;
|
||||
EntityList m_drawables;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Systems/RenderSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
// 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
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
namespace Ndk
|
||||
|
|
@ -65,6 +66,7 @@ namespace Ndk
|
|||
// Systèmes
|
||||
InitializeSystem<ListenerSystem>();
|
||||
InitializeSystem<PhysicsSystem>();
|
||||
InitializeSystem<RenderSystem>();
|
||||
InitializeSystem<VelocitySystem>();
|
||||
|
||||
NazaraNotice("Initialized: SDK");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
namespace Ndk
|
||||
|
|
@ -20,6 +21,7 @@ namespace Ndk
|
|||
{
|
||||
AddSystem<ListenerSystem>();
|
||||
AddSystem<PhysicsSystem>();
|
||||
AddSystem<RenderSystem>();
|
||||
AddSystem<VelocitySystem>();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue