Skip to content

Commit

Permalink
[EyeMovementFix] Made the eyeAngle values to be between [-1; 1], corr…
Browse files Browse the repository at this point in the history
…esponding to the min and max angle.
  • Loading branch information
kafeijao committed Jan 21, 2023
1 parent 65ccee9 commit c99d6f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions EyeMovementFix/BetterEyeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion EyeMovementFix/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

0 comments on commit c99d6f0

Please sign in to comment.