using System.Diagnostics; using System.Runtime.InteropServices; using ComputeSharp.Exceptions; namespace ComputeSharp { /// /// A that maps the HLSL type. /// [DebuggerDisplay("({X}, {Y}, {Z})")] [StructLayout(LayoutKind.Sequential, Size = sizeof(int) * 3)] public partial struct Int3 { /// /// Gets an value with all components set to 0. /// public static Int3 Zero => 0; /// /// Gets an value with all components set to 1. /// public static Int3 One => 1; /// /// Gets an value with the component set to 1, and the others to 0. /// public static Int3 UnitX => new(1, 0, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static Int3 UnitY => new(0, 1, 0); /// /// Gets an value with the component set to 1, and the others to 0. /// public static Int3 UnitZ => new(0, 0, 1); /// /// Creates a new instance with the specified parameters. /// /// The value to assign to the first vector component. /// The value to assign to the second vector component. /// The value to assign to the third vector component. public Int3(int x, int y, int z) { X = x; Y = y; Z = z; } /// /// Gets or sets the value of the first vector component. /// public int X { get; set; } /// /// Gets or sets the value of the second vector component. /// public int Y { get; set; } /// /// Gets or sets the value of the third vector component. /// public int Z { get; set; } /// /// Gets or sets the value of the first color component. /// public int R { get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(R)}"); set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(R)}"); } /// /// Gets or sets the value of the second color component. /// public int G { get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(G)}"); set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(G)}"); } /// /// Gets or sets the value of the third color component. /// public int B { get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(B)}"); set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(B)}"); } /// /// Gets or sets a specific component in the current instance. /// /// The index of the component to access. public int this[int i] { get => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]"); set => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]"); } /// /// Creates a new value with the same value for all its components. /// /// The value to use for the components of the new instance. public static implicit operator Int3(int x) => new(x, x, x); /// /// Casts a value to a one. /// /// The input value to cast. public static explicit operator UInt3(Int3 xyz) => throw new InvalidExecutionContextException($"{nameof(Int3)}.({nameof(UInt3)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static implicit operator Float3(Int3 xyz) => throw new InvalidExecutionContextException($"{nameof(Int3)}.({nameof(Float3)})"); /// /// Casts a value to a one. /// /// The input value to cast. public static implicit operator Double3(Int3 xyz) => throw new InvalidExecutionContextException($"{nameof(Int3)}.({nameof(Double3)})"); /// /// Negates a value. /// /// The value to negate. public static Int3 operator -(Int3 xyz) => throw new InvalidExecutionContextException($"{nameof(Int3)}.-"); /// /// Sums two values. /// /// The first value to sum. /// The second value to sum. public static Int3 operator +(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}.+"); /// /// Divides two values. /// /// The first value to divide. /// The second value to divide. public static Int3 operator /(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}./"); /// /// Multiplies two values. /// /// The first value to multiply. /// The second value to multiply. public static Int3 operator *(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}.*"); /// /// Subtracts two values. /// /// The first value to subtract. /// The second value to subtract. public static Int3 operator -(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}.-"); } }