public void CreateNodeRec(QuadtreeNodeHolder holder, int depth, int x, int y) { int num = 1 << Math.Min(this.editorHeightLog2, this.editorWidthLog2) - depth; int num2; if (depth < this.minDepth) { num2 = -1; } else { num2 = this.CheckNode(x, y, num); } if (num2 == 1 || num2 == 0 || num == 1) { QuadtreeNode quadtreeNode = new QuadtreeNode(this.active); quadtreeNode.SetPosition((Int3)this.LocalToWorldPosition(x, y, num)); quadtreeNode.Walkable = (num2 == 1); holder.node = quadtreeNode; } else { holder.c0 = new QuadtreeNodeHolder(); holder.c1 = new QuadtreeNodeHolder(); holder.c2 = new QuadtreeNodeHolder(); holder.c3 = new QuadtreeNodeHolder(); this.CreateNodeRec(holder.c0, depth + 1, x, y); this.CreateNodeRec(holder.c1, depth + 1, x + num / 2, y); this.CreateNodeRec(holder.c2, depth + 1, x + num / 2, y + num / 2); this.CreateNodeRec(holder.c3, depth + 1, x, y + num / 2); } }
public void CreateNodeRec(QuadtreeNodeHolder holder, int depth, int x, int y) { int width = 1 << (System.Math.Min(editorHeightLog2, editorWidthLog2) - depth); int walkable; if (depth < minDepth) { walkable = -1; } else { walkable = CheckNode(x, y, width); } if (walkable == 1 || walkable == 0 || width == 1) { var node = new QuadtreeNode(active); node.SetPosition((Int3)LocalToWorldPosition(x, y, width)); node.Walkable = walkable == 1; holder.node = node; } else //walkable = -1 //Undefined { holder.c0 = new QuadtreeNodeHolder(); holder.c1 = new QuadtreeNodeHolder(); holder.c2 = new QuadtreeNodeHolder(); holder.c3 = new QuadtreeNodeHolder(); CreateNodeRec(holder.c0, depth + 1, x, y); CreateNodeRec(holder.c1, depth + 1, x + width / 2, y); CreateNodeRec(holder.c2, depth + 1, x + width / 2, y + width / 2); CreateNodeRec(holder.c3, depth + 1, x, y + width / 2); } }
public void CreateNodeRec(QuadtreeNodeHolder holder, int depth, int x, int y) { int num2; int width = ((int)1) << (Math.Min(this.editorHeightLog2, this.editorWidthLog2) - depth); if (depth < this.minDepth) { num2 = -1; } else { num2 = this.CheckNode(x, y, width); } if (((num2 == 1) || (num2 == 0)) || (width == 1)) { QuadtreeNode node = new QuadtreeNode(base.active); node.SetPosition((VInt3)this.LocalToWorldPosition(x, y, width)); node.Walkable = num2 == 1; holder.node = node; } else { holder.c0 = new QuadtreeNodeHolder(); holder.c1 = new QuadtreeNodeHolder(); holder.c2 = new QuadtreeNodeHolder(); holder.c3 = new QuadtreeNodeHolder(); this.CreateNodeRec(holder.c0, depth + 1, x, y); this.CreateNodeRec(holder.c1, depth + 1, x + (width / 2), y); this.CreateNodeRec(holder.c2, depth + 1, x + (width / 2), y + (width / 2)); this.CreateNodeRec(holder.c3, depth + 1, x, y + (width / 2)); } }
public void CreateNodeRec (QuadtreeNodeHolder holder, int depth, int x, int y) { var width = 1 << (Math.Min (editorHeightLog2,editorWidthLog2)-depth); int walkable; if (depth < minDepth) { walkable = -1; } else { walkable = CheckNode (x,y, width); } if (walkable == 1 || walkable == 0 || width == 1) { var node = new QuadtreeNode(active); node.SetPosition ((Int3)LocalToWorldPosition(x,y,width)); node.Walkable = walkable == 1; holder.node = node; } else { //walkable = -1 //Undefined holder.c0 = new QuadtreeNodeHolder (); holder.c1 = new QuadtreeNodeHolder (); holder.c2 = new QuadtreeNodeHolder (); holder.c3 = new QuadtreeNodeHolder (); CreateNodeRec (holder.c0,depth+1,x , y ); CreateNodeRec (holder.c1,depth+1,x + width/2, y ); CreateNodeRec (holder.c2,depth+1,x + width/2, y + width/2); CreateNodeRec (holder.c3,depth+1,x , y + width/2); } }
public void AddNeighboursRec (List<QuadtreeNode> arr, QuadtreeNodeHolder holder, int depth, int x, int y, IntRect bounds, QuadtreeNode dontInclude) { var width = 1 << (Math.Min (editorHeightLog2,editorWidthLog2)-depth); var r = new IntRect(x,y,x+width,y+width); if (!IntRect.Intersects (r,bounds)) return; if (holder.node != null) { if (holder.node != dontInclude) { arr.Add (holder.node); } } else { AddNeighboursRec (arr, holder.c0, depth+1,x , y , bounds, dontInclude); AddNeighboursRec (arr, holder.c1, depth+1,x+width/2, y , bounds, dontInclude); AddNeighboursRec (arr, holder.c2, depth+1,x+width/2, y + width/2, bounds, dontInclude); AddNeighboursRec (arr, holder.c3, depth+1,x , y + width/2, bounds, dontInclude); } }
public void AddNeighboursRec(List <QuadtreeNode> arr, QuadtreeNodeHolder holder, int depth, int x, int y, IntRect bounds, QuadtreeNode dontInclude) { int num = 1 << Math.Min(this.editorHeightLog2, this.editorWidthLog2) - depth; IntRect a = new IntRect(x, y, x + num, y + num); if (!IntRect.Intersects(a, bounds)) { return; } if (holder.node != null) { if (holder.node != dontInclude) { arr.Add(holder.node); } } else { this.AddNeighboursRec(arr, holder.c0, depth + 1, x, y, bounds, dontInclude); this.AddNeighboursRec(arr, holder.c1, depth + 1, x + num / 2, y, bounds, dontInclude); this.AddNeighboursRec(arr, holder.c2, depth + 1, x + num / 2, y + num / 2, bounds, dontInclude); this.AddNeighboursRec(arr, holder.c3, depth + 1, x, y + num / 2, bounds, dontInclude); } }
public void AddNeighboursRec(List <QuadtreeNode> arr, QuadtreeNodeHolder holder, int depth, int x, int y, IntRect bounds, QuadtreeNode dontInclude) { int width = 1 << (System.Math.Min(editorHeightLog2, editorWidthLog2) - depth); var r = new IntRect(x, y, x + width, y + width); if (!IntRect.Intersects(r, bounds)) { return; } if (holder.node != null) { if (holder.node != dontInclude) { arr.Add(holder.node); } } else { AddNeighboursRec(arr, holder.c0, depth + 1, x, y, bounds, dontInclude); AddNeighboursRec(arr, holder.c1, depth + 1, x + width / 2, y, bounds, dontInclude); AddNeighboursRec(arr, holder.c2, depth + 1, x + width / 2, y + width / 2, bounds, dontInclude); AddNeighboursRec(arr, holder.c3, depth + 1, x, y + width / 2, bounds, dontInclude); } }