public static unsafe (PathStatus PathStatus, List <GridNode> NodePath, List <Vector3> VectorPath) Complete(BurstAStarPathFinder pathFinder, ref NativeArray3D <GridNode> grid, INativeArrayProducer <NativeAreaDefinition> areas, int queryId, GridPoint start, GridPoint end, ulong allowedFlags, float4x4 localToWorld) { using (var nativeAreas = areas.ToNativeArray(Allocator.TempJob)) using (var nativePath = new NativeList <GridNode>(grid.Length, Allocator.TempJob)) using (var nativeVectorPath = new NativeList <Vector3>(grid.Length, Allocator.TempJob)) using (var nativePriorityQueue = new NativePriorityQueue(grid.Length / 8, Allocator.TempJob)) { var result = new PathFindingJobResult(); var job = new PathFindingJob { QueryId = queryId, AllowedFlags = allowedFlags, StartPoint = start, EndPoint = end, OpenQueue = nativePriorityQueue, Grid = grid, Areas = nativeAreas, Path = nativePath, MaxPoints = 5000, WorldPath = nativeVectorPath, TransformMatrix = localToWorld, ResultPtr = &result }; pathFinder.Stopwatch.Restart(); job.Run(); pathFinder.Stopwatch.Stop(); var path = job.Path.ToArray().ToList(); var worldPath = nativeVectorPath.ToArray().ToList(); return(result.PathStatus, path, worldPath); } }
public BurstAStarPathFinder GetPath(GridNode from, GridNode to) { Id = _random.Next(1, int.MaxValue); var jobResult = PathFindingJob.Complete(this, ref Grid.InnerGrid, Areas, Id, from.GridPoint, to.GridPoint, AllowFlags, Grid.Transform.ToWorldMatrix); Status = jobResult.PathStatus; NodePath = jobResult.NodePath; Path = jobResult.VectorPath; return(this); }