void DrawBVHBoundsBFS(BVHNode root) { nodeQueue.Clear(); nodeQueue.Enqueue(root); nodeQueue.Enqueue(null); int depth = 0; int nodeCount = 0; while (nodeQueue.Count != 0 && depth < maxDepth) { BVHNode node = nodeQueue.Dequeue(); if (node == null) { if (nodeQueue.Count == 0) { break; } depth++; nodeQueue.Enqueue(null); continue; } Random.InitState(depth); Gizmos.color = new Color(Random.value, Random.value, Random.value, 0.2f); Gizmos.DrawCube(node.bounds.Center, node.bounds.max - node.bounds.min); if (node.GetChildNode(0) != null) { nodeQueue.Enqueue(node.GetChildNode(0)); } if (node.GetChildNode(1) != null) { nodeQueue.Enqueue(node.GetChildNode(1)); } if (node.IsLeaf()) { nodeCount++; } } //Debug.LogError("nodeCount = " + nodeCount); }