public void Execute() { KDTree.KDTreeHeader header = headerForJobs[0]; Debug.Assert(KDTree.Capacity(ref header, ref data) >= (header.count + positions.Length)); for (int i = 0, iLen = positions.Length; i < iLen; ++i) { float3 position = positions[i]; float radius = radii[i]; bool added = KDTree.TryAdd(ref header, ref data, i, position, radius); if (!added) { // WARNING: Working around a burst compilation bug here. // Previously I simply had this code, with no if statement: // Debug.Assert(added); // It looks like if we do not operate on this 'added' variable, it is stripped out in release mode, // which seems to make my assert silently fail, and causes nothing to be added to the KDTree. // By branching here, it forces the compiler to keep the 'added' variable around. Debug.Assert(false); break; } } headerForJobs[0] = header; }
public void Execute(int queryPositionIndex) { float3 queryPosition = queryPositions[queryPositionIndex]; KDTree.KDTreeHeader header = headerForJobs[0]; KDTree.FindNearestNeighbor(out int index, out float distanceSquared, ref header, ref data, queryPosition); resIndices[queryPositionIndex] = (index >= 0) ? data.payloadIndices[index] : -1; resDistances[queryPositionIndex] = (distanceSquared > 1e-5f) ? math.sqrt(distanceSquared) : 0.0f; }
public void Execute() { KDTree.KDTreeHeader header = headerForJobs[0]; KDTree.Build(ref header, ref data, depthCount); headerForJobs[0] = header; }