[DesktopVRIK] Fixed an issue where tracking status would update a frame late

This commit is contained in:
NotAKidoS 2023-07-29 16:49:06 -05:00
parent 02d6c7ec89
commit d3db894acf
6 changed files with 61 additions and 35 deletions

View file

@ -1,6 +1,7 @@
using ABI_RC.Core.Player;
using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.MovementSystem;
using NAK.DesktopVRIK.IK.VRIKHelpers;
using RootMotion.FinalIK;
using UnityEngine;
@ -31,11 +32,16 @@ internal class IKHandlerDesktop : IKHandler
_vrik.transform.localPosition = Vector3.zero;
_vrik.transform.localRotation = Quaternion.identity;
UpdateBodySystemTracking();
base.UpdateWeights();
}
public override void UpdateTracking()
{
BodySystem.TrackingEnabled = ShouldTrackAll();
BodySystem.TrackingLocomotionEnabled = BodySystem.TrackingEnabled && ShouldTrackLocomotion();
ResetSolverIfNeeded();
}
#endregion
#region VRIK Solver Events
@ -85,12 +91,6 @@ internal class IKHandlerDesktop : IKHandler
#endregion
#region Private Methods
private void UpdateBodySystemTracking()
{
BodySystem.TrackingEnabled = ShouldTrackAll();
BodySystem.TrackingLocomotionEnabled = ShouldTrackLocomotion();
}
private bool ShouldTrackAll()
{
@ -111,5 +111,17 @@ internal class IKHandlerDesktop : IKHandler
return !(isMoving || isCrouching || isProne || isFlying || isSitting || !isGrounded || !isStanding);
}
private void ResetSolverIfNeeded()
{
if (_wasTrackingLocomotion == BodySystem.TrackingLocomotionEnabled)
return;
_wasTrackingLocomotion = BodySystem.TrackingLocomotionEnabled;
if (ModSettings.EntryResetFootstepsOnIdle.Value)
VRIKUtils.ResetToInitialFootsteps(_vrik, _locomotionData, _scaleDifference);
_solver.Reset();
}
#endregion
}