diff --git a/MonoGame.Framework/BoundingBox.cs b/MonoGame.Framework/BoundingBox.cs index 1f4908f7a07..48008e5bf2d 100644 --- a/MonoGame.Framework/BoundingBox.cs +++ b/MonoGame.Framework/BoundingBox.cs @@ -102,22 +102,22 @@ public void Contains(ref BoundingBox box, out ContainmentType result) } /// - /// Check if this contains a . + /// Determines if this contains or intersects with a specified . + /// NOTE: This method may return false positives (indicating an intersection or containment when there is none) + /// to improve performance. Use with caution if precision is critical. /// /// The to test for overlap. /// - /// A value indicating if this contains, - /// intersects with or is disjoint with . + /// A value indicating whether this + /// contains or intersects the . /// public ContainmentType Contains(BoundingFrustum frustum) { - //TODO: bad done here need a fix. - //Because question is not frustum contain box but reverse and this is not the same int i; ContainmentType contained; Vector3[] corners = frustum.GetCorners(); - // First we check if frustum is in box + // First we check every corner of a frustum for (i = 0; i < corners.Length; i++) { this.Contains(ref corners[i], out contained); @@ -128,13 +128,13 @@ public ContainmentType Contains(BoundingFrustum frustum) if (i == corners.Length) // This means we checked all the corners and they were all contain or instersect return ContainmentType.Contains; - if (i != 0) // if i is not equal to zero, we can fastpath and say that this box intersects + if (i != 0) // If i is not equal to zero, we can fastpath and say that this box intersects return ContainmentType.Intersects; - // If we get here, it means the first (and only) point we checked was actually contained in the frustum. - // So we assume that all other points will also be contained. If one of the points is disjoint, we can - // exit immediately saying that the result is Intersects + // If we get here, it means the first (and only) point we checked was disjoint from frustum. + // So we assume that if all other points of frustum are inside the box, then box contains the frustum. + // Otherwise we exit immediately saying that the result is Intersects i++; for (; i < corners.Length; i++) { @@ -144,7 +144,7 @@ public ContainmentType Contains(BoundingFrustum frustum) } - // If we get here, then we know all the points were actually contained, therefore result is Contains + // If we get here, then we know that only one point is disjoint, therefore result is Contains return ContainmentType.Contains; } diff --git a/README.md b/README.md index 26a9574104f..fda92c3621c 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The [Platformer 2D](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/Plat | [Auto Pong Sample](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/AutoPong/README.md) | [Ship Game 3D](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/ShipGame/README.md) | |-|-| | Supported on all platforms | GL / DX / iOS / Android | -| [![Auto Pong Sample](https://raw.githubusercontent.com/MonoGame/MonoGame.Samples/refs/heads/3.8.2/Images/AutoPong_1.gif)](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/AutoPong/README.md) | [![ShipGame 3D Sample](https://raw.githubusercontent.com/MonoGame/MonoGame.Samples/refs/heads/3.8.2/Images/ShipGame.gif)](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/ShipGame/README.md) | +| [![Auto Pong Sample](https://raw.githubusercontent.com/MonoGame/MonoGame.Samples/refs/heads/3.8.2/Images/AutoPong_1.gif)](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/AutoPong/README.md) | [![ShipGame 3D Sample](https://raw.githubusercontent.com/MonoGame/MonoGame.Samples/refs/heads/3.8.2/Images/ShipGame.png)](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/ShipGame/README.md) | | A short [sample project](https://github.com/MonoGame/MonoGame.Samples/blob/3.8.2/AutoPong/README.md) showing you how to make the classic game of pong, with generated soundfx, in 300 lines of code. | 3D Ship Game (Descent clone) sample, pulled from the XNA archives and updated for MonoGame | |||