public static IntRect Intersection(IntRect a, IntRect b) { IntRect r = new IntRect( System.Math.Max(a.xmin,b.xmin), System.Math.Max(a.ymin,b.ymin), System.Math.Min(a.xmax,b.xmax), System.Math.Min(a.ymax,b.ymax) ); return r; }
public override List <GraphNode> GetNodesInRegion(IntRect rect) { List <GraphNode> list = ListPool <GraphNode> .Claim(); IntRect b = new IntRect(0, 0, this.width - 1, this.depth - 1); rect = IntRect.Intersection(rect, b); if (this.nodes == null || !rect.IsValid() || this.nodes.Length != this.width * this.depth * this.layerCount) { return(list); } for (int i = 0; i < this.layerCount; i++) { int num = i * base.Width * base.Depth; for (int j = rect.ymin; j <= rect.ymax; j++) { int num2 = num + j * base.Width; for (int k = rect.xmin; k <= rect.xmax; k++) { LevelGridNode levelGridNode = this.nodes[num2 + k]; if (levelGridNode != null) { list.Add(levelGridNode); } } } } return(list); }