Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box3d/M44d (frustum) intersection method is now based on opengl clip-space #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Aardvark.Base/Geometry/IntersectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3851,10 +3851,10 @@ around the box. Intersect the four space diagonals of the box

/// <summary>
/// returns true if the Box3d and the frustum described by the M44d intersect or the frustum contains the Box3d
/// Assumes DirectX clip-space:
/// Assumes OpenGL clip-space:
/// -w &lt; x &lt; w
/// -w &lt; y &lt; w
/// 0 &lt; z &lt; w
/// -w &lt; z &lt; w
/// </summary>
public static bool IntersectsFrustum(this Box3d box, M44d projection)
{
Expand All @@ -3869,7 +3869,7 @@ public static bool IntersectsFrustum(this Box3d box, M44d projection)
//0 < (proj.R0 + proj.R3) * v

//therefore (proj.R0 + proj.R3) is the plane describing the left clip-plane.
//The other planes can be derived in a similar way (only the near plane is a little different)
//The other planes can be derived in a similar way
//see http://fgiesen.wordpress.com/2012/08/31/frustum-planes-from-the-projection-matrix/ for a full explanation

var r0 = projection.R0;
Expand Down Expand Up @@ -3903,7 +3903,7 @@ public static bool IntersectsFrustum(this Box3d box, M44d projection)
if (min.Dot(n) + plane.W < 0 && max.Dot(n) + plane.W < 0) return false;

//near
plane = r2;
plane = r3 + r2;
n = plane.XYZ; box.GetMinMaxInDirection(n, out min, out max);
if (min.Dot(n) + plane.W < 0 && max.Dot(n) + plane.W < 0) return false;

Expand Down