Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Restore
run: dotnet restore --runtime ${{ matrix.rid }}
- name: Test
run: dotnet test -c Release --no-restore --runtime ${{ matrix.rid }} --collect:"XPlat Code Coverage" --results-directory ./coverage --logger:"trx"
run: dotnet test -c Release --no-restore --collect:"XPlat Code Coverage" --results-directory ./coverage --logger:"trx"
# TODO: https://github.com/dorny/test-reporter?tab=readme-ov-file#recommended-setup-for-public-repositories
#- name: Test Report
# uses: dorny/test-reporter@v1
Expand Down
Binary file added .silktouch/microsoft-clangsharp.stout
Binary file not shown.
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="NUnit" Version="4.4.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.v3" Version="3.2.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<!-- eng/benchmarks -->
<PackageVersion Include="BenchmarkDotNet" Version="0.15.6" />
Expand Down Expand Up @@ -44,4 +44,4 @@
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.NUnit" Version="31.6.0" />
</ItemGroup>
</Project>
</Project>
7 changes: 4 additions & 3 deletions generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"Jobs": {
"Microsoft": {
"Solution": "Silk.NET.sln",
"SourceProject": "TODO.csproj",
"TestProject": "tests/TODO.csproj",
"SourceProject": "sources/Win32/Win32/Silk.NET.Win32.csproj",
"TestProject": "tests/Win32/Win32/Silk.NET.Win32.UnitTests.csproj",
"DefaultLicenseHeader": "eng/silktouch/header.txt",
"Mods": [
"AddIncludes",
Expand All @@ -18,7 +18,8 @@
"sources/Windows/um/icm/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/icm/Windows.cs",
"sources/Gdiplus/um/gdiplustypes/GpRect.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpRect.cs",
"sources/Gdiplus/um/gdiplustypes/GpRectF.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpRectF.cs",
"sources/Gdiplus/um/gdiplustypes/GpPathData.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpPathData.cs"
"sources/Gdiplus/um/gdiplustypes/GpPathData.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpPathData.cs",
"sources/Windows/shared/strsafe/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/shared/strsafe/Windows.gen.cs"
},
"InputSourceRoot": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows",
"InputTestRoot": "eng/submodules/terrafx.interop.windows/tests/Interop/Windows",
Expand Down
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"sdk": {
"version": "10.0.100",
"rollForward": "major"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
89 changes: 47 additions & 42 deletions sources/Maths/Maths/Plane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Silk.NET.Maths
/// <typeparam name="T">The type used to store values.</typeparam>
[Serializable]
[DataContract]
public struct Plane<T>
: IEquatable<Plane<T>> where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
public struct Plane<T> : IEquatable<Plane<T>>
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
/// <summary>The normal vector of the Plane.</summary>
[DataMember]
Expand Down Expand Up @@ -58,22 +58,21 @@ public Plane(Vector4D<T> value)
/// <param name="value1">The first Plane to compare.</param>
/// <param name="value2">The second Plane to compare.</param>
/// <returns>True if the Planes are equal; False otherwise.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static bool operator ==(Plane<T> value1, Plane<T> value2)
=> value1.Normal == value2.Normal && Scalar.Equal(value1.Distance, value2.Distance);
[MethodImpl((MethodImplOptions)768)]
public static bool operator ==(Plane<T> value1, Plane<T> value2) =>
value1.Normal == value2.Normal && Scalar.Equal(value1.Distance, value2.Distance);

/// <summary>Returns a boolean indicating whether the two given Planes are not equal.</summary>
/// <param name="value1">The first Plane to compare.</param>
/// <param name="value2">The second Plane to compare.</param>
/// <returns>True if the Planes are not equal; False if they are equal.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static bool operator !=(Plane<T> value1, Plane<T> value2)
=> !(value1 == value2);
[MethodImpl((MethodImplOptions)768)]
public static bool operator !=(Plane<T> value1, Plane<T> value2) => !(value1 == value2);

/// <summary>Returns a boolean indicating whether the given Object is equal to this Plane instance.</summary>
/// <param name="obj">The Object to compare against.</param>
/// <returns>True if the Object is equal to this Plane; False otherwise.</returns>
[MethodImpl((MethodImplOptions) 768)]
[MethodImpl((MethodImplOptions)768)]
public override readonly bool Equals(object? obj)
{
return (obj is Plane<T> other) && Equals(other);
Expand All @@ -82,7 +81,7 @@ public override readonly bool Equals(object? obj)
/// <summary>Returns a boolean indicating whether the given Plane is equal to this Plane instance.</summary>
/// <param name="other">The Plane to compare this instance to.</param>
/// <returns>True if the other Plane is equal to this instance; False otherwise.</returns>
[MethodImpl((MethodImplOptions) 768)]
[MethodImpl((MethodImplOptions)768)]
public readonly bool Equals(Plane<T> other)
{
return Normal.Equals(other.Normal) && Scalar.Equal(Distance, other.Distance);
Expand All @@ -92,129 +91,135 @@ public readonly bool Equals(Plane<T> other)
/// <returns>The hash code.</returns>
public override readonly int GetHashCode()
{
return Normal.GetHashCode() + Distance.GetHashCode();
return HashCode.Combine(Normal.GetHashCode(), Distance.GetHashCode());
}

/// <summary>Returns a String representing this Plane instance.</summary>
/// <returns>The string representation.</returns>
public override readonly string ToString()
{
CultureInfo ci = CultureInfo.CurrentCulture;
return string.Format(ci, "{{Normal:{0} D:{1}}}", Normal.ToString(), Distance.ToString("G", ci));
return string.Format(
ci,
"{{Normal:{0} D:{1}}}",
Normal.ToString(),
Distance.ToString("G", ci)
);
}

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="Half"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="Half"/> matrix</returns>
public static explicit operator Plane<Half>(Plane<T> from)
=> new((Vector3D<Half>) from.Normal, Scalar.As<T, Half>(from.Distance));
public static explicit operator Plane<Half>(Plane<T> from) =>
new((Vector3D<Half>)from.Normal, Scalar.As<T, Half>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="float"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="float"/> matrix</returns>
public static explicit operator Plane<float>(Plane<T> from)
=> new((Vector3D<float>) from.Normal, Scalar.As<T, float>(from.Distance));
public static explicit operator Plane<float>(Plane<T> from) =>
new((Vector3D<float>)from.Normal, Scalar.As<T, float>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into <see cref="System.Numerics.Plane"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="System.Numerics"/> matrix</returns>
public static explicit operator System.Numerics.Plane(Plane<T> from)
=> new((System.Numerics.Vector3) from.Normal, Scalar.As<T, float>(from.Distance));
public static explicit operator System.Numerics.Plane(Plane<T> from) =>
new((System.Numerics.Vector3)from.Normal, Scalar.As<T, float>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="double"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="double"/> matrix</returns>
public static explicit operator Plane<double>(Plane<T> from)
=> new((Vector3D<double>) from.Normal, Scalar.As<T, double>(from.Distance));
public static explicit operator Plane<double>(Plane<T> from) =>
new((Vector3D<double>)from.Normal, Scalar.As<T, double>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="decimal"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="decimal"/> matrix</returns>
public static explicit operator Plane<decimal>(Plane<T> from)
=> new((Vector3D<decimal>) from.Normal, Scalar.As<T, decimal>(from.Distance));
public static explicit operator Plane<decimal>(Plane<T> from) =>
new((Vector3D<decimal>)from.Normal, Scalar.As<T, decimal>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="sbyte"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="sbyte"/> matrix</returns>
public static explicit operator Plane<sbyte>(Plane<T> from)
=> new((Vector3D<sbyte>) from.Normal, Scalar.As<T, sbyte>(from.Distance));
public static explicit operator Plane<sbyte>(Plane<T> from) =>
new((Vector3D<sbyte>)from.Normal, Scalar.As<T, sbyte>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="byte"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="byte"/> matrix</returns>
public static explicit operator Plane<byte>(Plane<T> from)
=> new((Vector3D<byte>) from.Normal, Scalar.As<T, byte>(from.Distance));
public static explicit operator Plane<byte>(Plane<T> from) =>
new((Vector3D<byte>)from.Normal, Scalar.As<T, byte>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="ushort"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="ushort"/> matrix</returns>
public static explicit operator Plane<ushort>(Plane<T> from)
=> new((Vector3D<ushort>) from.Normal, Scalar.As<T, ushort>(from.Distance));
public static explicit operator Plane<ushort>(Plane<T> from) =>
new((Vector3D<ushort>)from.Normal, Scalar.As<T, ushort>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="short"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="short"/> matrix</returns>
public static explicit operator Plane<short>(Plane<T> from)
=> new((Vector3D<short>) from.Normal, Scalar.As<T, short>(from.Distance));
public static explicit operator Plane<short>(Plane<T> from) =>
new((Vector3D<short>)from.Normal, Scalar.As<T, short>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="uint"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="uint"/> matrix</returns>
public static explicit operator Plane<uint>(Plane<T> from)
=> new((Vector3D<uint>) from.Normal, Scalar.As<T, uint>(from.Distance));
public static explicit operator Plane<uint>(Plane<T> from) =>
new((Vector3D<uint>)from.Normal, Scalar.As<T, uint>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="int"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="int"/> matrix</returns>
public static explicit operator Plane<int>(Plane<T> from)
=> new((Vector3D<int>) from.Normal, Scalar.As<T, int>(from.Distance));
public static explicit operator Plane<int>(Plane<T> from) =>
new((Vector3D<int>)from.Normal, Scalar.As<T, int>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="ulong"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="ulong"/> matrix</returns>
public static explicit operator Plane<ulong>(Plane<T> from)
=> new((Vector3D<ulong>) from.Normal, Scalar.As<T, ulong>(from.Distance));
public static explicit operator Plane<ulong>(Plane<T> from) =>
new((Vector3D<ulong>)from.Normal, Scalar.As<T, ulong>(from.Distance));

/// <summary>
/// Converts a <see cref="Plane{T}"/> into one with a <typeparamref name="T"/> of <see cref="long"/>
/// </summary>
/// <param name="from">The source matrix</param>
/// <returns>The <see cref="long"/> matrix</returns>
public static explicit operator Plane<long>(Plane<T> from)
=> new((Vector3D<long>) from.Normal, Scalar.As<T, long>(from.Distance));
public static explicit operator Plane<long>(Plane<T> from) =>
new((Vector3D<long>)from.Normal, Scalar.As<T, long>(from.Distance));

/// <summary>
/// Returns this plane casted to <typeparamref name="TOther"></typeparamref>
/// </summary>
/// <typeparam name="TOther">The type to cast to</typeparam>
/// <returns>The casted plane</returns>
public Plane<TOther> As<TOther>() where TOther : unmanaged, IFormattable, IEquatable<TOther>, IComparable<TOther>
public Plane<TOther> As<TOther>()
where TOther : unmanaged, IFormattable, IEquatable<TOther>, IComparable<TOther>
{
return new(Normal.As<TOther>(), Scalar.As<T, TOther>(Distance));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Loading
Loading