- fixed one frame activation delay for dynamic lights.

We cannot check HasDynamicLights in ProcessThinkers because it gets set too late.
This commit is contained in:
Christoph Oelckers 2021-09-21 20:43:21 +02:00
parent 6c12a8de12
commit 702b75e96a

View file

@ -43,7 +43,8 @@
#include "g_levellocals.h"
#include "a_dynlight.h"
#include "v_video.h"
#include "g_cvars.h"
#include "d_main.h"
static int ThinkCount;
static cycle_t ThinkCycles;
@ -107,6 +108,18 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
ThinkCycles.Clock();
bool dolights;
if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4))
{
dolights = Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED);
}
else
{
dolights = false;
}
Level->flags3 &= ~LEVEL3_LIGHTCREATED;
auto recreateLights = [=]() {
auto it = Level->GetThinkerIterator<AActor>();
@ -144,9 +157,8 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
}
} while (count != 0);
if (Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED))
if (dolights)
{
Level->flags3 &= ~LEVEL3_LIGHTCREATED;
recreateLights();
for (auto light = Level->lights; light;)
{
@ -175,9 +187,8 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
}
} while (count != 0);
if (Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED))
if (dolights)
{
Level->flags3 &= ~LEVEL3_LIGHTCREATED;
recreateLights();
// Also profile the internal dynamic lights, even though they are not implemented as thinkers.
auto &prof = Profiles[NAME_InternalDynamicLight];