src/StackQuadtree.cs
/// <summary>Updates position of <paramref name="id"/> in the tree.</summary>
/// <returns>True if <paramref name="id"/> has been updated, otherwise false.</returns>
Updates position of  in the tree.
Updates position of in the tree .
public bool Update(int id, Vector2 xy, Vector2 size, float angle = 0, Vector2 origin = default) {
            var bounds = new RotRect(xy, size, angle, origin);
            var aabb = bounds.AABB;
            var center = aabb.Center;
            var item = _items[id];
            var node = _nodes[item._node];
            int halfWidth = _bounds.Width >> node._depth,
                halfHeight = _bounds.Height >> node._depth;
            var bounds2 = new Rectangle(node._cX - halfWidth, node._cY - halfHeight, halfWidth << 1, halfHeight << 1);
            if (bounds2.Contains(center) || node._parent == -1) {
                _items[id]._bounds = bounds;
                _items[id]._xy = center;
                _nodesToGrow.Add(item._node);
                return true;
            }
            if (node._firstChild == id)
                _nodes[item._node]._firstChild = item._next;
            else {
                var prevItem = node._firstChild;
                var curItem = _items[prevItem]._next;
                for (var i = 0; i < node._itemCount; i++) {
                    if (curItem == id) {
                        _items[prevItem]._next = _items[curItem]._next;
                        break;
                    }
                    prevItem = curItem;
                    curItem = _items[curItem]._next;
                }
            }
            _nodes[item._node]._itemCount--;
            _nodesToGrow.Add(item._node);
            var nodeId = item._node;
            do {
                if (node._parent < 0)
                    break;
                var parentNode = _nodes[node._parent];
                halfWidth = _bounds.Width >> parentNode._depth;
                halfHeight = _bounds.Height >> parentNode._depth;
                bounds2 = new Rectangle(parentNode._cX - halfWidth, parentNode._cY - halfHeight, halfWidth << 1, halfHeight << 1);
                if (bounds2.Contains(center)) {
                    nodeId = node._parent;
                    break;
                }
                nodeId = node._parent;
                node = _nodes[nodeId];
            } while (true);
            var nId2 = Insert(id, nodeId, bounds, center);
            TrySubdivide(nId2);
            _nodesToGrow.Add(nId2);
            return true;
        }
public bool Update ( int id , Vector2 xy , Vector2 size , float angle = 0 , Vector2 origin = default ) { var bounds = new RotRect ( xy , size , angle , origin ) ; var aabb = bounds . AABB ; var center = aabb . Center ; var item = _items [ id ] ; var node = _nodes [ item . _node ] ; int halfWidth = _bounds . Width >> node . _depth , halfHeight = _bounds . Height >> node . _depth ; var bounds2 = new Rectangle ( node . _cX - halfWidth , node . _cY - halfHeight , halfWidth << 1 , halfHeight << 1 ) ; if ( bounds2 . Contains ( center ) || node . _parent == - 1 ) { _items [ id ] . _bounds = bounds ; _items [ id ] . _xy = center ; _nodesToGrow . Add ( item . _node ) ; return true ; } if ( node . _firstChild == id ) _nodes [ item . _node ] . _firstChild = item . _next ; else { var prevItem = node . _firstChild ; var curItem = _items [ prevItem ] . _next ; for ( var i = 0 ; i < node . _itemCount ; i ++ ) { if ( curItem == id ) { _items [ prevItem ] . _next = _items [ curItem ] . _next ; break ; } prevItem = curItem ; curItem = _items [ curItem ] . _next ; } } _nodes [ item . _node ] . _itemCount -- ; _nodesToGrow . Add ( item . _node ) ; var nodeId = item . _node ; do { if ( node . _parent < 0 ) break ; var parentNode = _nodes [ node . _parent ] ; halfWidth = _bounds . Width >> parentNode . _depth ; halfHeight = _bounds . Height >> parentNode . _depth ; bounds2 = new Rectangle ( parentNode . _cX - halfWidth , parentNode . _cY - halfHeight , halfWidth << 1 , halfHeight << 1 ) ; if ( bounds2 . Contains ( center ) ) { nodeId = node . _parent ; break ; } nodeId = node . _parent ; node = _nodes [ nodeId ] ; } while ( true ) ; var nId2 = Insert ( id , nodeId , bounds , center ) ; TrySubdivide ( nId2 ) ; _nodesToGrow . Add ( nId2 ) ; return true ; }
Updates position of  in the tree.
Updates position of in the tree .
True if  has been updated, otherwise false.
True if has been updated otherwise false .
id
int
xy
Vector2
size
Vector2
angle
float
origin
Vector2