Skip to content

Commit

Permalink
- fixed one frame activation delay for dynamic lights.
Browse files Browse the repository at this point in the history
We cannot check HasDynamicLights in ProcessThinkers because it gets set too late.
  • Loading branch information
coelckers committed Sep 21, 2021
1 parent 6c12a8d commit 702b75e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/playsim/dthinker.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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>();

Expand Down Expand Up @@ -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;)
{
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 702b75e

Please sign in to comment.