private MeshNode SearchBoxInside(int boxi, Vector3 p, NNConstraint constraint) { BBTree.BBTreeBox bBTreeBox = this.arr[boxi]; if (bBTreeBox.node != null) { if (bBTreeBox.node.ContainsPoint((Int3)p)) { if (constraint == null || constraint.Suitable(bBTreeBox.node)) { return(bBTreeBox.node); } } } else { if (this.arr[bBTreeBox.left].Contains(p)) { MeshNode meshNode = this.SearchBoxInside(bBTreeBox.left, p, constraint); if (meshNode != null) { return(meshNode); } } if (this.arr[bBTreeBox.right].Contains(p)) { MeshNode meshNode = this.SearchBoxInside(bBTreeBox.right, p, constraint); if (meshNode != null) { return(meshNode); } } } return(null); }
private void SearchBox(int boxi, Vector3 p, NNConstraint constraint, ref NNInfoInternal nnInfo) { BBTree.BBTreeBox bbtreeBox = this.arr[boxi]; if (bbtreeBox.node != null) { if (bbtreeBox.node.ContainsPoint((Int3)p)) { if (nnInfo.node == null) { nnInfo.node = bbtreeBox.node; } else if (Mathf.Abs(((Vector3)bbtreeBox.node.position).y - p.y) < Mathf.Abs(((Vector3)nnInfo.node.position).y - p.y)) { nnInfo.node = bbtreeBox.node; } if (constraint.Suitable(bbtreeBox.node) && (nnInfo.constrainedNode == null || Mathf.Abs((float)bbtreeBox.node.position.y - p.y) < Mathf.Abs((float)nnInfo.constrainedNode.position.y - p.y))) { nnInfo.constrainedNode = bbtreeBox.node; } } return; } if (this.arr[bbtreeBox.left].Contains(p)) { this.SearchBox(bbtreeBox.left, p, constraint, ref nnInfo); } if (this.arr[bbtreeBox.right].Contains(p)) { this.SearchBox(bbtreeBox.right, p, constraint, ref nnInfo); } }
private void SearchBoxClosestXZ(int boxi, Vector3 p, ref float closestDist, NNConstraint constraint, ref NNInfo nnInfo) { BBTree.BBTreeBox bBTreeBox = this.arr[boxi]; if (bBTreeBox.node != null) { Vector3 constClampedPosition = bBTreeBox.node.ClosestPointOnNodeXZ(p); if (constraint == null || constraint.Suitable(bBTreeBox.node)) { float num = (constClampedPosition.x - p.x) * (constClampedPosition.x - p.x) + (constClampedPosition.z - p.z) * (constClampedPosition.z - p.z); if (nnInfo.constrainedNode == null) { nnInfo.constrainedNode = bBTreeBox.node; nnInfo.constClampedPosition = constClampedPosition; closestDist = (float)Math.Sqrt((double)num); } else if (num < closestDist * closestDist) { nnInfo.constrainedNode = bBTreeBox.node; nnInfo.constClampedPosition = constClampedPosition; closestDist = (float)Math.Sqrt((double)num); } } } else { if (BBTree.RectIntersectsCircle(this.arr[bBTreeBox.left].rect, p, closestDist)) { this.SearchBoxClosestXZ(bBTreeBox.left, p, ref closestDist, constraint, ref nnInfo); } if (BBTree.RectIntersectsCircle(this.arr[bBTreeBox.right].rect, p, closestDist)) { this.SearchBoxClosestXZ(bBTreeBox.right, p, ref closestDist, constraint, ref nnInfo); } } }
private void SearchBoxClosest(int boxi, Vector3 p, ref float closestDist, NNConstraint constraint, ref NNInfoInternal nnInfo) { BBTree.BBTreeBox bbtreeBox = this.arr[boxi]; if (bbtreeBox.node != null) { if (BBTree.NodeIntersectsCircle(bbtreeBox.node, p, closestDist)) { Vector3 vector = bbtreeBox.node.ClosestPointOnNode(p); if (constraint == null || constraint.Suitable(bbtreeBox.node)) { float sqrMagnitude = (vector - p).sqrMagnitude; if (nnInfo.constrainedNode == null || sqrMagnitude < closestDist * closestDist) { nnInfo.constrainedNode = bbtreeBox.node; nnInfo.constClampedPosition = vector; closestDist = (float)Math.Sqrt((double)sqrMagnitude); } } } } else { if (BBTree.RectIntersectsCircle(this.arr[bbtreeBox.left].rect, p, closestDist)) { this.SearchBoxClosest(bbtreeBox.left, p, ref closestDist, constraint, ref nnInfo); } if (BBTree.RectIntersectsCircle(this.arr[bbtreeBox.right].rect, p, closestDist)) { this.SearchBoxClosest(bbtreeBox.right, p, ref closestDist, constraint, ref nnInfo); } } }
private void EnsureCapacity(int c) { if (this.arr.Length < c) { BBTree.BBTreeBox[] array = new BBTree.BBTreeBox[Math.Max(c, (int)((float)this.arr.Length * 1.5f))]; for (int i = 0; i < this.count; i++) { array[i] = this.arr[i]; } this.arr = array; } }
private void OnDrawGizmos(int boxi, int depth) { BBTree.BBTreeBox bBTreeBox = this.arr[boxi]; Vector3 a = new Vector3(bBTreeBox.rect.xMin, 0f, bBTreeBox.rect.yMin); Vector3 vector = new Vector3(bBTreeBox.rect.xMax, 0f, bBTreeBox.rect.yMax); Vector3 vector2 = (a + vector) * 0.5f; Vector3 size = (vector - vector2) * 2f; vector2.y += (float)depth * 0.2f; Gizmos.color = AstarMath.IntToColor(depth, 0.05f); Gizmos.DrawCube(vector2, size); if (bBTreeBox.node == null) { this.OnDrawGizmos(bBTreeBox.left, depth + 1); this.OnDrawGizmos(bBTreeBox.right, depth + 1); } }
private void OnDrawGizmos(int boxi, int depth) { BBTree.BBTreeBox bbtreeBox = this.tree[boxi]; Vector3 a = (Vector3) new Int3(bbtreeBox.rect.xmin, 0, bbtreeBox.rect.ymin); Vector3 vector = (Vector3) new Int3(bbtreeBox.rect.xmax, 0, bbtreeBox.rect.ymax); Vector3 vector2 = (a + vector) * 0.5f; Vector3 size = (vector - vector2) * 2f; size = new Vector3(size.x, 1f, size.z); vector2.y += (float)(depth * 2); Gizmos.color = AstarMath.IntToColor(depth, 1f); Gizmos.DrawCube(vector2, size); if (!bbtreeBox.IsLeaf) { this.OnDrawGizmos(bbtreeBox.left, depth + 1); this.OnDrawGizmos(bbtreeBox.right, depth + 1); } }
private void SearchBoxCircle(int boxi, Vector3 p, float radius, NNConstraint constraint, ref NNInfo nnInfo) { BBTree.BBTreeBox bBTreeBox = this.arr[boxi]; if (bBTreeBox.node != null) { if (BBTree.NodeIntersectsCircle(bBTreeBox.node, p, radius)) { Vector3 vector = bBTreeBox.node.ClosestPointOnNode(p); float sqrMagnitude = (vector - p).sqrMagnitude; if (nnInfo.node == null) { nnInfo.node = bBTreeBox.node; nnInfo.clampedPosition = vector; } else if (sqrMagnitude < (nnInfo.clampedPosition - p).sqrMagnitude) { nnInfo.node = bBTreeBox.node; nnInfo.clampedPosition = vector; } if (constraint == null || constraint.Suitable(bBTreeBox.node)) { if (nnInfo.constrainedNode == null) { nnInfo.constrainedNode = bBTreeBox.node; nnInfo.constClampedPosition = vector; } else if (sqrMagnitude < (nnInfo.constClampedPosition - p).sqrMagnitude) { nnInfo.constrainedNode = bBTreeBox.node; nnInfo.constClampedPosition = vector; } } } return; } if (BBTree.RectIntersectsCircle(this.arr[bBTreeBox.left].rect, p, radius)) { this.SearchBoxCircle(bBTreeBox.left, p, radius, constraint, ref nnInfo); } if (BBTree.RectIntersectsCircle(this.arr[bBTreeBox.right].rect, p, radius)) { this.SearchBoxCircle(bBTreeBox.right, p, radius, constraint, ref nnInfo); } }
public void Insert(MeshNode node) { int box = this.GetBox(node); if (box == 0) { return; } BBTree.BBTreeBox bBTreeBox = this.arr[box]; int num = 0; BBTree.BBTreeBox bBTreeBox2; while (true) { bBTreeBox2 = this.arr[num]; bBTreeBox2.rect = BBTree.ExpandToContain(bBTreeBox2.rect, bBTreeBox.rect); if (bBTreeBox2.node != null) { break; } this.arr[num] = bBTreeBox2; int num2 = BBTree.ExpansionRequired(this.arr[bBTreeBox2.left].rect, bBTreeBox.rect); int num3 = BBTree.ExpansionRequired(this.arr[bBTreeBox2.right].rect, bBTreeBox.rect); if (num2 < num3) { num = bBTreeBox2.left; } else if (num3 < num2) { num = bBTreeBox2.right; } else { num = ((BBTree.RectArea(this.arr[bBTreeBox2.left].rect) >= BBTree.RectArea(this.arr[bBTreeBox2.right].rect)) ? bBTreeBox2.right : bBTreeBox2.left); } } bBTreeBox2.left = box; int box2 = this.GetBox(bBTreeBox2.node); bBTreeBox2.right = box2; bBTreeBox2.node = null; this.arr[num] = bBTreeBox2; }
// Token: 0x060025F4 RID: 9716 RVA: 0x001A3488 File Offset: 0x001A1688 private void SearchBoxClosestXZ(int boxi, Vector3 p, ref float closestSqrDist, NNConstraint constraint, ref NNInfoInternal nnInfo) { BBTree.BBTreeBox bbtreeBox = this.tree[boxi]; if (bbtreeBox.IsLeaf) { TriangleMeshNode[] array = this.nodeLookup; for (int i = 0; i < 4; i++) { if (array[bbtreeBox.nodeOffset + i] == null) { return; } TriangleMeshNode triangleMeshNode = array[bbtreeBox.nodeOffset + i]; if (constraint == null || constraint.Suitable(triangleMeshNode)) { Vector3 vector = triangleMeshNode.ClosestPointOnNodeXZ(p); float num = (vector.x - p.x) * (vector.x - p.x) + (vector.z - p.z) * (vector.z - p.z); if (nnInfo.constrainedNode == null || num < closestSqrDist - 1E-06f || (num <= closestSqrDist + 1E-06f && Mathf.Abs(vector.y - p.y) < Mathf.Abs(nnInfo.constClampedPosition.y - p.y))) { nnInfo.constrainedNode = triangleMeshNode; nnInfo.constClampedPosition = vector; closestSqrDist = num; } } } } else { int left = bbtreeBox.left; int right = bbtreeBox.right; float num2; float num3; this.GetOrderedChildren(ref left, ref right, out num2, out num3, p); if (num2 <= closestSqrDist) { this.SearchBoxClosestXZ(left, p, ref closestSqrDist, constraint, ref nnInfo); } if (num3 <= closestSqrDist) { this.SearchBoxClosestXZ(right, p, ref closestSqrDist, constraint, ref nnInfo); } } }
private TriangleMeshNode SearchBoxInside(int boxi, Vector3 p, NNConstraint constraint) { BBTree.BBTreeBox bbtreeBox = this.tree[boxi]; if (bbtreeBox.IsLeaf) { TriangleMeshNode[] array = this.nodeLookup; int num = 0; while (num < 4 && array[bbtreeBox.nodeOffset + num] != null) { TriangleMeshNode triangleMeshNode = array[bbtreeBox.nodeOffset + num]; if (triangleMeshNode.ContainsPoint((Int3)p)) { if (constraint == null || constraint.Suitable(triangleMeshNode)) { return(triangleMeshNode); } } num++; } } else { if (this.tree[bbtreeBox.left].Contains(p)) { TriangleMeshNode triangleMeshNode2 = this.SearchBoxInside(bbtreeBox.left, p, constraint); if (triangleMeshNode2 != null) { return(triangleMeshNode2); } } if (this.tree[bbtreeBox.right].Contains(p)) { TriangleMeshNode triangleMeshNode3 = this.SearchBoxInside(bbtreeBox.right, p, constraint); if (triangleMeshNode3 != null) { return(triangleMeshNode3); } } } return(null); }
private void SearchBoxClosest(int boxi, Vector3 p, ref float closestSqrDist, NNConstraint constraint, ref NNInfoInternal nnInfo) { BBTree.BBTreeBox bbtreeBox = this.tree[boxi]; if (bbtreeBox.IsLeaf) { TriangleMeshNode[] array = this.nodeLookup; int num = 0; while (num < 4 && array[bbtreeBox.nodeOffset + num] != null) { TriangleMeshNode triangleMeshNode = array[bbtreeBox.nodeOffset + num]; Vector3 vector = triangleMeshNode.ClosestPointOnNode(p); float sqrMagnitude = (vector - p).sqrMagnitude; if (sqrMagnitude < closestSqrDist) { if (constraint == null || constraint.Suitable(triangleMeshNode)) { nnInfo.constrainedNode = triangleMeshNode; nnInfo.constClampedPosition = vector; closestSqrDist = sqrMagnitude; } } num++; } } else { int left = bbtreeBox.left; int right = bbtreeBox.right; float num2; float num3; this.GetOrderedChildren(ref left, ref right, out num2, out num3, p); if (num2 < closestSqrDist) { this.SearchBoxClosest(left, p, ref closestSqrDist, constraint, ref nnInfo); } if (num3 < closestSqrDist) { this.SearchBoxClosest(right, p, ref closestSqrDist, constraint, ref nnInfo); } } }
private void SearchBoxClosestXZ(int boxi, Vector3 p, ref float closestSqrDist, NNConstraint constraint, ref NNInfoInternal nnInfo) { BBTree.BBTreeBox bbtreeBox = this.tree[boxi]; if (bbtreeBox.IsLeaf) { TriangleMeshNode[] array = this.nodeLookup; int num = 0; while (num < 4 && array[bbtreeBox.nodeOffset + num] != null) { TriangleMeshNode triangleMeshNode = array[bbtreeBox.nodeOffset + num]; if (constraint == null || constraint.Suitable(triangleMeshNode)) { Vector3 constClampedPosition = triangleMeshNode.ClosestPointOnNodeXZ(p); float num2 = (constClampedPosition.x - p.x) * (constClampedPosition.x - p.x) + (constClampedPosition.z - p.z) * (constClampedPosition.z - p.z); if (nnInfo.constrainedNode == null || num2 < closestSqrDist - 1E-06f || (num2 <= closestSqrDist + 1E-06f && Mathf.Abs(constClampedPosition.y - p.y) < Mathf.Abs(nnInfo.constClampedPosition.y - p.y))) { nnInfo.constrainedNode = triangleMeshNode; nnInfo.constClampedPosition = constClampedPosition; closestSqrDist = num2; } } num++; } } else { int left = bbtreeBox.left; int right = bbtreeBox.right; float num3; float num4; this.GetOrderedChildren(ref left, ref right, out num3, out num4, p); if (num3 <= closestSqrDist) { this.SearchBoxClosestXZ(left, p, ref closestSqrDist, constraint, ref nnInfo); } if (num4 <= closestSqrDist) { this.SearchBoxClosestXZ(right, p, ref closestSqrDist, constraint, ref nnInfo); } } }
private void OnDrawGizmos(int boxi, int depth) { BBTree.BBTreeBox bbtreeBox = this.arr[boxi]; Vector3 vector; vector..ctor(bbtreeBox.rect.xMin, 0f, bbtreeBox.rect.yMin); Vector3 vector2; vector2..ctor(bbtreeBox.rect.xMax, 0f, bbtreeBox.rect.yMax); Vector3 vector3 = (vector + vector2) * 0.5f; Vector3 vector4 = (vector2 - vector3) * 2f; vector3.y += (float)depth * 0.2f; Gizmos.color = AstarMath.IntToColor(depth, 0.05f); Gizmos.DrawCube(vector3, vector4); if (bbtreeBox.node == null) { this.OnDrawGizmos(bbtreeBox.left, depth + 1); this.OnDrawGizmos(bbtreeBox.right, depth + 1); } }
// Token: 0x060025F9 RID: 9721 RVA: 0x001A379C File Offset: 0x001A199C private TriangleMeshNode SearchBoxInside(int boxi, Vector3 p, NNConstraint constraint) { BBTree.BBTreeBox bbtreeBox = this.tree[boxi]; if (bbtreeBox.IsLeaf) { TriangleMeshNode[] array = this.nodeLookup; for (int i = 0; i < 4; i++) { if (array[bbtreeBox.nodeOffset + i] == null) { break; } TriangleMeshNode triangleMeshNode = array[bbtreeBox.nodeOffset + i]; if (triangleMeshNode.ContainsPoint((Int3)p) && (constraint == null || constraint.Suitable(triangleMeshNode))) { return(triangleMeshNode); } } } else { if (this.tree[bbtreeBox.left].Contains(p)) { TriangleMeshNode triangleMeshNode2 = this.SearchBoxInside(bbtreeBox.left, p, constraint); if (triangleMeshNode2 != null) { return(triangleMeshNode2); } } if (this.tree[bbtreeBox.right].Contains(p)) { TriangleMeshNode triangleMeshNode3 = this.SearchBoxInside(bbtreeBox.right, p, constraint); if (triangleMeshNode3 != null) { return(triangleMeshNode3); } } } return(null); }