From 9ac3b6aa1b298f7cfa69a862fabe1bf77612a7d8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2013 13:15:22 +0100 Subject: [PATCH] - fixed: IsVisibleToPlayer needs to be checked for the owner of owned dynamic lights. --- src/gl/dynlights/gl_dynlight1.cpp | 4 ++ src/gl/scene/gl_spritelight.cpp | 61 ++++++++++++++++--------------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index af2a9f7c6..0b2ffa43d 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -183,6 +183,10 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u { return false; } + if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer()) + { + return false; + } scale = 1.0f / ((2.f * radius) - dist); diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index d630ddbc2..b1216d86b 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -79,42 +79,45 @@ bool gl_GetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_ while (node) { light=node->lightsource; - if (!(light->flags2&MF2_DORMANT) && - (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) { - float dist = FVector3( FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z) ).Length(); - radius = light->GetRadius() * gl_lights_size; - - if (dist < radius) + if (!(light->flags2&MF2_DORMANT) && + (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - frac = 1.0f - (dist / radius); - - if (frac > 0) + float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius) { - if (line != NULL) + frac = 1.0f - (dist / radius); + + if (frac > 0) { - if (P_PointOnLineSide(light->x, light->y, line) != side) + if (line != NULL) { - node = node->nextLight; - continue; + if (P_PointOnLineSide(light->x, light->y, line) != side) + { + node = node->nextLight; + continue; + } } + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) + { + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; + } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; + changed = true; } - lr = light->GetRed() / 255.0f * gl_lights_intensity; - lg = light->GetGreen() / 255.0f * gl_lights_intensity; - lb = light->GetBlue() / 255.0f * gl_lights_intensity; - if (light->IsSubtractive()) - { - float bright = FVector3(lr, lg, lb).Length(); - FVector3 lightColor(lr, lg, lb); - lr = (bright - lr) * -1; - lg = (bright - lg) * -1; - lb = (bright - lb) * -1; - } - - out[0] += lr * frac; - out[1] += lg * frac; - out[2] += lb * frac; - changed = true; } } }