Merge remote-tracking branch 'origin/NDK' into NDK-ShadowMapping

Conflicts:
	SDK/include/NDK/Systems/RenderSystem.hpp
	SDK/src/NDK/Systems/RenderSystem.cpp

Former-commit-id: 0a72e838de272bff91f0b8c8a3637db94fdd7820
This commit is contained in:
Lynix
2015-06-22 13:31:23 +02:00
18 changed files with 341 additions and 301 deletions

View File

@@ -15,7 +15,7 @@ namespace Ndk
Requires<ListenerComponent, NodeComponent>();
}
void ListenerSystem::Update(float elapsedTime)
void ListenerSystem::OnUpdate(float elapsedTime)
{
NazaraUnused(elapsedTime);

View File

@@ -22,7 +22,21 @@ namespace Ndk
{
}
void PhysicsSystem::Update(float elapsedTime)
void PhysicsSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
// Si l'entité ne vient pas d'être ajoutée au système, il est possible qu'elle fasse partie du mauvais tableau
if (!justAdded)
{
// On prend le tableau inverse de celui dont l'entité devrait faire partie
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_staticObjects : m_dynamicObjects;
entities.Remove(entity);
}
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_dynamicObjects : m_staticObjects;
entities.Insert(entity);
}
void PhysicsSystem::OnUpdate(float elapsedTime)
{
m_world.Step(elapsedTime);
@@ -75,19 +89,5 @@ namespace Ndk
}
}
void PhysicsSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
// Si l'entité ne vient pas d'être ajoutée au système, il est possible qu'elle fasse partie du mauvais tableau
if (!justAdded)
{
// On prend le tableau inverse de celui dont l'entité devrait faire partie
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_staticObjects : m_dynamicObjects;
entities.Remove(entity);
}
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_dynamicObjects : m_staticObjects;
entities.Insert(entity);
}
SystemIndex PhysicsSystem::systemIndex;
}

View File

@@ -17,7 +17,69 @@ namespace Ndk
{
}
void RenderSystem::Update(float elapsedTime)
void RenderSystem::OnEntityRemoved(Entity* entity)
{
m_cameras.Remove(entity);
m_drawables.Remove(entity);
m_lights.Remove(entity);
}
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
if (entity->HasComponent<CameraComponent>() && entity->HasComponent<NodeComponent>())
{
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>() && entity->HasComponent<NodeComponent>())
m_drawables.Insert(entity);
else
m_drawables.Remove(entity);
if (entity->HasComponent<LightComponent>() && entity->HasComponent<NodeComponent>())
m_lights.Insert(entity);
else
m_lights.Remove(entity);
}
void RenderSystem::OnEntityRemoved(Entity* entity)
{
m_cameras.Remove(entity);
m_drawables.Remove(entity);
m_lights.Remove(entity);
}
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
if (entity->HasComponent<CameraComponent>() && entity->HasComponent<NodeComponent>())
{
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>() && entity->HasComponent<NodeComponent>())
m_drawables.Insert(entity);
else
m_drawables.Remove(entity);
if (entity->HasComponent<LightComponent>() && entity->HasComponent<NodeComponent>())
m_lights.Insert(entity);
else
m_lights.Remove(entity);
}
void RenderSystem::OnUpdate(float elapsedTime)
{
UpdateShadowMaps();
@@ -56,37 +118,6 @@ namespace Ndk
}
}
void RenderSystem::OnEntityRemoved(Entity* entity)
{
m_cameras.Remove(entity);
m_drawables.Remove(entity);
m_lights.Remove(entity);
}
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
if (entity->HasComponent<CameraComponent>() && entity->HasComponent<NodeComponent>())
{
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>() && entity->HasComponent<NodeComponent>())
m_drawables.Insert(entity);
else
m_drawables.Remove(entity);
if (entity->HasComponent<LightComponent>() && entity->HasComponent<NodeComponent>())
m_lights.Insert(entity);
else
m_lights.Remove(entity);
}
void RenderSystem::UpdateShadowMaps()
{
if (!m_shadowRT.IsValid())

View File

@@ -15,7 +15,7 @@ namespace Ndk
Excludes<PhysicsComponent>();
}
void VelocitySystem::Update(float elapsedTime)
void VelocitySystem::OnUpdate(float elapsedTime)
{
for (const Ndk::EntityHandle& entity : GetEntities())
{