Skip to content

Commit

Permalink
Merge branch 'develop' into installtools
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 authored Nov 10, 2024
2 parents e7f5c8f + 0c8b558 commit 67bcb45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions MonoGame.Framework/BoundingBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ public void Contains(ref BoundingBox box, out ContainmentType result)
}

/// <summary>
/// Check if this <see cref="BoundingBox"/> contains a <see cref="BoundingFrustum"/>.
/// Determines if this <see cref="BoundingBox"/> contains or intersects with a specified <see cref="BoundingFrustum"/>.
/// 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.
/// </summary>
/// <param name="frustum">The <see cref="BoundingFrustum"/> to test for overlap.</param>
/// <returns>
/// A value indicating if this <see cref="BoundingBox"/> contains,
/// intersects with or is disjoint with <paramref name="frustum"/>.
/// A <see cref="ContainmentType"/> value indicating whether this <see cref="BoundingBox"/>
/// contains or intersects the <paramref name="frustum"/>.
/// </returns>
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);
Expand All @@ -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++)
{
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|||

Expand Down

0 comments on commit 67bcb45

Please sign in to comment.