mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-29 06:28:25 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
123
Brutal.Numerics/Vector/short3/short3.gen.cs
Normal file
123
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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue