コード例 #1
0
    public void Clear()
    {
        if (TotalLeafNodes != 0)
        {
            if (_ChildNode == null)
            {
                for (int leaf = 0; leaf < 4; ++leaf)
                {
                    if (_ChildNodes.ContainsKey(leaf))
                    {
                        _ChildNodes[leaf].Clear();
                        SMainInstance.DestroyQuadTreeObject(_SelfPartitionPrefab);
                    }
                }
            }
            else
            {
                _ChildNode = null;
            }
            TotalLeafNodes = 0;
            _CurrentDepth  = 0;
            SMaxDepth      = 0;

            _ParentNode          = null;
            _SelfPartitionPrefab = null;
            _ChildNode           = null;
            _SPreviousChildNode  = null;
            _ChildNodes          = new Dictionary <int, QuadTree>();
            _PartitionDrawn      = false;
        }
    }
コード例 #2
0
    public bool RemoveParticle(GameObject ParticleObject)
    {
        QuadTree TempParent = FindParticleParent(ParticleObject);

        if (TempParent != null)
        {
            TempParent._ChildNode = null;
            //	if (TempParent._TotalLeafNodes == 1)
            {
                while (TempParent._ParentNode != null)
                {
                    --TempParent.TotalLeafNodes;


                    if (TempParent.TotalLeafNodes == 1)
                    {
                        SMainInstance.DestroyQuadTreeObject(TempParent._SelfPartitionPrefab);
                        TempParent._SelfPartitionPrefab = null;

                        //update childrens
                        for (int leaf = 0; leaf < 4; ++leaf)
                        {
                            if (TempParent._ChildNodes.ContainsKey(leaf))
                            {
                                TempParent._ChildNode = TempParent._ChildNodes[leaf]._ChildNode;

                                TempParent._ChildNodes[leaf]._ChildNode = null;
                                TempParent._ChildNodes[leaf].Clear();
                                TempParent._ChildNodes.Clear();
                            }
                        }
                    }

                    TempParent._PartitionDrawn = false;
                    TempParent = TempParent._ParentNode;
                }
                if (TempParent._ParentNode == null)
                {
                    if (TempParent.TotalLeafNodes == 1)
                    {
                        --TempParent.TotalLeafNodes;
                        SMainInstance.DestroyQuadTreeObject(TempParent._SelfPartitionPrefab);
                        TempParent._SelfPartitionPrefab = null;
                    }
                }
            }
            //if (temp._TotalLeafNodes == 0)
            //{
            //	MainInstance.DestroyObject(temp._SelfPartitionPrefab);
            //	temp._SelfPartitionPrefab = null;
            //}
            return(true);
        }

        //object not found
        return(false);
    }
コード例 #3
0
    public void ClearPartitionDrawn()
    {
        SMainInstance.DestroyQuadTreeObject(_SelfPartitionPrefab);
//		Debug.Log("DEL8888888888888888888888888888888888888888888888888888888");
//		if (TotalLeafNodes > 0)
//		{
//			if (_PartitionDrawn)
//				_PartitionDrawn = false;
//			for (int leaf = 0; leaf < 4; ++leaf)
//			{
//				if (_ChildNodes.ContainsKey(leaf))
//					_ChildNodes[leaf].ClearPartitionDrawn();
//			}
//		}
    }