private static uint Pack(float x, float y) { uint packX = HalfUtils.ConvertFloatToHalf(x); uint packY = (uint)(HalfUtils.ConvertFloatToHalf(y) << 16); return(packX | packY); }
/// <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)) )); }
void IPackedVector.PackFromVector4(Vector4 vector) { PackedValue = HalfUtils.ConvertFloatToHalf(vector.X); }
/// <summary> /// Expands the packed value to a <see cref="float"/>. /// </summary> public float ToSingle() => HalfUtils.ConvertHalfToFloat(PackedValue);
/// <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); }
/// <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); }