diff options
| author | chai <215380520@qq.com> | 2024-05-23 10:08:29 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-23 10:08:29 +0800 |
| commit | 8722a9920c1f6119bf6e769cba270e63097f8e25 (patch) | |
| tree | 2eaf9865de7fb1404546de4a4296553d8f68cc3b /Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs | |
| parent | 3ba4020b69e5971bb0df7ee08b31d10ea4d01937 (diff) | |
+ astar project
Diffstat (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs')
| -rw-r--r-- | Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs new file mode 100644 index 0000000..61707dd --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using Unity.Burst; +using Unity.Collections; +using Unity.Jobs; + +namespace Pathfinding.Graphs.Grid.Jobs { + /// <summary> + /// Calculates if either of the two input hits actually hit something. + /// + /// result[i] = true if hit1[i] or hit2[i] is a valid hit. + /// + /// A valid hit will always have a non-zero normal. + /// </summary> + [BurstCompile] + public struct JobMergeRaycastCollisionHits : IJob { + [ReadOnly] + public NativeArray<RaycastHit> hit1; + + [ReadOnly] + public NativeArray<RaycastHit> hit2; + + [WriteOnly] + public NativeArray<bool> result; + + public void Execute () { + for (int i = 0; i < hit1.Length; i++) { + result[i] = hit1[i].normal == Vector3.zero && hit2[i].normal == Vector3.zero; + } + } + } +} |
