//BSD License  
//DXGfx® - http://www.eteractions.com
//Copyright (c) 2005
//by Guillaume Randon
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software
//and associated documentation files (the "Software"), to deal in the Software without restriction,
//including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
//and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
//subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all copies or substantial
//portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
//AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
//DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;

namespace DXGfxLib
{
    /// <summary>
    /// A quadtree node is a special sceneNode that goes into a quadtree. Does it behaves differently from any other
    /// scenenode, not really except we want to know that we are dealing with a quadtree node and not just a simple scenenode
    /// this is why this class exists even if we don't perform any operation differently for it than for the base scenenode.
    /// </summary>
    public class QuadTreeNode : SceneNode
    {
        /// <summary>
        /// Default constructor. By default a QuadTreeNode will set useFrustrumCulling to true. If a Quadtree node is not
        /// used in frustrum tets, it is not that useful.
        /// </summary>
        public QuadTreeNode()
        {
            useFrustrumCulling = true;
        }

        /// <summary>
        /// In a QuadTreeNode it is interesting to override this method because QuadTreeNode behaves in certain ways
        /// which make some optimizations possible.
        /// First they are always created by an outdoor scene. Their bounding box are not supposed to change in any
        /// manner so instead of going down all the tree to update bounding box information, then walk it up to update
        /// all nodes in between and then do the attach phase, we can in fact do everything in one traversal!
        /// Descendent nodes will know themselves how they need to behave !
        /// </summary>
        /// <param name="frustrum"></param>
        /// <param name="elapsedTime"></param>
        /// <param name="appTime"></param>
        /// <param name="objectsToBeRendered"></param>
        public override void Update(Frustrum frustrum, float elapsedTime, double appTime, List<IDrawable> objectsToBeRendered)
        {
                for (int i = 0; i < children.Count; i++)
                {
                    children[i].Update(frustrum, elapsedTime, appTime, objectsToBeRendered);
                }
        }
    }
}
