mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-27 13:38:25 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,80 @@
|
|||
// <auto-generated /> - edit Plane.numerics.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct floatPlane
|
||||
{
|
||||
/// <inheritdoc cref="Plane.CreateFromVertices(Vector3, Vector3, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static floatPlane CreateFromVertices(float3 point1, float3 point2, float3 point3)
|
||||
{
|
||||
var normal = float3.Normalize(float3.Cross(point2 - point1, point3 - point1));
|
||||
|
||||
return new floatPlane(normal, -float3.Dot(normal, point1));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.Dot(Plane, Vector4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Dot(floatPlane plane, float4 value)
|
||||
{
|
||||
return float4.Dot(plane.AsFloat4(), value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.DotCoordinate(Plane, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float DotCoordinate(floatPlane plane, float3 value)
|
||||
{
|
||||
return Dot(plane, new float4(value, 1));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.DotNormal(Plane, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float DotNormal(floatPlane plane, float3 value)
|
||||
{
|
||||
return float3.Dot(plane.Normal, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.Normalize(Plane)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static floatPlane Normalize(floatPlane value)
|
||||
{
|
||||
var lengthSquared = value.Normal.LengthSquared();
|
||||
if (lengthSquared == float.PositiveInfinity)
|
||||
return default;
|
||||
|
||||
var length = float.Sqrt(lengthSquared);
|
||||
return new floatPlane(value.Normal / length, value.D / length);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.Normalize(Plane)" />
|
||||
/// <remarks>Returns a zero plane if the input plane is zero</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static floatPlane NormalizeOrZero(floatPlane value)
|
||||
{
|
||||
var normalLengthSquared = value.Normal.LengthSquared();
|
||||
if (normalLengthSquared == 0)
|
||||
return new floatPlane(float3.Zero, 0);
|
||||
|
||||
if (normalLengthSquared == float.PositiveInfinity)
|
||||
return default;
|
||||
|
||||
var length = float.Sqrt(normalLengthSquared);
|
||||
return new floatPlane(value.Normal / length, value.D / length);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.Transform(Plane, Matrix4x4)" />
|
||||
// deliberately not AggressiveInlining, either overload: this one composes a full matrix Invert
|
||||
public static floatPlane Transform(floatPlane plane, float4x4 matrix)
|
||||
{
|
||||
float4x4.Invert(matrix, out var inverseMatrix);
|
||||
return FromFloat4(float4.Transform(plane.AsFloat4(), float4x4.Transpose(inverseMatrix)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Plane.Transform(Plane, Quaternion)" />
|
||||
public static floatPlane Transform(floatPlane plane, floatQuat rotation)
|
||||
{
|
||||
return FromFloat4(float4.Transform(plane.AsFloat4(), rotation));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue