SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d
7 changed files with 768360 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 3.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
return true;
}
}

View file

@ -0,0 +1,41 @@
// <auto-generated /> - edit Vector.equality.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y, Z);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(bool3 other)
{
return X == other.X && Y == other.Y && Z == other.Z;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is bool3 other && Equals(other);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(bool3 a, bool3 b)
{
return a.Equals(b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(bool3 a, bool3 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,38 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3 : ISpanFormattable, IUtf8SpanFormattable
{
/// <inheritdoc />
public readonly override string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
/// <inheritdoc cref="Vector3.ToString(string?)" />
public readonly string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <inheritdoc />
public readonly string ToString(string? format, IFormatProvider? formatProvider)
{
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
return $"<{X.ToString()}{separator} {Y.ToString()}{separator} {Z.ToString()}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool3, bool>(this, destination, out charsWritten, format, provider);
}
/// <inheritdoc />
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool3, bool>(this, destination, out bytesWritten, format, provider);
}
}

View file

@ -0,0 +1,121 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 3D vector with bool components.
/// </summary>
public partial struct bool3 : IVector3<bool3, bool>
, IBooleanVector<bool3, bool>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(bool);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 3;
/// <inheritdoc cref="Vector3.X" />
[XmlAttribute]
public bool X;
/// <inheritdoc cref="Vector3.Y" />
[XmlAttribute]
public bool Y;
/// <inheritdoc cref="Vector3.Z" />
[XmlAttribute]
public bool Z;
bool IVector3<bool3, bool>.X { readonly get => X; set => X = value; }
bool IVector3<bool3, bool>.Y { readonly get => Y; set => Y = value; }
bool IVector3<bool3, bool>.Z { readonly get => Z; set => Z = value; }
/// <inheritdoc cref="Vector3(float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(bool x, bool y, bool z)
{
X = x;
Y = y;
Z = z;
}
/// <inheritdoc cref="Vector3(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(bool xyz)
: this(xyz, xyz, xyz) { }
/// <inheritdoc cref="Vector3(Vector2, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(bool2 xy, bool z)
: this(xy.X, xy.Y, z) { }
/// <summary>Creates a vector from the leading 3 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 3, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 3 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool3(ReadOnlySpan<bool> span)
{
if (span.Length < 3)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
this = Unsafe.ReadUnaligned<bool3>(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="bool3(ReadOnlySpan{bool})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool3 IComponentTuple<bool3, bool>.Create(ReadOnlySpan<bool> span) => new(span);
/// <inheritdoc />
public static bool3 UnitX => new(true, false, false);
/// <inheritdoc />
public static bool3 UnitY => new(false, true, false);
/// <inheritdoc />
public static bool3 UnitZ => new(false, false, true);
/// <inheritdoc />
public bool this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out bool x, out bool y, out bool z)
{
x = X;
y = Y;
z = Z;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<bool> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<bool3, bool>(ref this), 3);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<bool> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<bool3, bool>(ref Unsafe.AsRef(in this)), 3);
}
}

View file

@ -0,0 +1,13 @@
// <auto-generated /> - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <inheritdoc />
public readonly bool Any => X || Y || Z;
/// <inheritdoc />
public readonly bool All => X && Y && Z;
}

View file

