From 794635b6a1c114e8746a61db0d3d0d25d6b407e2 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 18 Jan 2016 14:58:19 +0100 Subject: [PATCH] Added DirectionalLights to renderqueue jobs --- include/Engine/Rendering/RenderQueue.h | 3 ++ .../Schema/Components/DirectionalLight.xml | 1 + src/Engine/Rendering/RenderSystem.cpp | 43 +++++++++++++------ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 119ea57f..8df967ac 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -12,6 +12,7 @@ #include "RenderJob.h" #include "ModelJob.h" #include "PointLightJob.h" +#include "DirectionalLightJob.h" /* @@ -53,12 +54,14 @@ struct RenderScene ::Camera* Camera; std::list> ForwardJobs; std::list> PointLightJobs; + std::list> DirectionalLightJobs; Rectangle Viewport; void Clear() { ForwardJobs.clear(); PointLightJobs.clear(); + DirectionalLightJobs.clear(); } }; diff --git a/resources/Schema/Components/DirectionalLight.xml b/resources/Schema/Components/DirectionalLight.xml index a14697c8..c854696a 100644 --- a/resources/Schema/Components/DirectionalLight.xml +++ b/resources/Schema/Components/DirectionalLight.xml @@ -1,4 +1,5 @@ + 0.8 true diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 11eca86b..eecf6786 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -102,22 +102,39 @@ void RenderSystem::fillModels(std::list>& jobs, World void RenderSystem::fillLight(std::list>& jobs, World* world) { auto pointLights = world->GetComponents("PointLight"); - if (pointLights == nullptr) { - return; + if (pointLights != nullptr) { + for (auto& pointlightC : *pointLights) { + bool visible = pointlightC["Visible"]; + if (!visible) { + continue; + } + auto transformC = world->GetComponent(pointlightC.EntityID, "Transform"); + if (&transformC == nullptr) { + continue; + } + + std::shared_ptr pointLightJob = std::shared_ptr(new PointLightJob(transformC, pointlightC, m_World)); + jobs.push_back(pointLightJob); + } } - for (auto& pointlightC : *pointLights) { - bool visible = pointlightC["Visible"]; - if (!visible) { - continue; - } - auto transformC = world->GetComponent(pointlightC.EntityID, "Transform"); - if (&transformC == nullptr) { - return; - } - std::shared_ptr pointLightJob = std::shared_ptr(new PointLightJob(transformC, pointlightC, m_World)); - jobs.push_back(pointLightJob); + auto directionalLights = world->GetComponents("DirectionalLight"); + if (directionalLights != nullptr) { + for (auto& directionalLightC : *directionalLights) { + bool visable = directionalLightC["Visible"]; + if (!visable) { + continue; + } + + auto transformC = world->GetComponent(directionalLightC.EntityID, "Transform"); + if(&transformC == nullptr) { + continue; + } + + std::shared_ptr directionalLightJob = std::shared_ptr(new DirectionalLightJob(transformC, directionalLightC, m_World)); + jobs.push_back(directionalLightJob); + } } }