[AlternateIKSystem] Slight cleanup of BodyControls

This commit is contained in:
NotAKidoS 2023-07-12 12:14:08 -05:00
parent 16e44f7c35
commit 684b330a4c
4 changed files with 71 additions and 65 deletions

View file

@ -1,42 +1,12 @@
using RootMotion.FinalIK;
using ABI_RC.Core.Player;
using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK;
using UnityEngine;
namespace NAK.AlternateIKSystem.IK;
public static class BodyControl
public class BodyControl
{
#region Tracking Controls
public static bool TrackingAll = true;
public static bool TrackingHead = true;
public static bool TrackingPelvis = true;
public static bool TrackingLeftArm = true;
public static bool TrackingRightArm = true;
public static bool TrackingLeftLeg = true;
public static bool TrackingRightLeg = true;
//TODO: dont do this, it is effective but lazy
public static bool TrackingLocomotion
{
get => _trackingLocomotion;
set
{
if (_trackingLocomotion == value)
return;
_trackingLocomotion = value;
IKManager.solver?.Reset();
}
}
private static bool _trackingLocomotion = true;
public static float TrackingPositionWeight = 1f;
// TODO: decide if these are considered "Tracking Controls"
public static float TrackingUpright = 1f;
public static float TrackingMaxRootAngle = 0f;
#endregion
#region Player Settings
public static bool useHipTracking = true;
@ -53,12 +23,68 @@ public static class BodyControl
#endregion
#region Tracking Controls
public static bool TrackingAll = true;
public static bool TrackingHead = true;
public static bool TrackingPelvis = true;
public static bool TrackingLeftArm = true;
public static bool TrackingRightArm = true;
public static bool TrackingLeftLeg = true;
public static bool TrackingRightLeg = true;
public static bool TrackingLocomotion = true;
public static float TrackingPositionWeight = 1f;
// TODO: decide if this is considered "Tracking Controls"
public static float TrackingMaxRootAngle = 0f;
#endregion
#region Avatar Info
public static float AvatarUpright = 1f;
#endregion
#region BodyControl Configuration
public static float InvalidTrackerDistance = 1f;
#endregion
public void Update()
{
TrackingAll = ShouldTrackAll();
TrackingLocomotion = ShouldTrackLocomotion();
AvatarUpright = GetPlayerUpright();
}
#region Private Methods
private static bool ShouldTrackAll()
{
return !PlayerSetup.Instance._emotePlaying;
}
private static bool ShouldTrackLocomotion()
{
return !(MovementSystem.Instance.movementVector.magnitude > 0f
|| MovementSystem.Instance.crouching
|| MovementSystem.Instance.prone
|| MovementSystem.Instance.flying
|| MovementSystem.Instance.sitting
|| !MovementSystem.Instance._isGrounded);
}
private static float GetPlayerUpright()
{
float avatarHeight = PlayerSetup.Instance._avatarHeight;
float currentHeight = PlayerSetup.Instance.GetViewRelativePosition().y;
return Mathf.Clamp01((avatarHeight > 0f) ? (currentHeight / avatarHeight) : 0f);
}
#endregion
#region Solver Weight Helpers
public static void SetHeadWeight(IKSolverVR.Spine spine, LookAtIK lookAtIk, float weight)