- fixed the disabled visibility rules check for dynamic lights by doing the actual check in the light's Tick() method and letting the renderer only use the result.

This commit is contained in:
Christoph Oelckers 2016-05-04 11:33:18 +02:00
parent 0a94371974
commit ab8a647433
4 changed files with 44 additions and 46 deletions

View file

@ -392,7 +392,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt,
{
return false;
}
if (light->owned && light->target != NULL && !light->target->IsVisibleToPlayer())
if (!light->visibletoplayer)
{
return false;
}

View file

@ -160,6 +160,7 @@ void ADynamicLight::BeginPlay()
m_Radius[0] = args[LIGHT_INTENSITY];
m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY];
visibletoplayer = true;
}
//==========================================================================
@ -237,6 +238,7 @@ void ADynamicLight::Tick()
return;
}
if (target->flags & MF_UNMORPHED) return;
visibletoplayer = target->IsVisibleToPlayer(); // cache this value for the renderer to speed up calculations.
}
// Don't bother if the light won't be shown

View file

@ -116,6 +116,7 @@ public:
bool owned;
bool halo;
BYTE color2[3];
bool visibletoplayer;
int bufferindex;
// intermediate texture coordinate data

View file

@ -75,10 +75,7 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
while (node)
{
light=node->lightsource;
//if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer())
{
if (!(light->flags2&MF2_DORMANT) &&
(!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self))
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self))
{
float dist;
@ -98,14 +95,13 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
direct:
dist = FVector3(x - light->X(), y - light->Y(), z - light->Z()).LengthSquared();
}
// This is to avoid calling the software-implemented sqrt function which gets used by FVector3::Length().
// With fast math on in this module this call will be mapped to a machine instruction on most platforms.
dist = sqrtf(dist);
radius = light->GetRadius() * gl_lights_size;
if (dist < radius)
if (dist < radius * radius)
{
dist = sqrtf(dist); // only calculate the square root if we really need it.
frac = 1.0f - (dist / radius);
if (frac > 0)
@ -128,7 +124,6 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
}
}
}
}
node = node->nextLight;
}
gl_RenderState.SetDynLight(out[0], out[1], out[2]);