Beispiel #1
0
        /*
         * Updates the internal quadtree to make it identical to the given terrain
         * quadtree. This method releases the texture tiles corresponding to
         * deleted quads.
         */
        protected virtual void PutTiles(QuadTree tree, TerrainQuad quad)
        {
            if (tree == null)
            {
                return;
            }

            //Check if this tile is needed, if not put tile.
            tree.needTile = NeedTile(quad);

            if (!tree.needTile && tree.tile != null)
            {
                m_producer.PutTile(tree.tile);
                tree.tile = null;
            }

            //If this qiad is a leaf then all children of the tree are not needed
            if (quad.IsLeaf())
            {
                if (!tree.IsLeaf())
                {
                    tree.RecursiveDeleteChildren(this);
                }
            }
            else if (m_producer.HasChildren(quad.GetLevel(), quad.GetTX(), quad.GetTY()))
            {
                for (int i = 0; i < 4; ++i)
                {
                    PutTiles(tree.children[i], quad.GetChild(i));
                }
            }
        }