From c99d6f07b5781915c806847d5fcf24c40f9f8628 Mon Sep 17 00:00:00 2001 From: kafeijao Date: Sat, 21 Jan 2023 16:55:09 +0000 Subject: [PATCH] [EyeMovementFix] Made the eyeAngle values to be between [-1; 1], corresponding to the min and max angle. --- EyeMovementFix/BetterEyeController.cs | 9 +++++++-- EyeMovementFix/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/EyeMovementFix/BetterEyeController.cs b/EyeMovementFix/BetterEyeController.cs index dfe8a99..5360a29 100644 --- a/EyeMovementFix/BetterEyeController.cs +++ b/EyeMovementFix/BetterEyeController.cs @@ -265,6 +265,11 @@ private void TargetHandler(CVREyeController controller) { } } + private static float NormalizeAngleToPercent(float angle, float maxAngle) { + var normal = Mathf.InverseLerp(-maxAngle, maxAngle, angle); + return Mathf.Lerp(-1f, 1f, normal); + } + private void UpdateEyeRotation(BetterEye eye, Quaternion lookRotation) { // Limit the rotation on the X and Y axes on the left eye @@ -286,8 +291,8 @@ private void UpdateEyeRotation(BetterEye eye, Quaternion lookRotation) { // Set the eye angle (we're setting twice if we have 2 eyes, but the values should be the same anyway) // This will give values different than cvr. I've opted to have the looking forward angle to be 0 - // And then goes between [-25;0] and [0;+25], instead of [335-360] and [0-25] (cvr default) - cvrEyeController.eyeAngle.Set(wrapperLocalRotation.y, wrapperLocalRotation.x); + // And then goes between [-1;0] and [0;+1], instead of [335-360] and [0-25] (cvr default) + cvrEyeController.eyeAngle.Set(NormalizeAngleToPercent(wrapperLocalRotation.y, MaxHorizontalAngle), NormalizeAngleToPercent(wrapperLocalRotation.x, MaxVerticalAngle)); } private void UpdateEyeRotations() { diff --git a/EyeMovementFix/Properties/AssemblyInfo.cs b/EyeMovementFix/Properties/AssemblyInfo.cs index ed0758d..bc61aa2 100644 --- a/EyeMovementFix/Properties/AssemblyInfo.cs +++ b/EyeMovementFix/Properties/AssemblyInfo.cs @@ -26,6 +26,6 @@ namespace EyeMovementFix.Properties; internal static class AssemblyInfoParams { - public const string Version = "2.0.0"; + public const string Version = "2.0.1"; public const string Author = "kafeijao"; }