From 01a164847c41713deb9ef908921917188cada510 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 18 Jan 2016 15:15:33 +0100 Subject: [PATCH] Directional light now fully added to all lists. --- include/Engine/Rendering/DirectionalLightJob.h | 8 ++++---- include/Engine/Rendering/RenderSystem.h | 3 ++- resources/Schema/Components.xsd | 1 + resources/Schema/Components/DirectionalLight.xml | 4 ++-- src/Engine/Rendering/LightCullingPass.cpp | 8 ++++---- src/Engine/Rendering/RenderSystem.cpp | 10 +++++++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index 2686eb41..e8cd5b17 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -12,12 +12,12 @@ struct DirectionalLightJob : RenderJob { - DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightCompoentn, World* m_World) + DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightComponent, World* m_World) : RenderJob() { - Direction = glm::vec4((glm::vec3)directionalLightCompoentn["Direction"], 1.f); - Color = (glm::vec4)directionalLightCompoentn["Color"]; - Intensity = (double)directionalLightCompoentn["Intensity"]; + Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 1.f); + Color = (glm::vec4)directionalLightComponent["Color"]; + Intensity = (double)directionalLightComponent["Intensity"]; }; glm::vec4 Direction; diff --git a/include/Engine/Rendering/RenderSystem.h b/include/Engine/Rendering/RenderSystem.h index fe110276..966593db 100644 --- a/include/Engine/Rendering/RenderSystem.h +++ b/include/Engine/Rendering/RenderSystem.h @@ -46,7 +46,8 @@ private: void updateProjectionMatrix(ComponentWrapper& cameraComponent); void fillModels(std::list>& jobs, World* world); - void fillLight(std::list>& jobs, World* world); + void fillPointLights(std::list>& jobs, World* world); + void fillDirectionalLights(std::list>& jobs, World* world); EventRelay m_EInputCommand; bool OnInputCommand(const Events::InputCommand& e); diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 9181daf2..a90d51ec 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -9,6 +9,7 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/DirectionalLight.xml b/resources/Schema/Components/DirectionalLight.xml index c854696a..79d3ac2b 100644 --- a/resources/Schema/Components/DirectionalLight.xml +++ b/resources/Schema/Components/DirectionalLight.xml @@ -1,6 +1,6 @@ - + 0.8 true - \ No newline at end of file + \ No newline at end of file diff --git a/src/Engine/Rendering/LightCullingPass.cpp b/src/Engine/Rendering/LightCullingPass.cpp index 76f2045f..f49156dc 100644 --- a/src/Engine/Rendering/LightCullingPass.cpp +++ b/src/Engine/Rendering/LightCullingPass.cpp @@ -96,19 +96,19 @@ void LightCullingPass::FillLightList(RenderScene& scene) //p.Padding = 123.f; p.Type = LightSource::Point; m_LightSources.push_back(p); - continue; + } } for(auto &job : scene.DirectionalLightJobs) { - auto directionalLightJob = std::dynamic_pointer_cast(job); + auto directionalLightJob = std::dynamic_pointer_cast(job); if(directionalLightJob) { LightSource p; + p.Direction = directionalLightJob->Direction; p.Color = directionalLightJob->Color; p.Intensity = directionalLightJob->Intensity; - p.Position = glm::vec4(glm::vec3(directionalLightJob->Position), 1.f); p.Type = LightSource::Directional; m_LightSources.push_back(p); - continue; + } } } diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index eecf6786..9a75a615 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -99,7 +99,7 @@ void RenderSystem::fillModels(std::list>& jobs, World } -void RenderSystem::fillLight(std::list>& jobs, World* world) +void RenderSystem::fillPointLights(std::list>& jobs, World* world) { auto pointLights = world->GetComponents("PointLight"); if (pointLights != nullptr) { @@ -117,8 +117,11 @@ void RenderSystem::fillLight(std::list>& jobs, World* jobs.push_back(pointLightJob); } } +} +void RenderSystem::fillDirectionalLights(std::list>& jobs, World* world) +{ auto directionalLights = world->GetComponents("DirectionalLight"); if (directionalLights != nullptr) { for (auto& directionalLightC : *directionalLights) { @@ -128,7 +131,7 @@ void RenderSystem::fillLight(std::list>& jobs, World* } auto transformC = world->GetComponent(directionalLightC.EntityID, "Transform"); - if(&transformC == nullptr) { + if (&transformC == nullptr) { continue; } @@ -162,7 +165,8 @@ void RenderSystem::Update(World* world, double dt) scene.Camera = m_Camera; scene.Viewport = Rectangle(1280, 720); fillModels(scene.ForwardJobs, world); - fillLight(scene.PointLightJobs, world); + fillPointLights(scene.PointLightJobs, world); + fillDirectionalLights(scene.DirectionalLightJobs, world); m_RenderFrame->Add(scene); }