Esempio n. 1
0
        private static float PickItem(ref Vector4 target, SwizzleItem item)
        {
            switch (item)
            {
            case SwizzleItem.X:
                return(target.x);

            case SwizzleItem.Y:
                return(target.y);

            case SwizzleItem.Z:
                return(target.z);

            case SwizzleItem.W:
                return(target.w);

            default:
                throw new ArgumentOutOfRangeException(nameof(item), item, $"Cannot pick swizzle item from {target}: unrecognized item name");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 重组向量分量
 /// </summary>
 /// <param name="value">目标向量</param>
 /// <param name="item1">分量1</param>
 /// <param name="item2">分量2</param>
 /// <returns></returns>
 public static Vector2 Swizzle(this Vector4 value, SwizzleItem item1, SwizzleItem item2)
 {
     return(new Vector2(PickItem(ref value, item1), PickItem(ref value, item2)));
 }
Esempio n. 3
0
 /// <summary>
 /// 重组向量分量
 /// </summary>
 /// <param name="value">目标向量</param>
 /// <param name="item1">分量1</param>
 /// <param name="item2">分量2</param>
 /// <param name="item3">分量3</param>
 /// <param name="item4">分量4</param>
 /// <returns></returns>
 public static Vector4 Swizzle(this Vector4 value, SwizzleItem item1, SwizzleItem item2, SwizzleItem item3, SwizzleItem item4)
 {
     return(new Vector4(PickItem(ref value, item1), PickItem(ref value, item2), PickItem(ref value, item3), PickItem(ref value, item4)));
 }
Esempio n. 4
0
 /// <summary>
 /// 重组向量分量
 /// </summary>
 /// <param name="value">目标向量</param>
 /// <param name="item1">分量1</param>
 /// <param name="item2">分量2</param>
 /// <param name="item3">分量3</param>
 /// <returns></returns>
 public static Vector3 Swizzle(this Vector3 value, SwizzleItem item1, SwizzleItem item2, SwizzleItem item3)
 {
     return(new Vector3(PickItem(ref value, item1), PickItem(ref value, item2), PickItem(ref value, item3)));
 }