コード例 #1
0
ファイル: MapEditorForm.cs プロジェクト: uiters/MapEditor
        private QuadNode AutoBuild(int type, out List <CObject> objs)
        {
            QuadNode.depth          = depth;
            QuadNode.minSize.Width  = minWidth;
            QuadNode.minSize.Height = minHeight;
            QuadNode root = new QuadNode(0, 0, new Rectangle(0, 0, image.Width, image.Height));

            objs = new List <CObject>();
            if (type != (int)Type.All)
            {
                foreach (var item in objects)
                {
                    if (item.Value.type == type)
                    {
                        root.Build(item.Value);
                        objs.Add(item.Value);
                    }
                }
            }
            else
            {
                foreach (var item in objects)
                {
                    root.Build(item.Value);
                    objs.Add(item.Value);
                }
            }
            return(root);
        }
コード例 #2
0
        public void Build(CObject obj)
        {
            objects.Add(obj);
            CreateQuadNodeSub();
            if (leftBottom is null)
            {
                return;
            }
            else
            {
                for (int i = 0; i < objects.Count; ++i)
                {
                    if (leftTop.region.IntersectsWith(objects[i].region))
                    {
                        leftTop.Build(objects[i]);
                    }

                    if (rightTop.region.IntersectsWith(objects[i].region))
                    {
                        rightTop.Build(objects[i]);
                    }

                    if (leftBottom.region.IntersectsWith(objects[i].region))
                    {
                        leftBottom.Build(objects[i]);
                    }

                    if (rightBottom.region.IntersectsWith(objects[i].region))
                    {
                        rightBottom.Build(objects[i]);
                    }
                }
                objects.Clear();
            }
        }