Пример #1
0
 public QuadTree(int width, int height, int minWidth, int minHeight)
 {
     _width = width;
     _height = height;
     _minWidth = minWidth;
     _minHeight = minHeight;
     MapBoundary = new Rectangle(0, 0, _width, _height);
     _root = new QuadTreeNode(MapBoundary, _minWidth, _minHeight, null);            
 }
Пример #2
0
 public QuadTreeNode(Rectangle bound, int minWidth, int minHeight, QuadTreeNode parent)
 {
     Bounds = bound;
     _minWidth = minWidth;
     _minHeight = minHeight;
     Contents = new List<Collidable>();
     Children = new List<QuadTreeNode>(4);
     Parent = parent;
     UpdatedAtInterval = -1;
     Leaf = false;
     // Will build out the tree
     Partition();
 }
Пример #3
0
        // Expands by a multiple of 4
        public void ExpandTo(int newWidth, int newHeight, int newMinWidth, int newMinHeight)
        {
            // We will be larger, so we want to have larger min-width's
            _root.LiftLeafNodes(newMinWidth, newMinHeight);

            MapBoundary = new Rectangle(0,0,newWidth,newHeight);
            // Create larger quad tree map
            QuadTreeNode newRoot = new QuadTreeNode(MapBoundary,newMinWidth,newMinHeight,null);
            // Maybe fix in the future, newRoot generates a topLeft that will be replaced
            newRoot.TopLeft = _root;
            // Make old root a child
            _root.Parent = newRoot;
            // Assign a new root
            _root = newRoot;
        }
Пример #4
0
 public void Clear()
 {
     _root.ClearCollidableMaps();
     MapBoundary = new Rectangle(0, 0, _width, _height);
     _root       = new QuadTreeNode(MapBoundary, _minWidth, _minHeight, null);
 }
Пример #5
0
 public void SetMapArea(QuadTreeNode node)
 {
     _mapLocation = node;
 }
Пример #6
0
 public void ClearMapArea()
 {
     _mapLocation = null;
 }
Пример #7
0
 public void SetMapArea(QuadTreeNode node)
 {
     _mapLocation = node;
 }
Пример #8
0
 public void ClearMapArea()
 {
     _mapLocation = null;
 }
Пример #9
0
 public void Clear()
 {
     _root.ClearCollidableMaps();
     MapBoundary = new Rectangle(0, 0, _width, _height);
     _root = new QuadTreeNode(MapBoundary, _minWidth, _minHeight, null);
 }