Directional light now fully added to all lists.

This commit is contained in:
Tleety
2016-01-18 15:15:33 +01:00
parent 794635b6a1
commit 01a164847c
6 changed files with 20 additions and 14 deletions
@@ -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;
+2 -1
View File
@@ -46,7 +46,8 @@ private:
void updateProjectionMatrix(ComponentWrapper& cameraComponent);
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
+1
View File
@@ -9,6 +9,7 @@
<xs:include schemaLocation="Components/Camera.xsd"/>
<xs:include schemaLocation="Components/AABB.xsd"/>
<xs:include schemaLocation="Components/PointLight.xsd"/>
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
<xs:include schemaLocation="Components/Trigger.xsd"/>
<xs:include schemaLocation="Components/Health.xsd"/>
</xs:schema>
@@ -1,6 +1,6 @@
<c:PointLight>
<c:DirectionalLight>
<Direction X="0" Y="0" Z="0"/>
<Color R="1" G="1" B="1" A="1"/>
<Intensity>0.8</Intensity>
<Visible>true</Visible>
</c:PointLight>
</c:DirectionalLight>
+4 -4
View File
@@ -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<directionalLightJob>(job);
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(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;
}
}
}
+7 -3
View File
@@ -99,7 +99,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::fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
{
auto pointLights = world->GetComponents("PointLight");
if (pointLights != nullptr) {
@@ -117,8 +117,11 @@ void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World*
jobs.push_back(pointLightJob);
}
}
}
void RenderSystem::fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
{
auto directionalLights = world->GetComponents("DirectionalLight");
if (directionalLights != nullptr) {
for (auto& directionalLightC : *directionalLights) {
@@ -128,7 +131,7 @@ void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& 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);
}