// TODO: make SIMD public void DistanceQuery(DistanceQueryInput query, NativeList <int> results) { float maxDistanceSqrd = query.maxDistance * query.maxDistance; var stack = stackalloc int[256]; stack[0] = rootIndex[0]; var top = 1; while (top > 0) { var index = stack[--top]; var node = nodes[index]; if (!IntersectionUtils.IsInRange(node->box.LowerBound, node->box.UpperBound, query.origin, maxDistanceSqrd)) { continue; } if (node->isLeaf) { if ((query.layerMask & node->leaf.layer) == 0 && DoDistanceQuery(query, ref node->leaf)) { results.Add(index); } } else { stack[top++] = node->child1; stack[top++] = node->child2; } } }
public bool DistanceQuery(NativeBVHTree.DistanceQueryInput query) { return(IntersectionUtils.IsInRange(LowerBound, UpperBound, query.origin, query.maxDistance)); }