From 0702e4523da1fad519418af6fc084d60f64868f4 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 23 Feb 2017 09:27:00 +0100 Subject: [PATCH] Fix that sprite light wasn't calculated using the center of the sprite --- src/swrenderer/things/r_sprite.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 49c823ba2..2ebf1fd57 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -59,6 +59,7 @@ #include "gl/dynlights/gl_dynlight.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) +EXTERN_CVAR(Bool, gl_light_sprites) namespace swrenderer { @@ -227,7 +228,7 @@ namespace swrenderer bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0; - if (r_dynlights) + if (r_dynlights && gl_light_sprites) { float lit_red = 0; float lit_green = 0; @@ -238,9 +239,9 @@ namespace swrenderer ADynamicLight *light = node->lightsource; if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != thing)) { - float lx = (float)(light->X() - pos.X); - float ly = (float)(light->Y() - pos.Y); - float lz = (float)(light->Z() - pos.Z); + float lx = (float)(light->X() - thing->X()); + float ly = (float)(light->Y() - thing->Y()); + float lz = (float)(light->Z() - thing->Center()); float LdotL = lx * lx + ly * ly + lz * lz; float radius = node->lightsource->GetRadius(); if (radius * radius >= LdotL)