Are mutexes needed for writes to and reads from Native data types, especially those used in IJobParallelFor? Something like in this:
[BurstCompile]
private struct FilterJob : IJobParallelFor
{
public NativeArray<Vector3> currentStarts ;
public NativeHashMap<int, int> remaining;
public NativeArray<RaycastHit> results;
public NativeMultiHashMap<int, RaycastHit> allHits;
public NativeArray<Vector3> ends;
public void Execute(int index)
{
int value = 0;
if (remaining.TryGetValue(index, out value))
{
RaycastHit hit = results[index];
if(hit.point == default(Vector3))
{
remaining.Remove(index);
}
else
{
allHits.Add(index, hit);
currentStarts[index] = results[index].point + (ends[index] - currentStarts[index]).normalized * 0.1f;
}
}
}
}