Exemplo n.º 1
0
        public bool NeedsUpdate(IBoundedObject component)
        {
            if (ObjectsToUpdate.ContainsKey(component))
            {
                return(false);
            }

            return(!ObjectsToNodes.ContainsKey(component) || ObjectsToNodes[component].Bounds.Intersects(component.GetBoundingBox()));
        }
Exemplo n.º 2
0
 public void AddObjectRecursive(IBoundedObject obj)
 {
     if (ObjectsToNodes.ContainsKey(obj))
     {
         return;
     }
     else
     {
         Root.AddObjectRecursive(obj);
     }
 }
Exemplo n.º 3
0
 public bool RemoveObject(IBoundedObject obj)
 {
     if (!ObjectsToNodes.ContainsKey(obj))
     {
         return(false);
     }
     else
     {
         OctreeNode node = ObjectsToNodes[obj];
         return(node.RemoveObject(obj));
     }
 }
Exemplo n.º 4
0
        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();
        }