Skip to content

Commit 05e1187

Browse files
committed
less aggressive fix that also improves worst-case performance by delaying see rays by one frame instead
1 parent bb33ed0 commit 05e1187

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Source/Managers/MovableMan.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "Controller.h"
1313
#include "AtomGroup.h"
1414
#include "Actor.h"
15-
#include "HeldDevice.h"
1615
#include "ADoor.h"
1716
#include "Atom.h"
1817
#include "Scene.h"
@@ -1314,6 +1313,9 @@ void MovableMan::Update() {
13141313
g_SceneMan.GetScene()->BlockUntilAllPathingRequestsComplete();
13151314
}
13161315

1316+
// Finish our Seeing rays from last frame
1317+
m_ActorsSeeFuture.wait();
1318+
13171319
// Prior to controller/AI update, execute lua callbacks
13181320
g_LuaMan.ExecuteLuaScriptCallbacks();
13191321

@@ -1395,18 +1397,6 @@ void MovableMan::Update() {
13951397
g_PerformanceMan.StopPerformanceMeasurement(PerformanceMan::ScriptsUpdate);
13961398

13971399
{
1398-
auto actorsSeeFuture = g_ThreadMan.GetPriorityThreadPool().parallelize_loop(m_Actors.size(),
1399-
[&](int start, int end) {
1400-
ZoneScopedN("Actors See");
1401-
for (int i = start; i < end; ++i) {
1402-
m_Actors[i]->CastSeeRays();
1403-
}
1404-
});
1405-
1406-
// TODO- right now RemoveActor just removes to actor directly (instead of setting it disabled and delaying the actual remoal), meaning that actorsSeeFuture must be finished immediately
1407-
// This isn't ideal, as we'd prefer to be able to run the actor/items/particle update in parallel
1408-
actorsSeeFuture.wait();
1409-
14101400
{
14111401
ZoneScopedN("Actors Update");
14121402

@@ -1478,9 +1468,6 @@ void MovableMan::Update() {
14781468
particle->PostUpdate();
14791469
}
14801470
}
1481-
1482-
// See above TODO - this is only commented out because of how RemoveActor currently works
1483-
//actorsSeeFuture.wait();
14841471
} // namespace RTE
14851472

14861473
//////////////////////////////////////////////////////////////////////
@@ -1680,6 +1667,15 @@ void MovableMan::Update() {
16801667
}
16811668
}
16821669

1670+
// Run seeing rays for all actors
1671+
m_ActorsSeeFuture = g_ThreadMan.GetPriorityThreadPool().parallelize_loop(m_Actors.size(),
1672+
[&](int start, int end) {
1673+
ZoneScopedN("Actors See");
1674+
for (int i = start; i < end; ++i) {
1675+
m_Actors[i]->CastSeeRays();
1676+
}
1677+
});
1678+
16831679
// We've finished stuff that can interact with lua script, so it's the ideal time to start a gc run
16841680
g_LuaMan.StartAsyncGarbageCollection();
16851681

Source/Managers/MovableMan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "Singleton.h"
1010
#include "Activity.h"
1111

12+
#include "BS_thread_pool.hpp"
13+
1214
#include <mutex>
1315
#include <map>
1416
#include <future>
@@ -596,6 +598,9 @@ namespace RTE {
596598
// Async to draw MOIDs while rendering
597599
std::future<void> m_DrawMOIDsTask;
598600

601+
// Async to have actors see in parallel
602+
BS::multi_future<void> m_ActorsSeeFuture;
603+
599604
// Roster of each team's actors, sorted by their X positions in the scene. Actors not owned here
600605
std::list<Actor*> m_ActorRoster[Activity::MaxTeamCount];
601606
// Whether to draw HUD lines between the actors of a specific team

0 commit comments

Comments
 (0)