long QueryInterval() { stopwatch.Reset(); stopwatch.Start(); Vector3 randOffset = Random.insideUnitSphere * 0.25f; Vector3 min = Vector3.one * 0.25f + Random.insideUnitSphere * 0.25f + randOffset; Vector3 max = Vector3.one * 0.75f + Random.insideUnitSphere * 0.25f + randOffset; results.Clear(); query.Interval(tree, min, max, results); stopwatch.Stop(); return(stopwatch.ElapsedMilliseconds); }
private void OnDrawGizmos() { if (query == null) { return; } Vector3 size = 0.2f * Vector3.one; for (int i = 0; i < points.Length; i++) { Gizmos.DrawCube(points[i].transform.position, size); } var resultIndices = new List <int>(); Color markColor = Color.red; markColor.a = 0.5f; Gizmos.color = markColor; switch (QueryType) { case QType.ClosestPoint: { query.ClosestPoint(tree, transform.position, resultIndices); } break; case QType.KNearest: { query.KNearest(tree, transform.position, K, resultIndices); } break; case QType.Radius: { query.Radius(tree, transform.position, Radius, 0, resultIndices); Gizmos.DrawWireSphere(transform.position, Radius); } break; case QType.Interval: { query.Interval(tree, transform.position - IntervalSize / 2f, transform.position + IntervalSize / 2f, resultIndices); Gizmos.DrawWireCube(transform.position, IntervalSize); } break; default: break; } for (int i = 0; i < resultIndices.Count; i++) { Gizmos.DrawCube(points[resultIndices[i]].transform.position, 2f * size); } Gizmos.color = Color.green; Gizmos.DrawCube(transform.position, 4f * size); if (DrawQueryNodes) { query.DrawLastQuery(); } }