/// <summary> /// Get a reference to the deepest node that contains a point. /// </summary> /// <param name="point">Vector3 representing the target point</param> /// <returns>Deepest quad node containing target point</returns> public QuadNode DeepestNodeWithPoint(Vector3 point) { //If the point isn't in this node, return null if (!Contains(point)) { return(null); } if (HasChildren) { if (ChildTopLeft.Contains(point)) { return(ChildTopLeft.DeepestNodeWithPoint(point)); } if (ChildTopRight.Contains(point)) { return(ChildTopRight.DeepestNodeWithPoint(point)); } if (ChildBottomLeft.Contains(point)) { return(ChildBottomLeft.DeepestNodeWithPoint(point)); } //It's contained in this node and not in the first 3 //children, so has to be in 4th child. No need to check. return(ChildBottomRight.DeepestNodeWithPoint(point)); } //No children, return this QuadNode return(this); }
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(); }