public static BVHNode CombineAllBoxesAndPrimitives(List <RTBoundingBox> boxes) { BVHNode node = new BVHNode(); node.bounding = CombineAllBox(boxes); node.children = boxes; return(node); }
public void OnDrawGizmos() { if (meshBVH != null) { meshBVH.BuildBVHAndTriangleList(meshBVH.GetTrianglesVertexOrder(), meshBVH.GetVertices()); } BVHNode root = Root(); if (root == null) { return; } Queue <BVHNode> bfs = new Queue <BVHNode>(); Queue <int> depthQ = new Queue <int>(); bfs.Enqueue(root); depthQ.Enqueue(0); while (bfs.Count > 0) { var node = bfs.Dequeue(); var depth = depthQ.Dequeue(); if (!allLevel && depth > level) { break; } if (allLevel || depth == level) { Gizmos.color = Rainbow(depth); Gizmos.DrawWireCube(node.bounding.center, node.bounding.size); } if (node.left != null) { bfs.Enqueue(node.left); depthQ.Enqueue(depth + 1); } if (node.right != null) { bfs.Enqueue(node.right); depthQ.Enqueue(depth + 1); } } }
public void OnDrawGizmos() { if (!isActiveAndEnabled) { return; } if (refresh) { refresh = false; if (showTopLevelBVH) { SceneParser.Instance.ParseScene(SceneManager.GetActiveScene()); } else { if (meshBVH != null) { meshBVH.BuildBVHAndTriangleList(meshBVH.GetNormals(), meshBVH.GetTrianglesVertexOrder(0), meshBVH.GetVertices()); } } } BVHNode root = Root(); if (root == null) { return; } Queue <BVHNode> bfs = new Queue <BVHNode>(); Queue <int> depthQ = new Queue <int>(); bfs.Enqueue(root); depthQ.Enqueue(0); while (bfs.Count > 0) { var node = bfs.Dequeue(); var depth = depthQ.Dequeue(); if (!allLevel && depth > level) { break; } if (allLevel || depth == level) { Gizmos.color = Rainbow(depth); Gizmos.DrawWireCube(node.bounding.center, node.bounding.size); Gizmos.DrawSphere(node.bounding.center, 0.1f); } if (node.left != null) { bfs.Enqueue(node.left); depthQ.Enqueue(depth + 1); } if (node.right != null) { bfs.Enqueue(node.right); depthQ.Enqueue(depth + 1); } } }