@ -0,0 +1,53 @@
// <auto-generated /> - edit Vector.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
// INumberBase
public partial struct bool3
{
/// <inheritdoc />
public static bool3 Zero => new(false);
/// <inheritdoc />
public static bool3 One => new(true);
}
// IBitwiseOperators
public partial struct bool3 : IBitwiseOperators<bool3, bool3, bool3>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator |(bool3 a, bool3 b)
{
return new bool3(a.X | b.X, a.Y | b.Y, a.Z | b.Z);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator &(bool3 a, bool3 b)
{
return new bool3(a.X & b.X, a.Y & b.Y, a.Z & b.Z);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator ^(bool3 a, bool3 b)
{
return new bool3(a.X ^ b.X, a.Y ^ b.Y, a.Z ^ b.Z);
}
/// <inheritdoc cref="IBitwiseOperators{TSelf, TOther, TResult}.op_OnesComplement" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 operator !(bool3 value)
{
return new bool3(!value.X, !value.Y, !value.Z);
}
// bool has no ~; the interface's complement is componentwise logical not
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool3 IBitwiseOperators<bool3, bool3, bool3>.operator ~(bool3 value)
{
return !value;
}
}

View file

@ -0,0 +1,400 @@
// <auto-generated /> - edit Vector.swizzle.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool3
{
/// <summary>
/// Swizzle readonly getter/setter for the X and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool2 XY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(X, Y);
set
{
X = value.X;
Y = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the X and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool2 XZ
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(X, Z);
set
{
X = value.X;
Z = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y and X components of the vector.
/// </summary>
[XmlIgnore]
public bool2 YX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, X);
set
{
Y = value.X;
X = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool2 YZ
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, Z);
set
{
Y = value.X;
Z = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z and X components of the vector.
/// </summary>
[XmlIgnore]
public bool2 ZX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, X);
set
{
Z = value.X;
X = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool2 ZY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, Y);
set
{
Z = value.X;
Y = value.Y;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the X, Y and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool3 XYZ
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the X, Z and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool3 XZY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(X, Z, Y);
set
{
X = value.X;
Z = value.Y;
Y = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y, X and Z components of the vector.
/// </summary>
[XmlIgnore]
public bool3 YXZ
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, X, Z);
set
{
Y = value.X;
X = value.Y;
Z = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Y, Z and X components of the vector.
/// </summary>
[XmlIgnore]
public bool3 YZX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, Z, X);
set
{
Y = value.X;
Z = value.Y;
X = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z, X and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool3 ZXY
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, X, Y);
set
{
Z = value.X;
X = value.Y;
Y = value.Z;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Z, Y and X components of the vector.
/// </summary>
[XmlIgnore]
public bool3 ZYX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Z, Y, X);
set
{
Z = value.X;
Y = value.Y;
X = value.Z;
}
}
}
public partial struct bool3
{
/// <summary>
/// The Red component of the vector (synonym for X).
/// </summary>
[XmlIgnore]
public bool R
{
readonly get => X;
set => X = value;
}
/// <summary>
/// The Green component of the vector (synonym for Y).
/// </summary>
[XmlIgnore]
public bool G
{
readonly get => Y;
set => Y = value;
}
/// <summary>
/// The Blue component of the vector (synonym for Z).
/// </summary>
[XmlIgnore]
public bool B
{
readonly get => Z;
set => Z = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool2 RG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(R, G);
set
{
R = value.R;
G = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Red and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool2 RB
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(R, B);
set
{
R = value.R;
B = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool2 GR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, R);
set
{
G = value.R;
R = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool2 GB
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, B);
set
{
G = value.R;
B = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool2 BR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, R);
set
{
B = value.R;
R = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool2 BG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, G);
set
{
B = value.R;
G = value.G;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Red, Green, and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool3 RGB
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Red, Blue, and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool3 RBG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(R, B, G);
set
{
R = value.R;
B = value.G;
G = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green, Red, and Blue components of the vector.
/// </summary>
[XmlIgnore]
public bool3 GRB
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, R, B);
set
{
G = value.R;
R = value.G;
B = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Green, Blue, and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool3 GBR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, B, R);
set
{
G = value.R;
B = value.G;
R = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue, Red, and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool3 BRG
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, R, G);
set
{
B = value.R;
R = value.G;
G = value.B;
}
}
/// <summary>
/// Swizzle readonly getter/setter for the Blue, Green, and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool3 BGR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(B, G, R);
set
{
B = value.R;
G = value.G;
R = value.B;
}
}
}