summaryrefslogtreecommitdiff
path: root/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Graphs/Grid/Jobs/JobMergeRaycastCollisionHits.cs
blob: 61707ddfdd3f22ecb69df19507a6eb16179cedb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
			}
		}
	}
}