コード例 #1
0
        public BoundingRect GetAABB(float cos, float sin, float scale)
        {
            BoundingRect returnRect = CollisionShapes[0].GetAABB(cos, sin, scale);

            for (int i = 1; i < CollisionShapes.Count; i++)
            {
                BoundingRect temp = CollisionShapes[i].GetAABB(cos, sin, scale);
                returnRect = BoundingRect.Union(returnRect, temp);
            }
            return(returnRect);
        }
コード例 #2
0
        public BoundingRect GetAABB(float scale)
        {
            BoundingRect returnRect = RenderShapes[0].GetAABB(scale);

            for(int i=1; i<RenderShapes.Count; i++)
            {
                BoundingRect temp = RenderShapes[i].GetAABB(scale);
                returnRect = BoundingRect.Union(returnRect, temp);
            }
            return returnRect;
        }
コード例 #3
0
ファイル: RTree2D.cs プロジェクト: taha-islam/XTMF
        private void Add(Node currentNode, BoundingRect rect, T data)
        {
            var children      = currentNode.Children;
            int emptyPosition = -1;

            for (int i = 0; i < children.Length; i++)
            {
                if (children[i] == null)
                {
                    emptyPosition = i;
                    break;
                }
                if (children[i].Contains(rect))
                {
                    this.Add(children[i], rect, data);
                    currentNode.Depth = Math.Max(children[i].Depth, currentNode.Depth);
                    currentNode.Balance();
                    return;
                }
            }
            // if no child already contains that point
            // We need to expand to contain it
            currentNode.BoundingBox = BoundingRect.Union(currentNode.BoundingBox, rect);
            // check to see if there is a place we can just store it quickly
            if (emptyPosition >= 0)
            {
                children[emptyPosition] = new Node()
                {
                    Depth = 0, BoundingBox = rect, Children = new Node[this.ChildLength], Data = data
                };
                currentNode.Depth = Math.Max(currentNode.Depth, 1);
            }
            else
            {
                // if there is no place to store it we need to force a merge into a child that does not contain it
            }
            currentNode.Balance();
        }