optimizing network stuff

This commit is contained in:
2025-07-30 05:51:39 +02:00
parent ea99249fe2
commit 159e9adcd7
56 changed files with 2272 additions and 1781 deletions

View File

@@ -0,0 +1,25 @@
using System.Runtime.CompilerServices;
namespace RebootKit.Engine.Foundation {
public static class QuantizationUtility {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ushort FloatToUShort(float value, float min, float max) {
return (ushort)((value - min) / (max - min) * ushort.MaxValue);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float UShortToFloat(ushort value, float min, float max) {
return min + (value / (float)ushort.MaxValue) * (max - min);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte FloatToByte(float value, float min, float max) {
return (byte)((value - min) / (max - min) * byte.MaxValue);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float ByteToFloat(byte value, float min, float max) {
return min + (value / (float)byte.MaxValue) * (max - min);
}
}
}