mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-04 07:19:22 +00:00
[DesktopVRIK] Fixed an issue where tracking status would update a frame late
This commit is contained in:
parent
02d6c7ec89
commit
d3db894acf
6 changed files with 61 additions and 35 deletions
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue