Pathfinder parallel change (#18736)
This commit is contained in:
@@ -84,7 +84,7 @@ public sealed partial class PathfindingSystem
|
||||
component.Chunks.Clear();
|
||||
}
|
||||
|
||||
private void UpdateGrid()
|
||||
private void UpdateGrid(ParallelOptions options)
|
||||
{
|
||||
if (PauseUpdating)
|
||||
return;
|
||||
@@ -94,10 +94,6 @@ public sealed partial class PathfindingSystem
|
||||
var updateCount = 0;
|
||||
#endif
|
||||
_stopwatch.Restart();
|
||||
var options = new ParallelOptions()
|
||||
{
|
||||
MaxDegreeOfParallelism = 1,
|
||||
};
|
||||
|
||||
// We defer chunk updates because rebuilding a navmesh is hella costly
|
||||
// Still run even when paused.
|
||||
@@ -157,10 +153,9 @@ public sealed partial class PathfindingSystem
|
||||
var doorQuery = GetEntityQuery<DoorComponent>();
|
||||
var climbableQuery = GetEntityQuery<ClimbableComponent>();
|
||||
var fixturesQuery = GetEntityQuery<FixturesComponent>();
|
||||
var physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
BuildBreadcrumbs(dirt[i], mapGridComp, accessQuery, destructibleQuery, doorQuery, climbableQuery,
|
||||
fixturesQuery, physicsQuery, xformQuery);
|
||||
fixturesQuery, xformQuery);
|
||||
});
|
||||
|
||||
const int Division = 4;
|
||||
@@ -427,7 +422,6 @@ public sealed partial class PathfindingSystem
|
||||
EntityQuery<DoorComponent> doorQuery,
|
||||
EntityQuery<ClimbableComponent> climbableQuery,
|
||||
EntityQuery<FixturesComponent> fixturesQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
EntityQuery<TransformComponent> xformQuery)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
|
||||
@@ -85,12 +85,18 @@ namespace Content.Server.NPC.Pathfinding
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
UpdateGrid();
|
||||
var options = new ParallelOptions()
|
||||
{
|
||||
MaxDegreeOfParallelism = _parallel.ParallelProcessCount,
|
||||
};
|
||||
|
||||
UpdateGrid(options);
|
||||
_stopwatch.Restart();
|
||||
var amount = Math.Min(PathTickLimit, _pathRequests.Count);
|
||||
var results = ArrayPool<PathResult>.Shared.Rent(amount);
|
||||
|
||||
Parallel.For(0, amount, i =>
|
||||
|
||||
Parallel.For(0, amount, options, i =>
|
||||
{
|
||||
// If we're over the limit (either time-sliced or hard cap).
|
||||
if (_stopwatch.Elapsed >= PathTime)
|
||||
|
||||
@@ -254,7 +254,7 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem
|
||||
// Dependency issues across threads.
|
||||
var options = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = _parallel.ParallelProcessCount,
|
||||
MaxDegreeOfParallelism = 1,
|
||||
};
|
||||
var curTime = _timing.CurTime;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user