public bool NeedsUpdate(IBoundedObject component) { if (ObjectsToUpdate.ContainsKey(component)) { return(false); } return(!ObjectsToNodes.ContainsKey(component) || ObjectsToNodes[component].Bounds.Intersects(component.GetBoundingBox())); }
public void AddObjectRecursive(IBoundedObject obj) { if (ObjectsToNodes.ContainsKey(obj)) { return; } else { Root.AddObjectRecursive(obj); } }
public bool RemoveObject(IBoundedObject obj) { if (!ObjectsToNodes.ContainsKey(obj)) { return(false); } else { OctreeNode node = ObjectsToNodes[obj]; return(node.RemoveObject(obj)); } }
public void ExpandAndRebuild() { Lock.EnterWriteLock(); ObjectsToNodes.Clear(); List <IBoundedObject> objectsInTree = Root.MergeRecursive(); BoundingBox bounds = new BoundingBox(Bounds.Min * 2.0f, Bounds.Max * 2.0f); Bounds = bounds; Root = new OctreeNode(Bounds, this, 0, null); foreach (IBoundedObject loc in objectsInTree) { AddObjectRecursive(loc); } Lock.ExitWriteLock(); }