Exemple #1
0
        private static uint Pack(float x, float y)
        {
            uint packX = HalfUtils.ConvertFloatToHalf(x);
            uint packY = (uint)(HalfUtils.ConvertFloatToHalf(y) << 16);

            return(packX | packY);
        }
Exemple #2
0
 /// <summary>
 /// Expands this <see cref="Half2"/> structure to a <see cref="Vector2"/>.
 /// </summary>
 public Vector2 ToVector2()
 {
     return(new Vector2(
                HalfUtils.ConvertHalfToFloat((ushort)PackedValue),
                HalfUtils.ConvertHalfToFloat((ushort)(PackedValue >> 16))
                ));
 }
Exemple #3
0
 void IPackedVector.PackFromVector4(Vector4 vector)
 {
     PackedValue = HalfUtils.ConvertFloatToHalf(vector.X);
 }
Exemple #4
0
 /// <summary>
 /// Expands the packed value to a <see cref="float"/>.
 /// </summary>
 public float ToSingle() => HalfUtils.ConvertHalfToFloat(PackedValue);
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Half"/> structure.
 /// </summary>
 /// <param name="value">The floating point value that should be stored in 16 bit format.</param>
 public Half(float value)
 {
     PackedValue = HalfUtils.ConvertFloatToHalf(value);
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Half"/> structure.
 /// </summary>
 /// <param name="vector">The <see cref="Vector4"/> to pack from.</param>
 public Half(Vector4 vector)
 {
     PackedValue = HalfUtils.ConvertFloatToHalf(vector.X);
 }