예제 #1
0
        /// <summary>
        /// Split the node by activating vertices
        /// </summary>
        public void Split()
        {
            //Make sure parent node is split
            if (_parent != null && !_parent.IsSplit)
            {
                _parent.Split();
            }

            if (CanSplit)
            {
                //Set active nodes
                if (HasChildren)
                {
                    ChildTopLeft.Activate();
                    ChildTopRight.Activate();
                    ChildBottomLeft.Activate();
                    ChildBottomRight.Activate();

                    _isActive = false;
                }
                else
                {
                    _isActive = true;
                }

                _isSplit = true;
                //Set active vertices
                VertexTop.Activated    = true;
                VertexLeft.Activated   = true;
                VertexRight.Activated  = true;
                VertexBottom.Activated = true;
            }

            //Make sure neighbor parents are split
            EnsureNeighborParentSplit(NeighborTop);
            EnsureNeighborParentSplit(NeighborRight);
            EnsureNeighborParentSplit(NeighborBottom);
            EnsureNeighborParentSplit(NeighborLeft);

            //Make sure neighbor vertices are active
            if (NeighborTop != null)
            {
                NeighborTop.VertexBottom.Activated = true;
            }

            if (NeighborRight != null)
            {
                NeighborRight.VertexLeft.Activated = true;
            }

            if (NeighborBottom != null)
            {
                NeighborBottom.VertexTop.Activated = true;
            }

            if (NeighborLeft != null)
            {
                NeighborLeft.VertexRight.Activated = true;
            }
        }
예제 #2
0
        public void Update(GameTime gameTime)
        {
            View           = camera.World;
            Projection     = camera.Projection;
            CameraPosition = camera.Position;

            //Only update if the camera position has changed
            if (_cameraPosition == _lastCameraPosition)
            {
                return;
            }

            //Effect.View = View;
            //Effect.Projection = Projection;

            _lastCameraPosition = _cameraPosition;
            IndexCount          = 0;

            _rootNode.EnforceMinimumDepth();

            _activeNode = _rootNode.DeepestNodeWithPoint(CameraPosition);

            if (_activeNode != null)
            {
                _activeNode.Split();
            }

            _rootNode.SetActiveVertices();

            _buffers.UpdateIndexBuffer(Indices, IndexCount);
            _buffers.SwapBuffer();
        }