Skip to content

Commit

Permalink
Cinematic: Use glm::distance
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed Oct 16, 2018
1 parent 3e8d61b commit c871daf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/cinematic/Cinematic.cpp
Expand Up @@ -151,19 +151,18 @@ static float LightRND;

static Color CalculLight(CinematicLight * light, Vec2f pos, Color col) {

float ra = std::sqrt((light->pos.x - pos.x) * (light->pos.x - pos.x)
+ (light->pos.y - pos.y) * (light->pos.y - pos.y));
float distance = glm::distance(Vec2f(light->pos), pos);

if(ra > light->fallout) {
if(distance > light->fallout) {
return col * LightRND;
}

Color3f color = light->color * (LightRND / 255.f);
if(ra >= light->fallin) {
color = color * ((light->fallout - ra) / (light->fallout - light->fallin));
float attenuation = LightRND / 255.f;
if(distance >= light->fallin) {
attenuation *= (light->fallout - distance) / (light->fallout - light->fallin);
}

return Color(Color3f(col) + color, col.a);
return Color(Color3f(col) + light->color * attenuation, col.a);
}

static Vec3f TransformLocalVertex(const Vec2f & vbase, const Vec3f & LocalPos, float LocalSin, float LocalCos) {
Expand Down

0 comments on commit c871daf

Please sign in to comment.