mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Compression: ScaleToLong/Float Vector3Long variants to prepare for NetworkTransform V3
This commit is contained in:
parent
701c16a307
commit
9e352f5be2
@ -71,6 +71,13 @@ public static bool ScaleToLong(Vector3 value, float precision, out long x, out l
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool ScaleToLong(Vector3 value, float precision, out Vector3Long quantized)
|
||||||
|
{
|
||||||
|
quantized = Vector3Long.zero;
|
||||||
|
return ScaleToLong(value, precision, out quantized.x, out quantized.y, out quantized.z);
|
||||||
|
}
|
||||||
|
|
||||||
// multiple by precision.
|
// multiple by precision.
|
||||||
// for example, 0.1 cm precision converts '50' long to '5.0f' float.
|
// for example, 0.1 cm precision converts '50' long to '5.0f' float.
|
||||||
public static float ScaleToFloat(long value, float precision)
|
public static float ScaleToFloat(long value, float precision)
|
||||||
@ -96,6 +103,10 @@ public static Vector3 ScaleToFloat(long x, long y, long z, float precision)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static Vector3 ScaleToFloat(Vector3Long value, float precision) =>
|
||||||
|
ScaleToFloat(value.x, value.y, value.z, precision);
|
||||||
|
|
||||||
// scale a float within min/max range to an ushort between min/max range
|
// scale a float within min/max range to an ushort between min/max range
|
||||||
// note: can also use this for byte range from byte.MinValue to byte.MaxValue
|
// note: can also use this for byte range from byte.MinValue to byte.MaxValue
|
||||||
public static ushort ScaleFloatToUShort(float value, float minValue, float maxValue, ushort minTarget, ushort maxTarget)
|
public static ushort ScaleFloatToUShort(float value, float minValue, float maxValue, ushort minTarget, ushort maxTarget)
|
||||||
|
Loading…
Reference in New Issue
Block a user