void BuildQuadtree() { Quadtree.Clear(); if (agents.Count > 0) { //GG //Rect bounds = Rect.MinMaxRect(agents[0].position.x, agents[0].position.y, agents[0].position.x, agents[0].position.y); VRect bounds = VRect.MinMaxRect(agents[0].position.x, agents[0].position.y, agents[0].position.x, agents[0].position.y); for (int i = 1; i < agents.Count; i++) { //GG /*Vector2 p = agents[i].position; * bounds = Rect.MinMaxRect(Mathf.Min(bounds.xMin, p.x), Mathf.Min(bounds.yMin, p.y), Mathf.Max(bounds.xMax, p.x), Mathf.Max(bounds.yMax, p.y));*/ VInt2 p = agents[i].position; bounds = VRect.MinMaxRect(Mathf.Min(bounds.xMin, p.x), Mathf.Min(bounds.yMin, p.y), Mathf.Max(bounds.xMax, p.x), Mathf.Max(bounds.yMax, p.y)); } Quadtree.SetBounds(bounds); for (int i = 0; i < agents.Count; i++) { Quadtree.Insert(agents[i]); } //quadtree.DebugDraw (); } Quadtree.CalculateSpeeds(); }