From 139f501ec5ca0cd05fc0301519471fe53bcafbbe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 15:41:42 +0200 Subject: [PATCH] - run the dynamic light recreation loop before calling the light ticker. This was done afterward which performed some needed cleanup too late. --- src/p_tick.cpp | 16 ---------------- src/playsim/dthinker.cpp | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 7253eafbe..2889a06a5 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -175,22 +175,6 @@ void P_Ticker (void) { P_UpdateSpecials(Level); } - it = Level->GetThinkerIterator(); - - // 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++; diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 0c8e687f1..75c75e789 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -107,6 +107,25 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) ThinkCycles.Clock(); + auto recreateLights = [=]() { + auto it = Level->GetThinkerIterator(); + + // 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 @@ -127,6 +146,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) if (Level->HasDynamicLights) { + recreateLights(); for (auto light = Level->lights; light;) { auto next = light->next; @@ -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();