private void UpdateNode(Node node, Point p0, Point p1, Point a) { node.Visible = true; if (FrustumCullingEnabled && ViewFrustum.Contains(GetBoundingBox(node)) == ContainmentType.Disjoint) { node.Visible = false; return; } Point p = GetMidpoint(p0, p1); int width = Math.Abs(p0.X - p1.X) + Math.Abs(p0.Y - p1.Y); float distanceSquared = (CameraPosition - new Vector3(p.X, GetHeight(p) * Bumpiness, -p.Y)).LengthSquared(); bool split = SplitCheck(node, width, distanceSquared); if (!node.Split && split) { SplitNode(node); vertexCounter++; } else if (node.Split && !split && CanMerge(node) && CanMerge(node.BaseNeighbor)) { MergeNode(node); MergeNode(node.BaseNeighbor); vertexCounter--; } if (node.Split && node.LeftChild != null) { UpdateNode(node.LeftChild, a, p0, p); UpdateNode(node.RightChild, p1, a, p); } }
private void UpdateNode(Point p, int size, bool frustumCulling) { UpdateBlending(p, size); if (!IsEnabled(p)) { return; } if (GeomorphEnabled) { UpdateMidpointBlending(p, size); } Quadtree[p.X, p.Y].Visible = true; if (frustumCulling) { ContainmentType result = ViewFrustum.Contains(GetBoundingBox(p, size)); if (result == ContainmentType.Disjoint) { Quadtree[p.X, p.Y].Visible = false; } else if (result == ContainmentType.Contains) { frustumCulling = false; } } if (size == 3 || !IsVisible(p)) { return; } Point[] children = GetChildren(p, size); for (int i = 0; i < 4; i++) { UpdateNode(children[i], size / 2 + 1, frustumCulling); } }
private void UpdateNode(Node node, bool frustumCulling, GameTime gameTime) { node.Visible = true; if (frustumCulling) { ContainmentType result = ViewFrustum.Contains(GetBoundingBox(node)); if (result == ContainmentType.Disjoint) { node.Visible = false; } else if (result == ContainmentType.Contains) { frustumCulling = false; } } if (!node.Visible) { return; } if (node.Children != null) { foreach (Node child in node.Children) { UpdateNode(child, frustumCulling, gameTime); } } if (node.Block != null) { node.Block.Update(gameTime); } }
/// <summary> /// Check to see if a bounding volume is within the bounds of the view frustum /// </summary> /// <param name="sphere">BoundingSphere to be checked</param> /// <returns>Result</returns> public bool IsInView(BoundingSphere sphere) { return(ViewFrustum.Contains(sphere) != ContainmentType.Disjoint); }
/// <summary> /// Check to see if a bounding volume is within the bounds of the view frustum /// </summary> /// <param name="box">BoundingBox to be checked</param> /// <returns>Result</returns> public bool IsInView(BoundingBox box) { return(ViewFrustum.Contains(box) != ContainmentType.Disjoint); }
public bool Contains(ref BoundingBox box) { return(mFrustum.Contains(ref box) != ContainmentType.Disjoint); }