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); + } } }