internal void Update(GameTime gameTime, ICamera Camera) { ViewFrustrum.Matrix = Camera.ViewProjection; CameraPosition = Camera.Position; //Corners 0-3 = near plane clockwise, Corners 4-7 = far plane clockwise ViewFrustrum.GetCorners(VFCorners); var clip = ClippingFrustrum.FromFrustrumCorners(VFCorners, CameraPosition); ClipShape = clip.ProjectToTargetY(_position.Y); _lastCameraPosition = _cameraPosition; IndexCount = 0; _rootNode.Merge(); _rootNode.EnforceMinimumDepth(); _activeNode = _rootNode.DeepestNodeWithPoint(ClipShape.ViewPoint); if (_activeNode != null) { _activeNode.Split(); } _rootNode.SetActiveVertices(); _buffers.UpdateIndexBuffer(Indices, IndexCount); _buffers.SwapBuffer(); }
internal void Update(GameTime gameTime, ICamera Camera) { ViewFrustrum.Matrix = Camera.ViewProjection; CameraPosition = Camera.Position; //Corners 0-3 = near plane clockwise, Corners 4-7 = far plane clockwise ViewFrustrum.GetCorners(VFCorners); var clip = ClippingFrustrum.FromFrustrumCorners(VFCorners, CameraPosition); ClipShape = clip.ProjectToTargetY(_position.Y); _lastCameraPosition = _cameraPosition; IndexCount = 0; _rootNode.Merge(); _rootNode.EnforceMinimumDepth(); _activeNode = _rootNode.DeepestNodeWithPoint(ClipShape.ViewPoint); if (_activeNode != null) { _activeNode.Split(); } _rootNode.SetActiveVertices(); _buffers.UpdateIndexBuffer(Indices, IndexCount); _buffers.SwapBuffer(); }
/// <summary> /// Split the node by activating vertices /// </summary> public void Split() { if (_parentTree.Cull && !IsInView) { return; } //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; } }