public void Insert(UV uv) { if (!Contains(uv)) { return; } if (IsLeafNode) { // If the node that is being inserted is // the same as one that exists, then return // true; if (Point == null) { Point = uv; return; } if (uv.IsAlmostEqualTo(Point)) { return; } Split(); // Move the existing point into a new cell NW.Insert(UV.ByCoordinates(Point.U, Point.V)); NE.Insert(UV.ByCoordinates(Point.U, Point.V)); SE.Insert(UV.ByCoordinates(Point.U, Point.V)); SW.Insert(UV.ByCoordinates(Point.U, Point.V)); Point = null; // Insert the new UV into the correct cell NW.Insert(uv); NE.Insert(uv); SW.Insert(uv); SE.Insert(uv); } else { NW.Insert(uv); NE.Insert(uv); SW.Insert(uv); SE.Insert(uv); } }
private bool Insert(BoundsLink <T> member) { // make sure we intersect with the bounds of this object if (!Bounds.IntersectsWith(member.bounds, true)) { return(false); } if (Members.Count < MaxReferencesPerTree) { Members.Add(member); return(true); } // else we are full, but need to store this object if (!IsDivided) { Subdivide(); } bool Inserted = false; if (SW.Insert(member)) { Inserted = true; } if (NW.Insert(member)) { Inserted = true; } if (NE.Insert(member)) { Inserted = true; } if (SE.Insert(member)) { Inserted = true; } return(Inserted); }