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
10 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
// <auto-generated /> - edit Vector.copy.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void CopyTo(Span<short> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
throw new ArgumentException("Length must be at least 3.", nameof(destination));
|
||||
|
||||
Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref MemoryMarshal.GetReference(destination)), this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool TryCopyTo(Span<short> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
return false;
|
||||
|
||||
Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref MemoryMarshal.GetReference(destination)), this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// <auto-generated /> - edit Vector.equality.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(X, Y, Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(short3 other)
|
||||
{
|
||||
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly override bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return obj is short3 other && Equals(other);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(short3 a, short3 b)
|
||||
{
|
||||
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(short3 a, short3 b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
// <auto-generated /> - edit Vector.format.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<short3>
|
||||
{
|
||||
/// <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(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}{separator} {Z.ToString(format, formatProvider)}>";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return StringHelpers.TryFormat<short3, short>(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<short3, short>(this, destination, out bytesWritten, format, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static short3 Parse(string s, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), NumberStyles.Integer, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static short3 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
|
||||
{
|
||||
return Parse(s, NumberStyles.Integer, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static short3 Parse(string s, NumberStyles style, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), style, provider);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
|
||||
public static short3 Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider)
|
||||
{
|
||||
if (!TryParse(s, style, provider, out var result))
|
||||
throw new FormatException($"'{s}' is not in a valid short3 format.");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out short3)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out short3 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), NumberStyles.Integer, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out short3)" />
|
||||
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out short3 result)
|
||||
{
|
||||
return TryParse(s, NumberStyles.Integer, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out short3)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out short3 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), style, provider, out result);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <returns>true if the input parsed as a short3.</returns>
|
||||
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out short3 result)
|
||||
{
|
||||
return StringHelpers.TryParse<short3, short>(s, style, provider, out result);
|
||||
}
|
||||
}
|
||||
123
brutal.numerics/Brutal.Numerics/Vector/short3/short3.gen.cs
Normal file
123
brutal.numerics/Brutal.Numerics/Vector/short3/short3.gen.cs
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// <auto-generated /> - edit Vector.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
/// <summary>
|
||||
/// Implements a 3D vector with short components.
|
||||
/// </summary>
|
||||
[DebuggerTypeProxy(typeof(VectorDebugView3<short3, short, float>))]
|
||||
public partial struct short3 : IVector3<short3, short>
|
||||
, ISignedIntegerVector<short3, short, int, float>
|
||||
, ICrossProduct<short3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static int ComponentSize => sizeof(short);
|
||||
|
||||
/// <summary>Gets the number of components.</summary>
|
||||
public static int ComponentCount => 3;
|
||||
|
||||
/// <inheritdoc cref="Vector3.X" />
|
||||
[XmlAttribute]
|
||||
public short X;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Y" />
|
||||
[XmlAttribute]
|
||||
public short Y;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Z" />
|
||||
[XmlAttribute]
|
||||
public short Z;
|
||||
|
||||
short IVector3<short3, short>.X { readonly get => X; set => X = value; }
|
||||
|
||||
short IVector3<short3, short>.Y { readonly get => Y; set => Y = value; }
|
||||
|
||||
short IVector3<short3, short>.Z { readonly get => Z; set => Z = value; }
|
||||
|
||||
/// <inheritdoc cref="Vector3(float, float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short3(short x, short y, short z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short3(short xyz)
|
||||
: this(xyz, xyz, xyz) { }
|
||||
|
||||
/// <inheritdoc cref="Vector3(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short3(short2 xy, short 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 short3(ReadOnlySpan<short> span)
|
||||
{
|
||||
if (span.Length < 3)
|
||||
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
|
||||
|
||||
this = Unsafe.ReadUnaligned<short3>(ref Unsafe.As<short, byte>(ref MemoryMarshal.GetReference(span)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="short3(ReadOnlySpan{short})" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static short3 IComponentTuple<short3, short>.Create(ReadOnlySpan<short> span) => new(span);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static short3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static short3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static short3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <inheritdoc />
|
||||
public short 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 short x, out short y, out short z)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<short> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<short3, short>(ref this), 3);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<short> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<short3, short>(ref Unsafe.AsRef(in this)), 3);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float Length()
|
||||
{
|
||||
return (float)double.Sqrt((double)X * X + (double)Y * Y + (double)Z * Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly int LengthSquared()
|
||||
{
|
||||
return Dot(this, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Distance" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Distance(short3 a, short3 b)
|
||||
{
|
||||
return (float)double.Sqrt(((double)a.X - b.X) * ((double)a.X - b.X) + ((double)a.Y - b.Y) * ((double)a.Y - b.Y) + ((double)a.Z - b.Z) * ((double)a.Z - b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.DistanceSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int DistanceSquared(short3 a, short3 b)
|
||||
{
|
||||
return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y) + (a.Z - b.Z) * (a.Z - b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Dot(short3 a, short3 b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y + a.Z * b.Z;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// <auto-generated /> - edit Vector.math.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
/// <inheritdoc cref="Vector3.Cross" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Cross(short3 a, short3 b)
|
||||
{
|
||||
return new(
|
||||
(short)(a.Y * b.Z - a.Z * b.Y),
|
||||
(short)(a.Z * b.X - a.X * b.Z),
|
||||
(short)(a.X * b.Y - a.Y * b.X));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// IBinaryNumber
|
||||
public partial struct short3 : IBinaryNumber<short3>
|
||||
{
|
||||
/// <summary>Determines if every component of a value is a power of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool IBinaryNumber<short3>.IsPow2(short3 value)
|
||||
{
|
||||
return short.IsPow2(value.X) && short.IsPow2(value.Y) && short.IsPow2(value.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryNumber{TSelf}.Log2" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Log2(short3 value)
|
||||
{
|
||||
return new short3(short.Log2(value.X), short.Log2(value.Y), short.Log2(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator &(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X & b.X), (short)(a.Y & b.Y), (short)(a.Z & b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator |(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X | b.X), (short)(a.Y | b.Y), (short)(a.Z | b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator ^(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X ^ b.X), (short)(a.Y ^ b.Y), (short)(a.Z ^ b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator ~(short3 value)
|
||||
{
|
||||
return new((short)(~value.X), (short)(~value.Y), (short)(~value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
|
||||
public partial struct short3
|
||||
{
|
||||
/// <summary>Determines which components of a value are powers of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsPow2(short3 value)
|
||||
{
|
||||
return new bool3(short.IsPow2(value.X), short.IsPow2(value.Y), short.IsPow2(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// the good bits from IBinaryInteger - declared on IIntegerVector
|
||||
public partial struct short3
|
||||
{
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.PopCount" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 PopCount(short3 value)
|
||||
{
|
||||
return new short3(short.PopCount(value.X), short.PopCount(value.Y), short.PopCount(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.LeadingZeroCount" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 LeadingZeroCount(short3 value)
|
||||
{
|
||||
return new short3(short.LeadingZeroCount(value.X), short.LeadingZeroCount(value.Y), short.LeadingZeroCount(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.TrailingZeroCount" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 TrailingZeroCount(short3 value)
|
||||
{
|
||||
return new short3(short.TrailingZeroCount(value.X), short.TrailingZeroCount(value.Y), short.TrailingZeroCount(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateLeft" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 RotateLeft(short3 value, int rotateAmount)
|
||||
{
|
||||
return new short3(short.RotateLeft(value.X, rotateAmount), short.RotateLeft(value.Y, rotateAmount), short.RotateLeft(value.Z, rotateAmount));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBinaryInteger{TSelf}.RotateRight" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 RotateRight(short3 value, int rotateAmount)
|
||||
{
|
||||
return new short3(short.RotateRight(value.X, rotateAmount), short.RotateRight(value.Y, rotateAmount), short.RotateRight(value.Z, rotateAmount));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,438 @@
|
|||
// <auto-generated /> - edit Vector.numerics.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// INumberBase
|
||||
public partial struct short3 : INumberBase<short3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static short3 Zero => new(0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static short3 One => new(1);
|
||||
|
||||
static short3 IAdditiveIdentity<short3, short3>.AdditiveIdentity => Zero;
|
||||
|
||||
static short3 IMultiplicativeIdentity<short3, short3>.MultiplicativeIdentity => One;
|
||||
|
||||
static int INumberBase<short3>.Radix => 2; // every component type is binary
|
||||
|
||||
/// <inheritdoc cref="Vector3.Abs" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Abs(short3 value)
|
||||
{
|
||||
return new short3(WrappingAbs(value.X), WrappingAbs(value.Y), WrappingAbs(value.Z));
|
||||
}
|
||||
|
||||
/* |MinValue| is unrepresentable, so that lane keeps MinValue and Abs can return a NEGATIVE
|
||||
* number. Deliberate, settled 2026-08-25: Math.Abs throws there instead, which kills a whole
|
||||
* vector for one pathological lane. Everyone else wraps - HLSL, GLSL, SPIR-V SAbs, LLVM's
|
||||
* llvm.abs on its non-poison branch, and .NET's own Vector128.Abs, whose Scalar<T>.Abs even
|
||||
* carries the comment "avoid Math.Abs for integers since it throws for MinValue".
|
||||
* unchecked is explicit because the wrap IS the contract here: on the narrow types the
|
||||
* truncating cast is what performs it (-short.MinValue widens to 32768, which no short holds),
|
||||
* so this must not depend on the project's overflow setting. */
|
||||
private static short WrappingAbs(short value) =>
|
||||
unchecked((short)(value < 0 ? -value : value));
|
||||
|
||||
static bool INumberBase<short3>.IsCanonical(short3 value) => true;
|
||||
|
||||
static bool INumberBase<short3>.IsComplexNumber(short3 value) => false;
|
||||
|
||||
static bool INumberBase<short3>.IsImaginaryNumber(short3 value) => false;
|
||||
|
||||
/// <summary>Determines if every component of a value is zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<short3>.IsZero(short3 value)
|
||||
{
|
||||
return value == Zero;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<short3>.IsEvenInteger(short3 value)
|
||||
{
|
||||
return (value.X & 1) == 0 && (value.Y & 1) == 0 && (value.Z & 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<short3>.IsOddInteger(short3 value)
|
||||
{
|
||||
return (value.X & 1) == 1 && (value.Y & 1) == 1 && (value.Z & 1) == 1;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is negative.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<short3>.IsNegative(short3 value)
|
||||
{
|
||||
return value.X < 0 && value.Y < 0 && value.Z < 0;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is positive.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<short3>.IsPositive(short3 value)
|
||||
{
|
||||
return value.X >= 0 && value.Y >= 0 && value.Z >= 0;
|
||||
}
|
||||
|
||||
static bool INumberBase<short3>.IsFinite(short3 value) => true;
|
||||
|
||||
static bool INumberBase<short3>.IsInfinity(short3 value) => false;
|
||||
|
||||
static bool INumberBase<short3>.IsNegativeInfinity(short3 value) => false;
|
||||
|
||||
static bool INumberBase<short3>.IsPositiveInfinity(short3 value) => false;
|
||||
|
||||
static bool INumberBase<short3>.IsInteger(short3 value) => true;
|
||||
|
||||
static bool INumberBase<short3>.IsRealNumber(short3 value) => true;
|
||||
|
||||
static bool INumberBase<short3>.IsNaN(short3 value) => false;
|
||||
|
||||
static bool INumberBase<short3>.IsNormal(short3 value) => value.X != 0 && value.Y != 0 && value.Z != 0;
|
||||
|
||||
static bool INumberBase<short3>.IsSubnormal(short3 value) => false;
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 MaxMagnitude(short3 a, short3 b)
|
||||
{
|
||||
return new short3(short.MaxMagnitude(a.X, b.X), short.MaxMagnitude(a.Y, b.Y), short.MaxMagnitude(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 MaxMagnitudeNumber(short3 a, short3 b)
|
||||
{
|
||||
return new short3(short.MaxMagnitude(a.X, b.X), short.MaxMagnitude(a.Y, b.Y), short.MaxMagnitude(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 MinMagnitude(short3 a, short3 b)
|
||||
{
|
||||
return new short3(short.MinMagnitude(a.X, b.X), short.MinMagnitude(a.Y, b.Y), short.MinMagnitude(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 MinMagnitudeNumber(short3 a, short3 b)
|
||||
{
|
||||
return new short3(short.MinMagnitude(a.X, b.X), short.MinMagnitude(a.Y, b.Y), short.MinMagnitude(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Add" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Add(short3 a, short3 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Divide(Vector3, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Divide(short3 a, short3 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Multiply(Vector3, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Multiply(short3 a, short3 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Negate" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Negate(short3 value)
|
||||
{
|
||||
return -value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Subtract" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Subtract(short3 a, short3 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator +(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X + b.X), (short)(a.Y + b.Y), (short)(a.Z + b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator -(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X - b.X), (short)(a.Y - b.Y), (short)(a.Z - b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator *(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X * b.X), (short)(a.Y * b.Y), (short)(a.Z * b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator /(short3 a, short3 b)
|
||||
{
|
||||
return new((short)(a.X / b.X), (short)(a.Y / b.Y), (short)(a.Z / b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator -(short3 a)
|
||||
{
|
||||
return new((short)(-a.X), (short)(-a.Y), (short)(-a.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator +(short3 a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
// ++/-- are well-defined (+/- One) but a footgun on a concrete vector: generic-plane only.
|
||||
|
||||
static short3 IIncrementOperators<short3>.operator ++(short3 value) => value + One;
|
||||
|
||||
static short3 IDecrementOperators<short3>.operator --(short3 value) => value - One;
|
||||
|
||||
|
||||
static bool INumberBase<short3>.TryConvertFromChecked<TOther>(TOther value, out short3 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<short3, short, TOther, NumberConversion.Checked>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<short3>.TryConvertToChecked<TOther>(short3 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<short3>.TryConvertFromSaturating<TOther>(TOther value, out short3 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<short3, short, TOther, NumberConversion.Saturating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<short3>.TryConvertToSaturating<TOther>(short3 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<short3>.TryConvertFromTruncating<TOther>(TOther value, out short3 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<short3, short, TOther, NumberConversion.Truncating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<short3>.TryConvertToTruncating<TOther>(short3 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// IMultiplyOperators<TSelf, TComponent, TSelf>, IDivisionOperators<TSelf, TComponent, TSelf>
|
||||
public partial struct short3
|
||||
: IMultiplyOperators<short3, short, short3>
|
||||
, IDivisionOperators<short3, short, short3>
|
||||
{
|
||||
/// <inheritdoc cref="Vector3.Divide(Vector3, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Divide(short3 a, short b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Multiply(Vector3, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Multiply(short3 a, short b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Multiply(float, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Multiply(short a, short3 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator *(short3 a, short b)
|
||||
{
|
||||
return new((short)(a.X * b), (short)(a.Y * b), (short)(a.Z * b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator /(short3 a, short b)
|
||||
{
|
||||
return new((short)(a.X / b), (short)(a.Y / b), (short)(a.Z / b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator *(short a, short3 b)
|
||||
{
|
||||
return new((short)(a * b.X), (short)(a * b.Y), (short)(a * b.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// INumber
|
||||
public partial struct short3 : INumber<short3>
|
||||
{
|
||||
/// <inheritdoc cref="Vector3.Clamp" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Clamp(short3 value, short3 min, short3 max)
|
||||
{
|
||||
// HLSL contract when min > max: max wins (clamp is Max-then-Min); pinned in
|
||||
// Clamp_InvertedBounds_MatchesBcl. NOT scalar T.Clamp, which throws on inversion.
|
||||
return Min(Max(value, min), max);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Max" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Max(short3 a, short3 b)
|
||||
{
|
||||
return new(short.Max(a.X, b.X), short.Max(a.Y, b.Y), short.Max(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Min" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 Min(short3 a, short3 b)
|
||||
{
|
||||
return new(short.Min(a.X, b.X), short.Min(a.Y, b.Y), short.Min(a.Z, b.Z));
|
||||
}
|
||||
|
||||
static short3 INumber<short3>.MaxNumber(short3 a, short3 b) => Max(a, b);
|
||||
|
||||
static short3 INumber<short3>.MinNumber(short3 a, short3 b) => Min(a, b);
|
||||
|
||||
/// <summary>Copies, componentwise, the sign of <paramref name="sign" /> onto the magnitude of <paramref name="value" />.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 CopySign(short3 value, short3 sign)
|
||||
{
|
||||
return new short3(short.CopySign(value.X, sign.X), short.CopySign(value.Y, sign.Y), short.CopySign(value.Z, sign.Z));
|
||||
}
|
||||
|
||||
// the Native variants permit either NaN/signed-zero behavior - forwarding is always legal
|
||||
static short3 INumber<short3>.ClampNative(short3 value, short3 min, short3 max) => Clamp(value, min, max);
|
||||
|
||||
static short3 INumber<short3>.MaxNative(short3 a, short3 b) => Max(a, b);
|
||||
|
||||
static short3 INumber<short3>.MinNative(short3 a, short3 b) => Min(a, b);
|
||||
|
||||
// Sign's int return cannot hold a per-lane answer, and a collapsed one would lie for mixed signs
|
||||
static int INumber<short3>.Sign(short3 value) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no scalar sign.");
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static short3 operator %(short3 a, short3 b)
|
||||
{
|
||||
return new short3((short)(a.X % b.X), (short)(a.Y % b.Y), (short)(a.Z % b.Z));
|
||||
}
|
||||
|
||||
int IComparable.CompareTo(object? obj) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no total order.");
|
||||
|
||||
int IComparable<short3>.CompareTo(short3 other) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<short3, short3, bool>.operator <(short3 a, short3 b) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<short3, short3, bool>.operator <=(short3 a, short3 b) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<short3, short3, bool>.operator >(short3 a, short3 b) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<short3, short3, bool>.operator >=(short3 a, short3 b) =>
|
||||
throw new NotSupportedException($"{nameof(short3)} has no total order.");
|
||||
}
|
||||
|
||||
// IComponentwiseComparison + the componentwise predicate masks (no interface to mirror)
|
||||
public partial struct short3 : IComponentwiseComparison<short3, bool3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator <(short3 a, short3 b)
|
||||
{
|
||||
return new bool3(a.X < b.X, a.Y < b.Y, a.Z < b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator <=(short3 a, short3 b)
|
||||
{
|
||||
return new bool3(a.X <= b.X, a.Y <= b.Y, a.Z <= b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator >(short3 a, short3 b)
|
||||
{
|
||||
return new bool3(a.X > b.X, a.Y > b.Y, a.Z > b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator >=(short3 a, short3 b)
|
||||
{
|
||||
return new bool3(a.X >= b.X, a.Y >= b.Y, a.Z >= b.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsZero(short3 value)
|
||||
{
|
||||
return new bool3(value.X == 0, value.Y == 0, value.Z == 0);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsEvenInteger(short3 value)
|
||||
{
|
||||
return new bool3(short.IsEvenInteger(value.X), short.IsEvenInteger(value.Y), short.IsEvenInteger(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsOddInteger(short3 value)
|
||||
{
|
||||
return new bool3(short.IsOddInteger(value.X), short.IsOddInteger(value.Y), short.IsOddInteger(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are negative.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsNegative(short3 value)
|
||||
{
|
||||
return new bool3(short.IsNegative(value.X), short.IsNegative(value.Y), short.IsNegative(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are positive.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsPositive(short3 value)
|
||||
{
|
||||
return new bool3(short.IsPositive(value.X), short.IsPositive(value.Y), short.IsPositive(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// ISignedNumber
|
||||
public partial struct short3 : ISignedNumber<short3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static short3 NegativeOne => new(-1);
|
||||
}
|
||||
210
brutal.numerics/Brutal.Numerics/Vector/short3/short3.pack.gen.cs
Normal file
210
brutal.numerics/Brutal.Numerics/Vector/short3/short3.pack.gen.cs
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
// <auto-generated /> - edit Vector.pack.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
public static short3 Unpack(in sbyte3 vector, Func<sbyte, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Unpack(in byte3 vector, Func<byte, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Pack(in ushort3 vector, Func<ushort, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Pack(in int3 vector, Func<int, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Pack(in uint3 vector, Func<uint, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Pack(in float3 vector, Func<float, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Pack(in double3 vector, Func<double, short> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out short3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static short3 Unpack(in sbyte3 vector, Unpack.Integer mode = Numerics.Unpack.Integer.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.SByte.ToShort(mode));
|
||||
}
|
||||
|
||||
public static short3 Unpack(in byte3 vector, Unpack.IntegerMixed mode = Numerics.Unpack.IntegerMixed.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Byte.ToShort(mode));
|
||||
}
|
||||
|
||||
public static short3 Pack(in ushort3 vector, Pack.IntegerMixed mode = Numerics.Pack.IntegerMixed.Cast)
|
||||
{
|
||||
return Pack(vector, PackUtils.UShort.ToShort(mode));
|
||||
}
|
||||
|
||||
public static short3 Pack(in int3 vector, Pack.Integer mode = Numerics.Pack.Integer.Cast)
|
||||
{
|
||||
return Pack(vector, PackUtils.Int.ToShort(mode));
|
||||
}
|
||||
|
||||
public static short3 Pack(in uint3 vector, Pack.IntegerMixed mode = Numerics.Pack.IntegerMixed.Cast)
|
||||
{
|
||||
return Pack(vector, PackUtils.UInt.ToShort(mode));
|
||||
}
|
||||
|
||||
public static short3 Pack(in float3 vector, Pack.Float mode = Numerics.Pack.Float.Truncate)
|
||||
{
|
||||
return Pack(vector, PackUtils.Float.ToShort(mode));
|
||||
}
|
||||
|
||||
public static short3 Pack(in double3 vector, Pack.Float mode = Numerics.Pack.Float.Truncate)
|
||||
{
|
||||
return Pack(vector, PackUtils.Double.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte3> source,
|
||||
Span<short3> destination,
|
||||
Func<sbyte, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte3> source,
|
||||
Span<short3> destination,
|
||||
Func<byte, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<ushort3> source,
|
||||
Span<short3> destination,
|
||||
Func<ushort, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<int3> source,
|
||||
Span<short3> destination,
|
||||
Func<int, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<uint3> source,
|
||||
Span<short3> destination,
|
||||
Func<uint, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<float3> source,
|
||||
Span<short3> destination,
|
||||
Func<float, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<double3> source,
|
||||
Span<short3> destination,
|
||||
Func<double, short> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte3> source,
|
||||
Span<short3> destination,
|
||||
Unpack.Integer mode = Numerics.Unpack.Integer.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.SByte.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte3> source,
|
||||
Span<short3> destination,
|
||||
Unpack.IntegerMixed mode = Numerics.Unpack.IntegerMixed.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Byte.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<ushort3> source,
|
||||
Span<short3> destination,
|
||||
Pack.IntegerMixed mode = Numerics.Pack.IntegerMixed.Cast
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.UShort.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<int3> source,
|
||||
Span<short3> destination,
|
||||
Pack.Integer mode = Numerics.Pack.Integer.Cast
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.Int.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<uint3> source,
|
||||
Span<short3> destination,
|
||||
Pack.IntegerMixed mode = Numerics.Pack.IntegerMixed.Cast
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.UInt.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<float3> source,
|
||||
Span<short3> destination,
|
||||
Pack.Float mode = Numerics.Pack.Float.Truncate
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.Float.ToShort(mode));
|
||||
}
|
||||
|
||||
public static void PackSpan(
|
||||
in ReadOnlySpan<double3> source,
|
||||
Span<short3> destination,
|
||||
Pack.Float mode = Numerics.Pack.Float.Truncate
|
||||
)
|
||||
{
|
||||
PackSpan(source, destination, PackUtils.Double.ToShort(mode));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,400 @@
|
|||
// <auto-generated /> - edit Vector.swizzle.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public short2 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 short2 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 short2 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 short2 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 short2 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 short2 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 short3 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 short3 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 short3 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 short3 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 short3 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 short3 ZYX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, Y, X);
|
||||
set
|
||||
{
|
||||
Z = value.X;
|
||||
Y = value.Y;
|
||||
X = value.Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct short3
|
||||
{
|
||||
/// <summary>
|
||||
/// The Red component of the vector (synonym for X).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public short R
|
||||
{
|
||||
readonly get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Green component of the vector (synonym for Y).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public short G
|
||||
{
|
||||
readonly get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Blue component of the vector (synonym for Z).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public short B
|
||||
{
|
||||
readonly get => Z;
|
||||
set => Z = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public short2 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 short2 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 short2 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 short2 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 short2 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 short2 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 short3 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 short3 RBG
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(X, Z, Y);
|
||||
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 short3 GRB
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X, Z);
|
||||
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 short3 GBR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, Z, X);
|
||||
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 short3 BRG
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, X, Y);
|
||||
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 short3 BGR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, Y, X);
|
||||
set
|
||||
{
|
||||
B = value.R;
|
||||
G = value.G;
|
||||
R = value.B;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue