/// <summary> /// Rebuilds the lookup structure for nodes. /// /// This is used when <see cref="optimizeForSparseGraph"/> is enabled. /// /// You should call this method every time you move a node in the graph manually and /// you are using <see cref="optimizeForSparseGraph"/>, otherwise pathfinding might not work correctly. /// /// You may also call this after you have added many nodes using the /// <see cref="AddNode"/> method. When adding nodes using the <see cref="AddNode"/> method they /// will be added to the lookup structure. The lookup structure will /// rebalance itself when it gets too unbalanced however if you are /// sure you won't be adding any more nodes in the short term, you can /// make sure it is perfectly balanced and thus squeeze out the last /// bit of performance by calling this method. This can improve the /// performance of the <see cref="GetNearest"/> method slightly. The improvements /// are on the order of 10-20%. /// </summary> public void RebuildNodeLookup() { if (!optimizeForSparseGraph || nodes == null) { lookupTree = new PointKDTree(); } else { lookupTree.Rebuild(nodes, 0, nodeCount); } }
// Token: 0x060025B9 RID: 9657 RVA: 0x001A1748 File Offset: 0x0019F948 public void RebuildNodeLookup() { if (!this.optimizeForSparseGraph || this.nodes == null) { this.lookupTree = new PointKDTree(); return; } PointKDTree pointKDTree = this.lookupTree; GraphNode[] array = this.nodes; pointKDTree.Rebuild(array, 0, this.nodeCount); }
private void Add(GraphNode point, int index, int depth = 0) { while (this.tree[index].data == null) { index = 2 * index + ((point.position[(int)this.tree[index].splitAxis] >= this.tree[index].split) ? 1 : 0); depth++; } this.tree[index].data.Add(point); if (this.tree[index].data.Count > PointKDTree.LeafSize * 2) { int num = 0; while (depth - num > 0 && this.Size(index >> num) > PointKDTree.MaxAllowedSize(this.numNodes, depth - num)) { num++; } this.Rebalance(index >> num); } }
// Token: 0x06002676 RID: 9846 RVA: 0x001AAC1C File Offset: 0x001A8E1C private void Add(GraphNode point, int index, int depth = 0) { while (this.tree[index].data == null) { index = 2 * index + ((point.position[(int)this.tree[index].splitAxis] < this.tree[index].split) ? 0 : 1); depth++; } GraphNode[] data = this.tree[index].data; PointKDTree.Node[] array = this.tree; int num = index; ushort count = array[num].count; array[num].count = count + 1; data[(int)count] = point; if (this.tree[index].count >= 21) { int num2 = 0; while (depth - num2 > 0 && this.Size(index >> num2) > PointKDTree.MaxAllowedSize(this.numNodes, depth - num2)) { num2++; } this.Rebalance(index >> num2); } }