private void SearchDistance(P3D_Node node, Vector3 point, float maxDistanceSqr) { // Is the node bound in range? if (node.Bound.SqrDistance(point) < maxDistanceSqr) { if (node.Split == true) { if (node.PositiveIndex != 0) { SearchDistance(nodes[node.PositiveIndex], point, maxDistanceSqr); } if (node.NegativeIndex != 0) { SearchDistance(nodes[node.NegativeIndex], point, maxDistanceSqr); } } else { AddToPotentials(node); } } }
private void Pack(P3D_Node node, int min, int max) { int num = max - min; node.TriangleIndex = min; node.TriangleCount = num; node.Split = num >= 5; node.CalculateBound(this.triangles); if (node.Split) { int num2 = (min + max) / 2; this.SortTriangles(min, max); node.PositiveIndex = this.nodes.Count; P3D_Node item = P3D_Node.Spawn(); this.nodes.Add(item); this.Pack(item, min, num2); node.NegativeIndex = this.nodes.Count; P3D_Node node3 = P3D_Node.Spawn(); this.nodes.Add(node3); this.Pack(node3, num2, max); } }
private void SearchBetween(P3D_Node node, Ray ray, float maxDistance) { float distance = 0f; if (node.Bound.IntersectRay(ray, out distance) && (distance <= maxDistance)) { if (!node.Split) { this.AddToPotentials(node); } else { if (node.PositiveIndex != 0) { this.SearchBetween(this.nodes[node.PositiveIndex], ray, maxDistance); } if (node.NegativeIndex != 0) { this.SearchBetween(this.nodes[node.NegativeIndex], ray, maxDistance); } } } }
private void SearchBetween(P3D_Node node, Ray ray, float maxDistance) { // Does ray hit the node bound? var distance = default(float); if (node.Bound.IntersectRay(ray, out distance) == true && distance <= maxDistance) { if (node.Split == true) { if (node.PositiveIndex != 0) { SearchBetween(nodes[node.PositiveIndex], ray, maxDistance); } if (node.NegativeIndex != 0) { SearchBetween(nodes[node.NegativeIndex], ray, maxDistance); } } else { AddToPotentials(node); } } }