From dc759b1d573b59ff5c39dd2792c40ebdec7649a2 Mon Sep 17 00:00:00 2001 From: js6pak Date: Thu, 18 Mar 2021 21:34:47 +0100 Subject: [PATCH] Fix FloatRange ranges --- src/Impostor.Api/Unity/Mathf.cs | 4 +++- src/Impostor.Hazel/MessageReader.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Impostor.Api/Unity/Mathf.cs b/src/Impostor.Api/Unity/Mathf.cs index f796dec..c907f81 100644 --- a/src/Impostor.Api/Unity/Mathf.cs +++ b/src/Impostor.Api/Unity/Mathf.cs @@ -53,7 +53,9 @@ public static float ReverseLerp(float t) { - return Clamp((t - -40f) / (40f - -40f), 0f, 1f); + const float range = 50f; + + return Clamp((t - -range) / (range - -range), 0f, 1f); } } } diff --git a/src/Impostor.Hazel/MessageReader.cs b/src/Impostor.Hazel/MessageReader.cs index 3593329..317e45b 100644 --- a/src/Impostor.Hazel/MessageReader.cs +++ b/src/Impostor.Hazel/MessageReader.cs @@ -254,10 +254,12 @@ namespace Impostor.Hazel public Vector2 ReadVector2() { + const float range = 50f; + var x = ReadUInt16() / (float) ushort.MaxValue; var y = ReadUInt16() / (float) ushort.MaxValue; - return new Vector2(Mathf.Lerp(-40f, 40f, x), Mathf.Lerp(-40f, 40f, y)); + return new Vector2(Mathf.Lerp(-range, range, x), Mathf.Lerp(-range, range, y)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] -- 2.39.5