Added DirectionalLights to renderqueue jobs

This commit is contained in:
Tleety
2016-01-18 14:58:19 +01:00
parent 0a3b6f4da1
commit 794635b6a1
3 changed files with 34 additions and 13 deletions
+3
View File
@@ -12,6 +12,7 @@
#include "RenderJob.h" #include "RenderJob.h"
#include "ModelJob.h" #include "ModelJob.h"
#include "PointLightJob.h" #include "PointLightJob.h"
#include "DirectionalLightJob.h"
/* /*
@@ -53,12 +54,14 @@ struct RenderScene
::Camera* Camera; ::Camera* Camera;
std::list<std::shared_ptr<RenderJob>> ForwardJobs; std::list<std::shared_ptr<RenderJob>> ForwardJobs;
std::list<std::shared_ptr<RenderJob>> PointLightJobs; std::list<std::shared_ptr<RenderJob>> PointLightJobs;
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
Rectangle Viewport; Rectangle Viewport;
void Clear() void Clear()
{ {
ForwardJobs.clear(); ForwardJobs.clear();
PointLightJobs.clear(); PointLightJobs.clear();
DirectionalLightJobs.clear();
} }
}; };
@@ -1,4 +1,5 @@
<c:PointLight> <c:PointLight>
<Direction X="0" Y="0" Z="0"/>
<Color R="1" G="1" B="1" A="1"/> <Color R="1" G="1" B="1" A="1"/>
<Intensity>0.8</Intensity> <Intensity>0.8</Intensity>
<Visible>true</Visible> <Visible>true</Visible>
+22 -5
View File
@@ -102,10 +102,7 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World
void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world) void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
{ {
auto pointLights = world->GetComponents("PointLight"); auto pointLights = world->GetComponents("PointLight");
if (pointLights == nullptr) { if (pointLights != nullptr) {
return;
}
for (auto& pointlightC : *pointLights) { for (auto& pointlightC : *pointLights) {
bool visible = pointlightC["Visible"]; bool visible = pointlightC["Visible"];
if (!visible) { if (!visible) {
@@ -113,12 +110,32 @@ void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World*
} }
auto transformC = world->GetComponent(pointlightC.EntityID, "Transform"); auto transformC = world->GetComponent(pointlightC.EntityID, "Transform");
if (&transformC == nullptr) { if (&transformC == nullptr) {
return; continue;
} }
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World)); std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
jobs.push_back(pointLightJob); 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> directionalLightJob = std::shared_ptr<DirectionalLightJob>(new DirectionalLightJob(transformC, directionalLightC, m_World));
jobs.push_back(directionalLightJob);
}
}
} }
bool RenderSystem::OnInputCommand(const Events::InputCommand& e) bool RenderSystem::OnInputCommand(const Events::InputCommand& e)