22 lines
709 B
C++
22 lines
709 B
C++
#include "LightPath.h"
|
|
#include "MathHelper.h"
|
|
#include "../inc/glm/glm.hpp"
|
|
|
|
LightState LightStateInterpolator::operator()(const LightState& before, const LightState& after, const double& time)
|
|
{
|
|
float t = (float)time;
|
|
LightState res;
|
|
res.lightType = before.lightType;
|
|
res.active = t < 0.5 ? before.active : after.active;
|
|
|
|
if (before.lightType != after.lightType)
|
|
res.lightProps = before.lightProps;
|
|
else
|
|
{
|
|
if (res.lightType == LightState::LightType::Directional)
|
|
res.lightProps = MathHelper::slerp(t, before.lightProps, after.lightProps);
|
|
else if (res.lightType == LightState::LightType::Point)
|
|
res.lightProps = MathHelper::lerp(t, before.lightProps, after.lightProps);
|
|
}
|
|
return res;
|
|
}; |