예제 #1
0
		internal QuadNode(NodeType nodeType, int nodeSize, int nodeDepth, QuadNode parent, QuadTree parentTree, int positionIndex)
		{
			NodeType = nodeType;
			_nodeSize = nodeSize;
			_nodeDepth = nodeDepth;
			_positionIndex = positionIndex;

			_parent = parent;
			_parentTree = parentTree;

			//Add the 9 vertices
			AddVertices();

			var tl = new Vector2(_parentTree.Vertices[VertexTopLeft.Index].Position.X, _parentTree.Vertices[VertexTopLeft.Index].Position.Z);
			var br = new Vector2(_parentTree.Vertices[VertexBottomRight.Index].Position.X, _parentTree.Vertices[VertexBottomRight.Index].Position.Z);

			Bounds = Culling.Rectangle.FromPoints(tl, br);

			if (nodeSize >= 4)
				AddChildren();

			//Make call to UpdateNeighbors from the parent node only.
			//This will update neighbors recursively for the children 
			//as well.  This ensures all nodes are created prior to 
			//updating neighbors.
			if (_nodeDepth == 1)
			{
				AddNeighbors();

				VertexTopLeft.Activated = true;
				VertexTopRight.Activated = true;
				VertexCenter.Activated = true;
				VertexBottomLeft.Activated = true;
				VertexBottomRight.Activated = true;

			}
		}
예제 #2
0
        internal QuadNode(NodeType nodeType, int nodeSize, int nodeDepth, QuadNode parent, QuadTree parentTree, int positionIndex)
        {
            NodeType       = nodeType;
            _nodeSize      = nodeSize;
            _nodeDepth     = nodeDepth;
            _positionIndex = positionIndex;

            _parent     = parent;
            _parentTree = parentTree;

            //Add the 9 vertices
            AddVertices();

            var tl = new Vector2(_parentTree.Vertices[VertexTopLeft.Index].Position.X, _parentTree.Vertices[VertexTopLeft.Index].Position.Z);
            var br = new Vector2(_parentTree.Vertices[VertexBottomRight.Index].Position.X, _parentTree.Vertices[VertexBottomRight.Index].Position.Z);

            Bounds = Culling.Rectangle.FromPoints(tl, br);

            if (nodeSize >= 4)
            {
                AddChildren();
            }

            //Make call to UpdateNeighbors from the parent node only.
            //This will update neighbors recursively for the children
            //as well.  This ensures all nodes are created prior to
            //updating neighbors.
            if (_nodeDepth == 1)
            {
                AddNeighbors();

                VertexTopLeft.Activated     = true;
                VertexTopRight.Activated    = true;
                VertexCenter.Activated      = true;
                VertexBottomLeft.Activated  = true;
                VertexBottomRight.Activated = true;
            }
        }