Skip to content

Commit

Permalink
- run the dynamic light recreation loop before calling the light ticker.
Browse files Browse the repository at this point in the history
This was done afterward which performed some needed cleanup too late.
  • Loading branch information
coelckers committed Aug 11, 2021
1 parent 1097bd6 commit 139f501
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/p_tick.cpp
Expand Up @@ -175,22 +175,6 @@ void P_Ticker (void)
{
P_UpdateSpecials(Level);
}
it = Level->GetThinkerIterator<AActor>();

// Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame.
while ((ac = it.Next()))
{
if (ac->flags8 & MF8_RECREATELIGHTS)
{
ac->flags8 &= ~MF8_RECREATELIGHTS;
ac->SetDynamicLights();
}
// This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop.
if ((ac->effects || ac->fountaincolor) && !Level->isFrozen())
{
P_RunEffect(ac, ac->effects);
}
}

// for par times
Level->time++;
Expand Down
21 changes: 21 additions & 0 deletions src/playsim/dthinker.cpp
Expand Up @@ -107,6 +107,25 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)

ThinkCycles.Clock();

auto recreateLights = [=]() {
auto it = Level->GetThinkerIterator<AActor>();

// Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame.
while (auto ac = it.Next())
{
if (ac->flags8 & MF8_RECREATELIGHTS)
{
ac->flags8 &= ~MF8_RECREATELIGHTS;
ac->SetDynamicLights();
}
// This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop.
if ((ac->effects || ac->fountaincolor) && !Level->isFrozen())
{
P_RunEffect(ac, ac->effects);
}
}
};

if (!profilethinkers)
{
// Tick every thinker left from last time
Expand All @@ -127,6 +146,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)

if (Level->HasDynamicLights)
{
recreateLights();
for (auto light = Level->lights; light;)
{
auto next = light->next;
Expand Down Expand Up @@ -156,6 +176,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)

if (Level->lights && Level->HasDynamicLights)
{
recreateLights();
// Also profile the internal dynamic lights, even though they are not implemented as thinkers.
auto &prof = Profiles[NAME_InternalDynamicLight];
prof.timer.Clock();
Expand Down

0 comments on commit 139f501

Please sign in to comment.