Skip to content

Commit

Permalink
Allow Matrix4X4 Projection using Reversed-Z (#504)
Browse files Browse the repository at this point in the history
Co-authored-by: EmileGr <[email protected]>
  • Loading branch information
theprotonfactor and EmileGr authored Jun 5, 2021
1 parent b848fc8 commit d79b9ad
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 43 deletions.
34 changes: 0 additions & 34 deletions src/Maths/Silk.NET.Maths.Tests/Matrix4x4Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -955,17 +955,6 @@ public void Matrix4x4CreatePerspectiveTest3()
});
}

// A test for CreatePerspective (float, float, float, float)
// CreatePerspective test where near plane is beyond far plane
[Fact]
public void Matrix4x4CreatePerspectiveTest4()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
Matrix4X4<float> actual = Matrix4X4.CreatePerspective<float>(10, 10, 10, 1);
});
}

// A test for CreatePerspectiveFieldOfView (float, float, float, float)
[Fact]
public void Matrix4x4CreatePerspectiveFieldOfViewTest()
Expand Down Expand Up @@ -1031,17 +1020,6 @@ public void Matrix4x4CreatePerspectiveFieldOfViewTest4()
});
}

// A test for CreatePerspectiveFieldOfView (float, float, float, float)
// CreatePerspectiveFieldOfView test where nearPlaneDistance is larger than farPlaneDistance.
[Fact]
public void Matrix4x4CreatePerspectiveFieldOfViewTest5()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
Matrix4X4<float> mtx = Matrix4X4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 1, 10, 1);
});
}

// A test for CreatePerspectiveOffCenter (float, float, float, float, float, float)
[Fact]
public void Matrix4x4CreatePerspectiveOffCenterTest()
Expand Down Expand Up @@ -1091,18 +1069,6 @@ public void Matrix4x4CreatePerspectiveOffCenterTest2()
});
}

// A test for CreatePerspectiveOffCenter (float, float, float, float, float, float)
// CreatePerspectiveOffCenter test where test where nearPlaneDistance is larger than farPlaneDistance.
[Fact]
public void Matrix4x4CreatePerspectiveOffCenterTest3()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
float left = 10.0f, right = 90.0f, bottom = 20.0f, top = 180.0f;
Matrix4X4<float> actual = Matrix4X4.CreatePerspectiveOffCenter(left, right, bottom, top, 10, 1);
});
}

// A test for Invert (Matrix4X4<float>)
// Non invertible matrix - determinant is zero - singular matrix
[Fact]
Expand Down
Binary file added src/Maths/Silk.NET.Maths/Maths - Shortcut.lnk
Binary file not shown.
9 changes: 0 additions & 9 deletions src/Maths/Silk.NET.Maths/Matrix4X4.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ public static Matrix4X4<T> CreatePerspective<T>(T width, T height, T nearPlaneDi
if (!Scalar.GreaterThan(farPlaneDistance, Scalar<T>.Zero))
throw new ArgumentOutOfRangeException(nameof(farPlaneDistance));

if (Scalar.GreaterThanOrEqual(nearPlaneDistance, farPlaneDistance))
throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance));

Matrix4X4<T> result = default;

result.M11 = Scalar.Divide(Scalar.Multiply(Scalar<T>.Two, nearPlaneDistance), width);
Expand Down Expand Up @@ -376,9 +373,6 @@ public static Matrix4X4<T> CreatePerspectiveFieldOfView<T>(T fieldOfView, T aspe
if (!Scalar.GreaterThan(farPlaneDistance, Scalar<T>.Zero))
throw new ArgumentOutOfRangeException(nameof(farPlaneDistance));

if (Scalar.GreaterThanOrEqual(nearPlaneDistance, farPlaneDistance))
throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance));

T yScale = Scalar.Reciprocal(Scalar.Tan(Scalar.Divide(fieldOfView, Scalar<T>.Two)));
T xScale = Scalar.Divide(yScale, aspectRatio);

Expand Down Expand Up @@ -418,9 +412,6 @@ public static Matrix4X4<T> CreatePerspectiveOffCenter<T>(T left, T right, T bott
if (!Scalar.GreaterThan(farPlaneDistance, Scalar<T>.Zero))
throw new ArgumentOutOfRangeException(nameof(farPlaneDistance));

if (Scalar.GreaterThanOrEqual(nearPlaneDistance, farPlaneDistance))
throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance));

Matrix4X4<T> result = default;

result.M11 = Scalar.Divide(Scalar.Multiply(Scalar<T>.Two, nearPlaneDistance), Scalar.Subtract(right, left));
Expand Down

0 comments on commit d79b9ad

Please sign in to comment.