From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:08:29 +0800 Subject: + astar project --- .../Graphs/Grid/Jobs/JobColliderHitsToBooleans.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobColliderHitsToBooleans.cs (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobColliderHitsToBooleans.cs') diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobColliderHitsToBooleans.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobColliderHitsToBooleans.cs new file mode 100644 index 0000000..84ae59e --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobColliderHitsToBooleans.cs @@ -0,0 +1,28 @@ +#if UNITY_2022_2_OR_NEWER +using UnityEngine; +using Unity.Burst; +using Unity.Collections; +using Unity.Jobs; + +namespace Pathfinding.Graphs.Grid.Jobs { + /// + /// Fills the output with true or false depending on if the collider hit was a hit. + /// + /// result[i] = false if hits[i] is a valid hit, otherwise true. + /// + [BurstCompile] + public struct JobColliderHitsToBooleans : IJob { + [ReadOnly] + public NativeArray hits; + + [WriteOnly] + public NativeArray result; + + public void Execute () { + for (int i = 0; i < hits.Length; i++) { + result[i] = hits[i].instanceID == 0; + } + } + } +} +#endif -- cgit v1.1-26-g67d0