paysages3d/src/render/software/LightStatus.cpp
Michaël Lemaire 0058a0a8e3 Switched to RGB material colors
...to avoid otherwise unused HSL conversion, which causes problems
for some RGB values (like Color(1, 0, 0))
2015-08-19 19:14:59 +02:00

46 lines
1.1 KiB
C++

#include "LightStatus.h"
#include "LightingManager.h"
#include "Color.h"
#include "SurfaceMaterial.h"
LightStatus::LightStatus(LightingManager *manager, const Vector3 &location, const Vector3 &eye)
{
this->max_power = 0.0;
this->manager = manager;
this->location = location;
this->eye = eye;
}
void LightStatus::pushComponent(LightComponent component)
{
double power = component.color.getPower();
if (component.altered && (power < max_power * 0.05 || power < 0.001))
{
// Exclude filtered lights that are owerpowered by a previous one
return;
}
if (manager->alterLight(component, location))
{
if (power > max_power)
{
max_power = power;
}
components.push_back(component);
}
}
Color LightStatus::apply(const Vector3 &normal, const SurfaceMaterial &material)
{
Color final(0.0, 0.0, 0.0, 0.0);
for (auto component: components)
{
final = final.add(manager->applyFinalComponent(component, eye, location, normal, material));
}
final.a = material.base->a;
return final;
}